Completed
Push — master ( caebd9...55f541 )
by Yannick
09:39
created
require/class.Marine.php 1 patch
Spacing   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Image.php');
10 10
 $global_marine_query = "SELECT marine_output.* FROM marine_output";
11 11
 
12
-class Marine{
12
+class Marine {
13 13
 	public $db;
14 14
 	
15 15
 	public function __construct($dbc = null) {
@@ -25,33 +25,33 @@  discard block
 block discarded – undo
25 25
      * @param bool $and
26 26
      * @return string the SQL part
27 27
      */
28
-	public function getFilter($filter = array(),$where = false,$and = false) {
28
+	public function getFilter($filter = array(), $where = false, $and = false) {
29 29
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
30 30
 		$filters = array();
31 31
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
32 32
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
33 33
 				$filters = $globalStatsFilters[$globalFilterName];
34 34
 			} else {
35
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
35
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
36 36
 			}
37 37
 		}
38 38
 		if (isset($filter[0]['source'])) {
39
-			$filters = array_merge($filters,$filter);
39
+			$filters = array_merge($filters, $filter);
40 40
 		}
41
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
41
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
42 42
 		$filter_query_join = '';
43 43
 		$filter_query_where = '';
44
-		foreach($filters as $flt) {
44
+		foreach ($filters as $flt) {
45 45
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$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'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
47
+					$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'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
48 48
 				} else {
49
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
49
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
50 50
 				}
51 51
 			}
52 52
 		}
53 53
 		if (isset($filter['source']) && !empty($filter['source'])) {
54
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
54
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
55 55
 		}
56 56
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
57 57
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
90 90
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
91 91
 		if ($filter_query_where != '') {
92
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
92
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
93 93
 		}
94 94
 		$filter_query = $filter_query_join.$filter_query_where;
95 95
 		return $filter_query;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @param bool $schedules
105 105
      * @return array the spotter information
106 106
      */
107
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
107
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
108 108
 	{
109 109
 		global $globalVM;
110 110
 		date_default_timezone_set('UTC');
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 			$sth = $this->db->prepare($query.$limitQuery);
126 126
 			$sth->execute($params);
127 127
 		} catch (PDOException $e) {
128
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
128
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
129 129
 			exit();
130 130
 		}
131 131
 		
132 132
 		$num_rows = 0;
133 133
 		$spotter_array = array();
134
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
134
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
135 135
 		{
136 136
 			$num_rows++;
137 137
 			$temp_array = array();
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			}
151 151
 			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
152 152
 			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
153
-			if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES);
153
+			if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'], ENT_QUOTES);
154 154
 			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
155 155
 			if (isset($row['status'])) $temp_array['status'] = $row['status'];
156 156
 			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 			}
174 174
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
175 175
 
176
-			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
176
+			if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
177 177
 			{
178 178
 				$Image = new Image($this->db);
179
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
179
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
180 180
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
181 181
 				unset($Image);
182 182
 				if (count($image_array) > 0) {
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 					$temp_array['image_source_website'] = $image_array[0]['image_source_website'];
187 187
 					$temp_array['image_copyright'] = $image_array[0]['image_copyright'];
188 188
 				}
189
-			} elseif(isset($temp_array['type']) && $temp_array['type'] != "")
189
+			} elseif (isset($temp_array['type']) && $temp_array['type'] != "")
190 190
 			{
191 191
 				$Image = new Image($this->db);
192
-				$image_array = $Image->getMarineImage('','','',$temp_array['type']);
192
+				$image_array = $Image->getMarineImage('', '', '', $temp_array['type']);
193 193
 				unset($Image);
194 194
 				if (count($image_array) > 0) {
195 195
 					$temp_array['image'] = $image_array[0]['image'];
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
 				{
225 225
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
226 226
 				} else {
227
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
227
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
228 228
 				}
229 229
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
230
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
231
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
230
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
231
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
232 232
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
233 233
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
234 234
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
235 235
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
236
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
237
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
236
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
237
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
238 238
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
239 239
 					}
240 240
 				}
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 		if ($limit != "")
270 270
 		{
271 271
 			$limit_array = explode(",", $limit);
272
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
273
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
272
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
273
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
274 274
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
275 275
 			{
276 276
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 		} else {
285 285
 			$orderby_query = " ORDER BY marine_output.date DESC";
286 286
 		}
287
-		$query  = $global_marine_query.$filter_query." ".$orderby_query;
288
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
287
+		$query = $global_marine_query.$filter_query." ".$orderby_query;
288
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
289 289
 		return $spotter_array;
290 290
 	}
291 291
     
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 		if ($id == '') return array();
304 304
 		$additional_query = "marine_output.fammarine_id = :id";
305 305
 		$query_values = array(':id' => $id);
306
-		$query  = $global_marine_query." WHERE ".$additional_query." ";
307
-		$spotter_array = $this->getDataFromDB($query,$query_values);
306
+		$query = $global_marine_query." WHERE ".$additional_query." ";
307
+		$spotter_array = $this->getDataFromDB($query, $query_values);
308 308
 		return $spotter_array;
309 309
 	}
310 310
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		$query_values = array();
327 327
 		$limit_query = '';
328 328
 		$additional_query = '';
329
-		$filter_query = $this->getFilter($filter,true,true);
329
+		$filter_query = $this->getFilter($filter, true, true);
330 330
 		if ($ident != "")
331 331
 		{
332 332
 			if (!is_string($ident))
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 		{
343 343
 			$limit_array = explode(",", $limit);
344 344
 			
345
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
346
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
345
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
346
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
347 347
 			
348 348
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
349 349
 			{
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 		date_default_timezone_set('UTC');
384 384
 		
385 385
 		$limit_query = '';
386
-		$filter_query = $this->getFilter($filter,true,true);
386
+		$filter_query = $this->getFilter($filter, true, true);
387 387
 		if (!is_string($type))
388 388
 		{
389 389
 			return array();
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 		{
397 397
 			$limit_array = explode(",", $limit);
398 398
 			
399
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
400
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
399
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
400
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
401 401
 			
402 402
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
403 403
 			{
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		$limit_query = '';
437 437
 		$additional_query = '';
438 438
 
439
-		$filter_query = $this->getFilter($filter,true,true);
439
+		$filter_query = $this->getFilter($filter, true, true);
440 440
 		
441 441
 		if ($date != "")
442 442
 		{
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 		{
463 463
 			$limit_array = explode(",", $limit);
464 464
 			
465
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
466
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
465
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
466
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
467 467
 			
468 468
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
469 469
 			{
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 		$query_values = array();
502 502
 		$limit_query = '';
503 503
 		$additional_query = '';
504
-		$filter_query = $this->getFilter($filter,true,true);
505
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
504
+		$filter_query = $this->getFilter($filter, true, true);
505
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
506 506
 		if ($captain != "")
507 507
 		{
508 508
 			$additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)";
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 		if ($limit != "")
512 512
 		{
513 513
 			$limit_array = explode(",", $limit);
514
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
515
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
514
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
515
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
516 516
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
517 517
 			{
518 518
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -542,13 +542,13 @@  discard block
 block discarded – undo
542 542
      */
543 543
 	public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array())
544 544
 	{
545
-		global $global_marine_query,$globalDBdriver;
545
+		global $global_marine_query, $globalDBdriver;
546 546
 		date_default_timezone_set('UTC');
547 547
 		$query_values = array();
548 548
 		$limit_query = '';
549 549
 		$additional_query = '';
550
-		$filter_query = $this->getFilter($filter,true,true);
551
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
550
+		$filter_query = $this->getFilter($filter, true, true);
551
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
552 552
 		if ($race != "")
553 553
 		{
554 554
 			$additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)";
@@ -557,8 +557,8 @@  discard block
 block discarded – undo
557 557
 		if ($limit != "")
558 558
 		{
559 559
 			$limit_array = explode(",", $limit);
560
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
561
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
560
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
561
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
562 562
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
563 563
 			{
564 564
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -588,14 +588,14 @@  discard block
 block discarded – undo
588 588
      * @param array $filters
589 589
      * @return Integer number of race for a captain
590 590
      */
591
-	public function countRacesByCaptain($captain,$filters = array())
591
+	public function countRacesByCaptain($captain, $filters = array())
592 592
 	{
593
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
594
-		$filter_query = $this->getFilter($filters,true,true);
595
-		$query  = "SELECT COUNT(*) AS nb 
593
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
594
+		$filter_query = $this->getFilter($filters, true, true);
595
+		$query = "SELECT COUNT(*) AS nb 
596 596
 			FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)";
597 597
 		$query_values = array();
598
-		$query_values = array_merge($query_values,array(':captain' => $captain));
598
+		$query_values = array_merge($query_values, array(':captain' => $captain));
599 599
 		$sth = $this->db->prepare($query);
600 600
 		$sth->execute($query_values);
601 601
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -609,14 +609,14 @@  discard block
 block discarded – undo
609 609
      * @param array $filters
610 610
      * @return String Duration of all races
611 611
      */
612
-	public function countCaptainsByRace($race,$filters = array())
612
+	public function countCaptainsByRace($race, $filters = array())
613 613
 	{
614
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
615
-		$filter_query = $this->getFilter($filters,true,true);
616
-		$query  = "SELECT COUNT(*) AS nb 
614
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
615
+		$filter_query = $this->getFilter($filters, true, true);
616
+		$query = "SELECT COUNT(*) AS nb 
617 617
 			FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)";
618 618
 		$query_values = array();
619
-		$query_values = array_merge($query_values,array(':race' => $race));
619
+		$query_values = array_merge($query_values, array(':race' => $race));
620 620
 		$sth = $this->db->prepare($query);
621 621
 		$sth->execute($query_values);
622 622
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -633,44 +633,44 @@  discard block
 block discarded – undo
633 633
      * @param string $day
634 634
      * @return array the boat list
635 635
      */
636
-	public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
636
+	public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '')
637 637
 	{
638 638
 		global $globalDBdriver;
639
-		$filter_query = $this->getFilter($filters,true,true);
640
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
641
-		$query  = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
639
+		$filter_query = $this->getFilter($filters, true, true);
640
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
641
+		$query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
642 642
 			FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)";
643 643
 		$query_values = array();
644 644
 		if ($year != '') {
645 645
 			if ($globalDBdriver == 'mysql') {
646 646
 				$query .= " AND YEAR(marine_output.date) = :year";
647
-				$query_values = array_merge($query_values,array(':year' => $year));
647
+				$query_values = array_merge($query_values, array(':year' => $year));
648 648
 			} else {
649 649
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
650
-				$query_values = array_merge($query_values,array(':year' => $year));
650
+				$query_values = array_merge($query_values, array(':year' => $year));
651 651
 			}
652 652
 		}
653 653
 		if ($month != '') {
654 654
 			if ($globalDBdriver == 'mysql') {
655 655
 				$query .= " AND MONTH(marine_output.date) = :month";
656
-				$query_values = array_merge($query_values,array(':month' => $month));
656
+				$query_values = array_merge($query_values, array(':month' => $month));
657 657
 			} else {
658 658
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
659
-				$query_values = array_merge($query_values,array(':month' => $month));
659
+				$query_values = array_merge($query_values, array(':month' => $month));
660 660
 			}
661 661
 		}
662 662
 		if ($day != '') {
663 663
 			if ($globalDBdriver == 'mysql') {
664 664
 				$query .= " AND DAY(marine_output.date) = :day";
665
-				$query_values = array_merge($query_values,array(':day' => $day));
665
+				$query_values = array_merge($query_values, array(':day' => $day));
666 666
 			} else {
667 667
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
668
-				$query_values = array_merge($query_values,array(':day' => $day));
668
+				$query_values = array_merge($query_values, array(':day' => $day));
669 669
 			}
670 670
 		}
671 671
 		$query .= " GROUP BY marine_output.type
672 672
 			ORDER BY type_count DESC";
673
-		$query_values = array_merge($query_values,array(':captain' => $captain));
673
+		$query_values = array_merge($query_values, array(':captain' => $captain));
674 674
 		$sth = $this->db->prepare($query);
675 675
 		$sth->execute($query_values);
676 676
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -686,44 +686,44 @@  discard block
 block discarded – undo
686 686
      * @param string $day
687 687
      * @return array the boat list
688 688
      */
689
-	public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '')
689
+	public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '')
690 690
 	{
691 691
 		global $globalDBdriver;
692
-		$filter_query = $this->getFilter($filters,true,true);
693
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
694
-		$query  = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
692
+		$filter_query = $this->getFilter($filters, true, true);
693
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
694
+		$query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
695 695
 			FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)";
696 696
 		$query_values = array();
697 697
 		if ($year != '') {
698 698
 			if ($globalDBdriver == 'mysql') {
699 699
 				$query .= " AND YEAR(marine_output.date) = :year";
700
-				$query_values = array_merge($query_values,array(':year' => $year));
700
+				$query_values = array_merge($query_values, array(':year' => $year));
701 701
 			} else {
702 702
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
703
-				$query_values = array_merge($query_values,array(':year' => $year));
703
+				$query_values = array_merge($query_values, array(':year' => $year));
704 704
 			}
705 705
 		}
706 706
 		if ($month != '') {
707 707
 			if ($globalDBdriver == 'mysql') {
708 708
 				$query .= " AND MONTH(marine_output.date) = :month";
709
-				$query_values = array_merge($query_values,array(':month' => $month));
709
+				$query_values = array_merge($query_values, array(':month' => $month));
710 710
 			} else {
711 711
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
712
-				$query_values = array_merge($query_values,array(':month' => $month));
712
+				$query_values = array_merge($query_values, array(':month' => $month));
713 713
 			}
714 714
 		}
715 715
 		if ($day != '') {
716 716
 			if ($globalDBdriver == 'mysql') {
717 717
 				$query .= " AND DAY(marine_output.date) = :day";
718
-				$query_values = array_merge($query_values,array(':day' => $day));
718
+				$query_values = array_merge($query_values, array(':day' => $day));
719 719
 			} else {
720 720
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
721
-				$query_values = array_merge($query_values,array(':day' => $day));
721
+				$query_values = array_merge($query_values, array(':day' => $day));
722 722
 			}
723 723
 		}
724 724
 		$query .= " GROUP BY marine_output.type
725 725
 			ORDER BY type_count DESC";
726
-		$query_values = array_merge($query_values,array(':race' => $race));
726
+		$query_values = array_merge($query_values, array(':race' => $race));
727 727
 		$sth = $this->db->prepare($query);
728 728
 		$sth->execute($query_values);
729 729
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -739,47 +739,47 @@  discard block
 block discarded – undo
739 739
      * @param string $day
740 740
      * @return String Duration of all race
741 741
      */
742
-	public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
742
+	public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '')
743 743
 	{
744 744
 		global $globalDBdriver;
745
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
746
-		$filter_query = $this->getFilter($filters,true,true);
747
-		$query  = "SELECT SUM(last_seen - date) AS duration 
745
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
746
+		$filter_query = $this->getFilter($filters, true, true);
747
+		$query = "SELECT SUM(last_seen - date) AS duration 
748 748
 		    FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) 
749 749
 		    AND last_seen > date";
750 750
 		$query_values = array();
751 751
 		if ($year != '') {
752 752
 			if ($globalDBdriver == 'mysql') {
753 753
 				$query .= " AND YEAR(marine_output.date) = :year";
754
-				$query_values = array_merge($query_values,array(':year' => $year));
754
+				$query_values = array_merge($query_values, array(':year' => $year));
755 755
 			} else {
756 756
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
757
-				$query_values = array_merge($query_values,array(':year' => $year));
757
+				$query_values = array_merge($query_values, array(':year' => $year));
758 758
 			}
759 759
 		}
760 760
 		if ($month != '') {
761 761
 			if ($globalDBdriver == 'mysql') {
762 762
 				$query .= " AND MONTH(marine_output.date) = :month";
763
-				$query_values = array_merge($query_values,array(':month' => $month));
763
+				$query_values = array_merge($query_values, array(':month' => $month));
764 764
 			} else {
765 765
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
766
-				$query_values = array_merge($query_values,array(':month' => $month));
766
+				$query_values = array_merge($query_values, array(':month' => $month));
767 767
 			}
768 768
 		}
769 769
 		if ($day != '') {
770 770
 			if ($globalDBdriver == 'mysql') {
771 771
 				$query .= " AND DAY(marine_output.date) = :day";
772
-				$query_values = array_merge($query_values,array(':day' => $day));
772
+				$query_values = array_merge($query_values, array(':day' => $day));
773 773
 			} else {
774 774
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
775
-				$query_values = array_merge($query_values,array(':day' => $day));
775
+				$query_values = array_merge($query_values, array(':day' => $day));
776 776
 			}
777 777
 		}
778
-		$query_values = array_merge($query_values,array(':captain' => $captain));
778
+		$query_values = array_merge($query_values, array(':captain' => $captain));
779 779
 		$sth = $this->db->prepare($query);
780 780
 		$sth->execute($query_values);
781 781
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
782
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
782
+		if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
783 783
 		else return $result[0]['duration'];
784 784
 	}
785 785
 
@@ -793,38 +793,38 @@  discard block
 block discarded – undo
793 793
      * @param string $day
794 794
      * @return array Duration of all race
795 795
      */
796
-	public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '')
796
+	public function getRaceDurationByCaptains($limit = true, $filters = array(), $year = '', $month = '', $day = '')
797 797
 	{
798 798
 		global $globalDBdriver;
799
-		$filter_query = $this->getFilter($filters,true,true);
800
-		$query  = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name 
799
+		$filter_query = $this->getFilter($filters, true, true);
800
+		$query = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name 
801 801
 		    FROM marine_output".$filter_query." last_seen > date";
802 802
 		$query_values = array();
803 803
 		if ($year != '') {
804 804
 			if ($globalDBdriver == 'mysql') {
805 805
 				$query .= " AND YEAR(marine_output.date) = :year";
806
-				$query_values = array_merge($query_values,array(':year' => $year));
806
+				$query_values = array_merge($query_values, array(':year' => $year));
807 807
 			} else {
808 808
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
809
-				$query_values = array_merge($query_values,array(':year' => $year));
809
+				$query_values = array_merge($query_values, array(':year' => $year));
810 810
 			}
811 811
 		}
812 812
 		if ($month != '') {
813 813
 			if ($globalDBdriver == 'mysql') {
814 814
 				$query .= " AND MONTH(marine_output.date) = :month";
815
-				$query_values = array_merge($query_values,array(':month' => $month));
815
+				$query_values = array_merge($query_values, array(':month' => $month));
816 816
 			} else {
817 817
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
818
-				$query_values = array_merge($query_values,array(':month' => $month));
818
+				$query_values = array_merge($query_values, array(':month' => $month));
819 819
 			}
820 820
 		}
821 821
 		if ($day != '') {
822 822
 			if ($globalDBdriver == 'mysql') {
823 823
 				$query .= " AND DAY(marine_output.date) = :day";
824
-				$query_values = array_merge($query_values,array(':day' => $day));
824
+				$query_values = array_merge($query_values, array(':day' => $day));
825 825
 			} else {
826 826
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
827
-				$query_values = array_merge($query_values,array(':day' => $day));
827
+				$query_values = array_merge($query_values, array(':day' => $day));
828 828
 			}
829 829
 		}
830 830
 		$query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC";
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 		$duration_array = array();
837 837
 		$temp_array = array();
838 838
         
839
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
839
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
840 840
 		{
841 841
 			if ($row['duration'] != '') {
842 842
 				$temp_array['marine_duration_days'] = $row['duration'];
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
      */
859 859
 	public function getAllCaptainNames($filters = array())
860 860
 	{
861
-		$filter_query = $this->getFilter($filters,true,true);
862
-		$query  = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id
861
+		$filter_query = $this->getFilter($filters, true, true);
862
+		$query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id
863 863
 			FROM marine_output".$filter_query." marine_output.captain_name <> '' 
864 864
 			ORDER BY marine_output.captain_name ASC";
865 865
 	
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
      */
877 877
 	public function getAllRaceNames($filters = array())
878 878
 	{
879
-		$filter_query = $this->getFilter($filters,true,true);
880
-		$query  = "SELECT DISTINCT marine_output.race_name, marine_output.race_id
879
+		$filter_query = $this->getFilter($filters, true, true);
880
+		$query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id
881 881
 			FROM marine_output".$filter_query." marine_output.race_name <> '' 
882 882
 			ORDER BY marine_output.race_name ASC";
883 883
 	
@@ -894,11 +894,11 @@  discard block
 block discarded – undo
894 894
      * @param array $filters
895 895
      * @return array list of source name
896 896
      */
897
-	public function getAllSourceName($type = '',$filters = array())
897
+	public function getAllSourceName($type = '', $filters = array())
898 898
 	{
899
-		$filter_query = $this->getFilter($filters,true,true);
899
+		$filter_query = $this->getFilter($filters, true, true);
900 900
 		$query_values = array();
901
-		$query  = "SELECT DISTINCT marine_output.source_name 
901
+		$query = "SELECT DISTINCT marine_output.source_name 
902 902
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
903 903
 		if ($type != '') {
904 904
 			$query_values = array(':type' => $type);
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 		$source_array = array();
914 914
 		$temp_array = array();
915 915
 		
916
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
916
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
917 917
 		{
918 918
 			$temp_array['source_name'] = $row['source_name'];
919 919
 			$source_array[] = $temp_array;
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
      */
931 931
 	public function getAllIdents($filters = array())
932 932
 	{
933
-		$filter_query = $this->getFilter($filters,true,true);
934
-		$query  = "SELECT DISTINCT marine_output.ident
933
+		$filter_query = $this->getFilter($filters, true, true);
934
+		$query = "SELECT DISTINCT marine_output.ident
935 935
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
936 936
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
937 937
 
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 		$ident_array = array();
942 942
 		$temp_array = array();
943 943
 		
944
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
944
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
945 945
 		{
946 946
 			$temp_array['ident'] = $row['ident'];
947 947
 			$ident_array[] = $temp_array;
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
      */
959 959
 	public function getIdentity($mmsi)
960 960
 	{
961
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
961
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
962 962
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
963 963
 		$sth = $this->db->prepare($query);
964 964
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -975,23 +975,23 @@  discard block
 block discarded – undo
975 975
      * @param $callsign
976 976
      * @param $type
977 977
      */
978
-	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
978
+	public function addIdentity($mmsi, $imo, $ident, $callsign, $type)
979 979
 	{
980
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
980
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
981 981
 		if ($mmsi != '') {
982
-			$imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT);
983
-			$ident = filter_var($ident,FILTER_SANITIZE_STRING);
984
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
985
-			$type = filter_var($type,FILTER_SANITIZE_STRING);
982
+			$imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT);
983
+			$ident = filter_var($ident, FILTER_SANITIZE_STRING);
984
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
985
+			$type = filter_var($type, FILTER_SANITIZE_STRING);
986 986
 			$identinfo = $this->getIdentity($mmsi);
987 987
 			if (empty($identinfo)) {
988
-				$query  = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
988
+				$query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
989 989
 				$sth = $this->db->prepare($query);
990
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type));
990
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type));
991 991
 			} elseif ($ident != '' && $identinfo['ship_name'] != $ident) {
992
-				$query  = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
992
+				$query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
993 993
 				$sth = $this->db->prepare($query);
994
-				$sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type));
994
+				$sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type));
995 995
 			}
996 996
 		}
997 997
 	}
@@ -1012,12 +1012,12 @@  discard block
 block discarded – undo
1012 1012
 		} else $offset = '+00:00';
1013 1013
 
1014 1014
 		if ($globalDBdriver == 'mysql') {
1015
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
1015
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
1016 1016
 								FROM marine_output
1017 1017
 								WHERE marine_output.date <> '' 
1018 1018
 								ORDER BY marine_output.date ASC LIMIT 0,100";
1019 1019
 		} else {
1020
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
1020
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
1021 1021
 								FROM marine_output
1022 1022
 								WHERE marine_output.date <> '' 
1023 1023
 								ORDER BY marine_output.date ASC LIMIT 0,100";
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 		$date_array = array();
1030 1030
 		$temp_array = array();
1031 1031
 		
1032
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1032
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1033 1033
 		{
1034 1034
 			$temp_array['date'] = $row['date'];
1035 1035
 
@@ -1047,10 +1047,10 @@  discard block
 block discarded – undo
1047 1047
 	* @return String success or false
1048 1048
 	*
1049 1049
 	*/
1050
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
1050
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
1051 1051
 	{
1052 1052
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
1053
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
1053
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
1054 1054
 		try {
1055 1055
 			$sth = $this->db->prepare($query);
1056 1056
 			$sth->execute($query_values);
@@ -1068,10 +1068,10 @@  discard block
 block discarded – undo
1068 1068
 	* @return String success or false
1069 1069
 	*
1070 1070
 	*/
1071
-	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
1071
+	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL)
1072 1072
 	{
1073 1073
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
1074
-		$query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code);
1074
+		$query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code);
1075 1075
 		try {
1076 1076
 			$sth = $this->db->prepare($query);
1077 1077
 			$sth->execute($query_values);
@@ -1090,11 +1090,11 @@  discard block
 block discarded – undo
1090 1090
 	* @return String success or false
1091 1091
 	*
1092 1092
 	*/
1093
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
1093
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
1094 1094
 	{
1095 1095
 
1096 1096
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
1097
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1097
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
1098 1098
 
1099 1099
 		try {
1100 1100
 			$sth = $this->db->prepare($query);
@@ -1123,17 +1123,17 @@  discard block
 block discarded – undo
1123 1123
      * @param string $race_begin
1124 1124
      * @return String success or false
1125 1125
      */
1126
-	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1126
+	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1127 1127
 	{
1128 1128
 		if ($latitude == '') $latitude = NULL;
1129 1129
 		if ($longitude == '') $longitude = NULL;
1130 1130
 		$groundspeed = round($groundspeed);
1131 1131
 		if ($race_begin != '') {
1132 1132
 			$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id';
1133
-			$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status,':race_begin' => $race_begin);
1133
+			$query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status, ':race_begin' => $race_begin);
1134 1134
 		} else {
1135 1135
 			$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status WHERE fammarine_id = :fammarine_id';
1136
-			$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status);
1136
+			$query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status);
1137 1137
 		}
1138 1138
 		try {
1139 1139
 			$sth = $this->db->prepare($query);
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
      * @param string $race_time
1178 1178
      * @return String success or false
1179 1179
      */
1180
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '')
1180
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1181 1181
 	{
1182 1182
 		global $globalMarineImageFetch;
1183 1183
 		
@@ -1249,34 +1249,34 @@  discard block
 block discarded – undo
1249 1249
 			$date = date("Y-m-d H:i:s", time());
1250 1250
 		}
1251 1251
 
1252
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1253
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1254
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1255
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1256
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1257
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1258
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1259
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
1260
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
1261
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
1262
-		$type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
1263
-		$status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
1264
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1265
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1266
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
1267
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
1268
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
1269
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
1270
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1271
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1272
-		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1273
-		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1274
-		$distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1252
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1253
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1254
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1255
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1256
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1257
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1258
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1259
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
1260
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
1261
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
1262
+		$type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
1263
+		$status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
1264
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1265
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1266
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
1267
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
1268
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
1269
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
1270
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
1271
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
1272
+		$race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT);
1273
+		$race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1274
+		$distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1275 1275
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
1276 1276
 			$Image = new Image($this->db);
1277
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
1277
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
1278 1278
 			if (!isset($image_array[0]['mmsi'])) {
1279
-				$Image->addMarineImage($mmsi,$imo,$ident);
1279
+				$Image->addMarineImage($mmsi, $imo, $ident);
1280 1280
 			}
1281 1281
 			unset($Image);
1282 1282
 		}
@@ -1292,10 +1292,10 @@  discard block
 block discarded – undo
1292 1292
 		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1293 1293
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1294 1294
 		if ($arrival_date == '') $arrival_date = NULL;
1295
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1295
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1296 1296
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)";
1297 1297
 
1298
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time);
1298
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time);
1299 1299
 		try {
1300 1300
 			$sth = $this->db->prepare($query);
1301 1301
 			$sth->execute($query_values);
@@ -1319,13 +1319,13 @@  discard block
 block discarded – undo
1319 1319
 	{
1320 1320
 		global $globalDBdriver, $globalTimezone;
1321 1321
 		if ($globalDBdriver == 'mysql') {
1322
-			$query  = "SELECT marine_output.ident FROM marine_output 
1322
+			$query = "SELECT marine_output.ident FROM marine_output 
1323 1323
 								WHERE marine_output.ident = :ident 
1324 1324
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
1325 1325
 								AND marine_output.date < UTC_TIMESTAMP()";
1326 1326
 			$query_data = array(':ident' => $ident);
1327 1327
 		} else {
1328
-			$query  = "SELECT marine_output.ident FROM marine_output 
1328
+			$query = "SELECT marine_output.ident FROM marine_output 
1329 1329
 								WHERE marine_output.ident = :ident 
1330 1330
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
1331 1331
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -1334,8 +1334,8 @@  discard block
 block discarded – undo
1334 1334
 		
1335 1335
 		$sth = $this->db->prepare($query);
1336 1336
 		$sth->execute($query_data);
1337
-    		$ident_result='';
1338
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1337
+    		$ident_result = '';
1338
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1339 1339
 		{
1340 1340
 			$ident_result = $row['ident'];
1341 1341
 		}
@@ -1361,8 +1361,8 @@  discard block
 block discarded – undo
1361 1361
 				return false;
1362 1362
 			} else {
1363 1363
 				$q_array = explode(" ", $q);
1364
-				foreach ($q_array as $q_item){
1365
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1364
+				foreach ($q_array as $q_item) {
1365
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1366 1366
 					$additional_query .= " AND (";
1367 1367
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
1368 1368
 					$additional_query .= ")";
@@ -1370,11 +1370,11 @@  discard block
 block discarded – undo
1370 1370
 			}
1371 1371
 		}
1372 1372
 		if ($globalDBdriver == 'mysql') {
1373
-			$query  = "SELECT marine_output.* FROM marine_output 
1373
+			$query = "SELECT marine_output.* FROM marine_output 
1374 1374
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
1375 1375
 				AND marine_output.date < UTC_TIMESTAMP()";
1376 1376
 		} else {
1377
-			$query  = "SELECT marine_output.* FROM marine_output 
1377
+			$query = "SELECT marine_output.* FROM marine_output 
1378 1378
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1379 1379
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1380 1380
 		}
@@ -1394,16 +1394,16 @@  discard block
 block discarded – undo
1394 1394
      * @return array the airline country list
1395 1395
      */
1396 1396
 
1397
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1397
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
1398 1398
 	{
1399 1399
 		global $globalDBdriver, $globalArchive;
1400 1400
 		//$filter_query = $this->getFilter($filters,true,true);
1401
-		$Connection= new Connection($this->db);
1401
+		$Connection = new Connection($this->db);
1402 1402
 		if (!$Connection->tableExists('countries')) return array();
1403 1403
 		require_once('class.SpotterLive.php');
1404 1404
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
1405 1405
 			$MarineLive = new MarineLive($this->db);
1406
-			$filter_query = $MarineLive->getFilter($filters,true,true);
1406
+			$filter_query = $MarineLive->getFilter($filters, true, true);
1407 1407
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
1408 1408
 			if ($olderthanmonths > 0) {
1409 1409
 				if ($globalDBdriver == 'mysql') {
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 		} else {
1424 1424
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
1425 1425
 			$MarineArchive = new MarineArchive($this->db);
1426
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
1426
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
1427 1427
 			$filter_query .= " over_country <> ''";
1428 1428
 			if ($olderthanmonths > 0) {
1429 1429
 				if ($globalDBdriver == 'mysql') {
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 		$flight_array = array();
1452 1452
 		$temp_array = array();
1453 1453
         
1454
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1454
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1455 1455
 		{
1456 1456
 			$temp_array['marine_count'] = $row['nb'];
1457 1457
 			$temp_array['marine_country'] = $row['name'];
@@ -1475,11 +1475,11 @@  discard block
 block discarded – undo
1475 1475
      * @param string $day
1476 1476
      * @return array the callsign list
1477 1477
      */
1478
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1478
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1479 1479
 	{
1480 1480
 		global $globalDBdriver;
1481
-		$filter_query = $this->getFilter($filters,true,true);
1482
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1481
+		$filter_query = $this->getFilter($filters, true, true);
1482
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1483 1483
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1484 1484
 		 if ($olderthanmonths > 0) {
1485 1485
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -1493,28 +1493,28 @@  discard block
 block discarded – undo
1493 1493
 		if ($year != '') {
1494 1494
 			if ($globalDBdriver == 'mysql') {
1495 1495
 				$query .= " AND YEAR(marine_output.date) = :year";
1496
-				$query_values = array_merge($query_values,array(':year' => $year));
1496
+				$query_values = array_merge($query_values, array(':year' => $year));
1497 1497
 			} else {
1498 1498
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1499
-				$query_values = array_merge($query_values,array(':year' => $year));
1499
+				$query_values = array_merge($query_values, array(':year' => $year));
1500 1500
 			}
1501 1501
 		}
1502 1502
 		if ($month != '') {
1503 1503
 			if ($globalDBdriver == 'mysql') {
1504 1504
 				$query .= " AND MONTH(marine_output.date) = :month";
1505
-				$query_values = array_merge($query_values,array(':month' => $month));
1505
+				$query_values = array_merge($query_values, array(':month' => $month));
1506 1506
 			} else {
1507 1507
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1508
-				$query_values = array_merge($query_values,array(':month' => $month));
1508
+				$query_values = array_merge($query_values, array(':month' => $month));
1509 1509
 			}
1510 1510
 		}
1511 1511
 		if ($day != '') {
1512 1512
 			if ($globalDBdriver == 'mysql') {
1513 1513
 				$query .= " AND DAY(marine_output.date) = :day";
1514
-				$query_values = array_merge($query_values,array(':day' => $day));
1514
+				$query_values = array_merge($query_values, array(':day' => $day));
1515 1515
 			} else {
1516 1516
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1517
-				$query_values = array_merge($query_values,array(':day' => $day));
1517
+				$query_values = array_merge($query_values, array(':day' => $day));
1518 1518
 			}
1519 1519
 		}
1520 1520
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
 		$callsign_array = array();
1527 1527
 		$temp_array = array();
1528 1528
         
1529
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1529
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1530 1530
 		{
1531 1531
 			$temp_array['callsign_icao'] = $row['ident'];
1532 1532
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 		$date_array = array();
1579 1579
 		$temp_array = array();
1580 1580
         
1581
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1581
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1582 1582
 		{
1583 1583
 			$temp_array['date_name'] = $row['date_name'];
1584 1584
 			$temp_array['date_count'] = $row['date_count'];
@@ -1604,7 +1604,7 @@  discard block
 block discarded – undo
1604 1604
 			$datetime = new DateTime();
1605 1605
 			$offset = $datetime->format('P');
1606 1606
 		} else $offset = '+00:00';
1607
-		$filter_query = $this->getFilter($filters,true,true);
1607
+		$filter_query = $this->getFilter($filters, true, true);
1608 1608
 		if ($globalDBdriver == 'mysql') {
1609 1609
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1610 1610
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 		$date_array = array();
1626 1626
 		$temp_array = array();
1627 1627
         
1628
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1628
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1629 1629
 		{
1630 1630
 			$temp_array['date_name'] = $row['date_name'];
1631 1631
 			$temp_array['date_count'] = $row['date_count'];
@@ -1650,7 +1650,7 @@  discard block
 block discarded – undo
1650 1650
 			$datetime = new DateTime();
1651 1651
 			$offset = $datetime->format('P');
1652 1652
 		} else $offset = '+00:00';
1653
-		$filter_query = $this->getFilter($filters,true,true);
1653
+		$filter_query = $this->getFilter($filters, true, true);
1654 1654
 		if ($globalDBdriver == 'mysql') {
1655 1655
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1656 1656
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
 		$date_array = array();
1672 1672
 		$temp_array = array();
1673 1673
         
1674
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1674
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1675 1675
 		{
1676 1676
 			$temp_array['date_name'] = $row['date_name'];
1677 1677
 			$temp_array['date_count'] = $row['date_count'];
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 		$date_array = array();
1718 1718
 		$temp_array = array();
1719 1719
         
1720
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1720
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1721 1721
 		{
1722 1722
 			$temp_array['month_name'] = $row['month_name'];
1723 1723
 			$temp_array['year_name'] = $row['year_name'];
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 			$datetime = new DateTime();
1745 1745
 			$offset = $datetime->format('P');
1746 1746
 		} else $offset = '+00:00';
1747
-		$filter_query = $this->getFilter($filters,true,true);
1747
+		$filter_query = $this->getFilter($filters, true, true);
1748 1748
 		if ($globalDBdriver == 'mysql') {
1749 1749
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1750 1750
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
 		$date_array = array();
1766 1766
 		$temp_array = array();
1767 1767
         
1768
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1768
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1769 1769
 		{
1770 1770
 			$temp_array['year_name'] = $row['year_name'];
1771 1771
 			$temp_array['month_name'] = $row['month_name'];
@@ -1785,7 +1785,7 @@  discard block
 block discarded – undo
1785 1785
      * @param array $filters
1786 1786
      * @return array the hour list
1787 1787
      */
1788
-	public function countAllHours($orderby,$filters = array())
1788
+	public function countAllHours($orderby, $filters = array())
1789 1789
 	{
1790 1790
 		global $globalTimezone, $globalDBdriver;
1791 1791
 		if ($globalTimezone != '') {
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
 		$hour_array = array();
1834 1834
 		$temp_array = array();
1835 1835
         
1836
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1836
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1837 1837
 		{
1838 1838
 			$temp_array['hour_name'] = $row['hour_name'];
1839 1839
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1855,8 +1855,8 @@  discard block
 block discarded – undo
1855 1855
 	public function countAllHoursByDate($date, $filters = array())
1856 1856
 	{
1857 1857
 		global $globalTimezone, $globalDBdriver;
1858
-		$filter_query = $this->getFilter($filters,true,true);
1859
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1858
+		$filter_query = $this->getFilter($filters, true, true);
1859
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1860 1860
 		if ($globalTimezone != '') {
1861 1861
 			date_default_timezone_set($globalTimezone);
1862 1862
 			$datetime = new DateTime($date);
@@ -1864,12 +1864,12 @@  discard block
 block discarded – undo
1864 1864
 		} else $offset = '+00:00';
1865 1865
 
1866 1866
 		if ($globalDBdriver == 'mysql') {
1867
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1867
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1868 1868
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1869 1869
 								GROUP BY hour_name 
1870 1870
 								ORDER BY hour_name ASC";
1871 1871
 		} else {
1872
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1872
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1873 1873
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1874 1874
 								GROUP BY hour_name 
1875 1875
 								ORDER BY hour_name ASC";
@@ -1881,7 +1881,7 @@  discard block
 block discarded – undo
1881 1881
 		$hour_array = array();
1882 1882
 		$temp_array = array();
1883 1883
         
1884
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1884
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1885 1885
 		{
1886 1886
 			$temp_array['hour_name'] = $row['hour_name'];
1887 1887
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1903,8 +1903,8 @@  discard block
 block discarded – undo
1903 1903
 	public function countAllHoursByIdent($ident, $filters = array())
1904 1904
 	{
1905 1905
 		global $globalTimezone, $globalDBdriver;
1906
-		$filter_query = $this->getFilter($filters,true,true);
1907
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1906
+		$filter_query = $this->getFilter($filters, true, true);
1907
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1908 1908
 		if ($globalTimezone != '') {
1909 1909
 			date_default_timezone_set($globalTimezone);
1910 1910
 			$datetime = new DateTime();
@@ -1912,12 +1912,12 @@  discard block
 block discarded – undo
1912 1912
 		} else $offset = '+00:00';
1913 1913
 
1914 1914
 		if ($globalDBdriver == 'mysql') {
1915
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1915
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1916 1916
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1917 1917
 								GROUP BY hour_name 
1918 1918
 								ORDER BY hour_name ASC";
1919 1919
 		} else {
1920
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1920
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1921 1921
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1922 1922
 								GROUP BY hour_name 
1923 1923
 								ORDER BY hour_name ASC";
@@ -1925,12 +1925,12 @@  discard block
 block discarded – undo
1925 1925
       
1926 1926
 		
1927 1927
 		$sth = $this->db->prepare($query);
1928
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1928
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1929 1929
       
1930 1930
 		$hour_array = array();
1931 1931
 		$temp_array = array();
1932 1932
         
1933
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1933
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1934 1934
 		{
1935 1935
 			$temp_array['hour_name'] = $row['hour_name'];
1936 1936
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1950,11 +1950,11 @@  discard block
 block discarded – undo
1950 1950
      * @param array $filters
1951 1951
      * @return array the aircraft list
1952 1952
      */
1953
-	public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1953
+	public function countAllCaptainsByRaces($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
1954 1954
 	{
1955 1955
 		global $globalDBdriver;
1956
-		$filter_query = $this->getFilter($filters,true,true);
1957
-		$query  = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count 
1956
+		$filter_query = $this->getFilter($filters, true, true);
1957
+		$query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count 
1958 1958
 			FROM marine_output".$filter_query." race_id IS NOT NULL";
1959 1959
 		if ($olderthanmonths > 0) {
1960 1960
 			if ($globalDBdriver == 'mysql') {
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 		$marine_array = array();
1978 1978
 		$temp_array = array();
1979 1979
         
1980
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1980
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1981 1981
 		{
1982 1982
 			$temp_array['marine_race_id'] = $row['race_id'];
1983 1983
 			$temp_array['marine_race_name'] = $row['race_name'];
@@ -1995,33 +1995,33 @@  discard block
 block discarded – undo
1995 1995
      * @param string $month
1996 1996
      * @return Integer the number of vessels
1997 1997
      */
1998
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1998
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1999 1999
 	{
2000 2000
 		global $globalDBdriver;
2001 2001
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
2002
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
2002
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
2003 2003
 		$query_values = array();
2004 2004
 		$query = '';
2005 2005
 		if ($year != '') {
2006 2006
 			if ($globalDBdriver == 'mysql') {
2007 2007
 				$query .= " AND YEAR(marine_output.date) = :year";
2008
-				$query_values = array_merge($query_values,array(':year' => $year));
2008
+				$query_values = array_merge($query_values, array(':year' => $year));
2009 2009
 			} else {
2010 2010
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2011
-				$query_values = array_merge($query_values,array(':year' => $year));
2011
+				$query_values = array_merge($query_values, array(':year' => $year));
2012 2012
 			}
2013 2013
 		}
2014 2014
 		if ($month != '') {
2015 2015
 			if ($globalDBdriver == 'mysql') {
2016 2016
 				$query .= " AND MONTH(marine_output.date) = :month";
2017
-				$query_values = array_merge($query_values,array(':month' => $month));
2017
+				$query_values = array_merge($query_values, array(':month' => $month));
2018 2018
 			} else {
2019 2019
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2020
-				$query_values = array_merge($query_values,array(':month' => $month));
2020
+				$query_values = array_merge($query_values, array(':month' => $month));
2021 2021
 			}
2022 2022
 		}
2023 2023
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2024
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2024
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2025 2025
 		
2026 2026
 		$sth = $this->db->prepare($queryi);
2027 2027
 		$sth->execute($query_values);
@@ -2036,32 +2036,32 @@  discard block
 block discarded – undo
2036 2036
      * @param string $month
2037 2037
      * @return Integer the number of vessels
2038 2038
      */
2039
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
2039
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
2040 2040
 	{
2041 2041
 		global $globalDBdriver;
2042
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
2042
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
2043 2043
 		$query_values = array();
2044 2044
 		$query = '';
2045 2045
 		if ($year != '') {
2046 2046
 			if ($globalDBdriver == 'mysql') {
2047 2047
 				$query .= " AND YEAR(marine_output.date) = :year";
2048
-				$query_values = array_merge($query_values,array(':year' => $year));
2048
+				$query_values = array_merge($query_values, array(':year' => $year));
2049 2049
 			} else {
2050 2050
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2051
-				$query_values = array_merge($query_values,array(':year' => $year));
2051
+				$query_values = array_merge($query_values, array(':year' => $year));
2052 2052
 			}
2053 2053
 		}
2054 2054
 		if ($month != '') {
2055 2055
 			if ($globalDBdriver == 'mysql') {
2056 2056
 				$query .= " AND MONTH(marine_output.date) = :month";
2057
-				$query_values = array_merge($query_values,array(':month' => $month));
2057
+				$query_values = array_merge($query_values, array(':month' => $month));
2058 2058
 			} else {
2059 2059
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2060
-				$query_values = array_merge($query_values,array(':month' => $month));
2060
+				$query_values = array_merge($query_values, array(':month' => $month));
2061 2061
 			}
2062 2062
 		}
2063 2063
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2064
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2064
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2065 2065
 		
2066 2066
 		$sth = $this->db->prepare($queryi);
2067 2067
 		$sth->execute($query_values);
@@ -2076,32 +2076,32 @@  discard block
 block discarded – undo
2076 2076
      * @param string $month
2077 2077
      * @return Integer number of races
2078 2078
      */
2079
-	public function countOverallMarineRaces($filters = array(),$year = '',$month = '')
2079
+	public function countOverallMarineRaces($filters = array(), $year = '', $month = '')
2080 2080
 	{
2081 2081
 		global $globalDBdriver;
2082
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output";
2082
+		$queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output";
2083 2083
 		$query_values = array();
2084 2084
 		$query = '';
2085 2085
 		if ($year != '') {
2086 2086
 			if ($globalDBdriver == 'mysql') {
2087 2087
 				$query .= " AND YEAR(marine_output.date) = :year";
2088
-				$query_values = array_merge($query_values,array(':year' => $year));
2088
+				$query_values = array_merge($query_values, array(':year' => $year));
2089 2089
 			} else {
2090 2090
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2091
-				$query_values = array_merge($query_values,array(':year' => $year));
2091
+				$query_values = array_merge($query_values, array(':year' => $year));
2092 2092
 			}
2093 2093
 		}
2094 2094
 		if ($month != '') {
2095 2095
 			if ($globalDBdriver == 'mysql') {
2096 2096
 				$query .= " AND MONTH(marine_output.date) = :month";
2097
-				$query_values = array_merge($query_values,array(':month' => $month));
2097
+				$query_values = array_merge($query_values, array(':month' => $month));
2098 2098
 			} else {
2099 2099
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2100
-				$query_values = array_merge($query_values,array(':month' => $month));
2100
+				$query_values = array_merge($query_values, array(':month' => $month));
2101 2101
 			}
2102 2102
 		}
2103 2103
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2104
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2104
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2105 2105
 		
2106 2106
 		$sth = $this->db->prepare($queryi);
2107 2107
 		$sth->execute($query_values);
@@ -2116,32 +2116,32 @@  discard block
 block discarded – undo
2116 2116
      * @param string $month
2117 2117
      * @return Integer number of captain
2118 2118
      */
2119
-	public function countOverallMarineCaptains($filters = array(),$year = '',$month = '')
2119
+	public function countOverallMarineCaptains($filters = array(), $year = '', $month = '')
2120 2120
 	{
2121 2121
 		global $globalDBdriver;
2122
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output";
2122
+		$queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output";
2123 2123
 		$query_values = array();
2124 2124
 		$query = '';
2125 2125
 		if ($year != '') {
2126 2126
 			if ($globalDBdriver == 'mysql') {
2127 2127
 				$query .= " AND YEAR(marine_output.date) = :year";
2128
-				$query_values = array_merge($query_values,array(':year' => $year));
2128
+				$query_values = array_merge($query_values, array(':year' => $year));
2129 2129
 			} else {
2130 2130
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2131
-				$query_values = array_merge($query_values,array(':year' => $year));
2131
+				$query_values = array_merge($query_values, array(':year' => $year));
2132 2132
 			}
2133 2133
 		}
2134 2134
 		if ($month != '') {
2135 2135
 			if ($globalDBdriver == 'mysql') {
2136 2136
 				$query .= " AND MONTH(marine_output.date) = :month";
2137
-				$query_values = array_merge($query_values,array(':month' => $month));
2137
+				$query_values = array_merge($query_values, array(':month' => $month));
2138 2138
 			} else {
2139 2139
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2140
-				$query_values = array_merge($query_values,array(':month' => $month));
2140
+				$query_values = array_merge($query_values, array(':month' => $month));
2141 2141
 			}
2142 2142
 		}
2143 2143
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2144
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2144
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2145 2145
 		
2146 2146
 		$sth = $this->db->prepare($queryi);
2147 2147
 		$sth->execute($query_values);
@@ -2157,7 +2157,7 @@  discard block
 block discarded – undo
2157 2157
 	public function countAllHoursFromToday($filters = array())
2158 2158
 	{
2159 2159
 		global $globalTimezone, $globalDBdriver;
2160
-		$filter_query = $this->getFilter($filters,true,true);
2160
+		$filter_query = $this->getFilter($filters, true, true);
2161 2161
 		if ($globalTimezone != '') {
2162 2162
 			date_default_timezone_set($globalTimezone);
2163 2163
 			$datetime = new DateTime();
@@ -2165,12 +2165,12 @@  discard block
 block discarded – undo
2165 2165
 		} else $offset = '+00:00';
2166 2166
 
2167 2167
 		if ($globalDBdriver == 'mysql') {
2168
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
2168
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
2169 2169
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
2170 2170
 								GROUP BY hour_name 
2171 2171
 								ORDER BY hour_name ASC";
2172 2172
 		} else {
2173
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
2173
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
2174 2174
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
2175 2175
 								GROUP BY hour_name 
2176 2176
 								ORDER BY hour_name ASC";
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
 		$hour_array = array();
2183 2183
 		$temp_array = array();
2184 2184
         
2185
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2185
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2186 2186
 		{
2187 2187
 			$temp_array['hour_name'] = $row['hour_name'];
2188 2188
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -2201,9 +2201,9 @@  discard block
 block discarded – undo
2201 2201
      */
2202 2202
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
2203 2203
 	{
2204
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
2204
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
2205 2205
 
2206
-		$query  = "SELECT marine_output.marine_id
2206
+		$query = "SELECT marine_output.marine_id
2207 2207
 				FROM marine_output 
2208 2208
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
2209 2209
         
@@ -2211,7 +2211,7 @@  discard block
 block discarded – undo
2211 2211
 		$sth = $this->db->prepare($query);
2212 2212
 		$sth->execute();
2213 2213
 
2214
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2214
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2215 2215
 		{
2216 2216
 			return $row['marine_id'];
2217 2217
 		}
@@ -2236,23 +2236,23 @@  discard block
 block discarded – undo
2236 2236
 		}
2237 2237
 		
2238 2238
 		$current_date = date("Y-m-d H:i:s");
2239
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
2239
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
2240 2240
 		
2241 2241
 		$diff = abs(strtotime($current_date) - strtotime($date));
2242 2242
 
2243
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
2243
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
2244 2244
 		$years = $time_array['years'];
2245 2245
 		
2246
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
2246
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
2247 2247
 		$months = $time_array['months'];
2248 2248
 		
2249
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
2249
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
2250 2250
 		$days = $time_array['days'];
2251
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
2251
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
2252 2252
 		$hours = $time_array['hours'];
2253
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
2253
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
2254 2254
 		$minutes = $time_array['minutes'];
2255
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
2255
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
2256 2256
 		
2257 2257
 		return $time_array;
2258 2258
 	}
@@ -2275,63 +2275,63 @@  discard block
 block discarded – undo
2275 2275
 			$temp_array['direction_degree'] = $direction;
2276 2276
 			$temp_array['direction_shortname'] = "N";
2277 2277
 			$temp_array['direction_fullname'] = "North";
2278
-		} elseif ($direction >= 22.5 && $direction < 45){
2278
+		} elseif ($direction >= 22.5 && $direction < 45) {
2279 2279
 			$temp_array['direction_degree'] = $direction;
2280 2280
 			$temp_array['direction_shortname'] = "NNE";
2281 2281
 			$temp_array['direction_fullname'] = "North-Northeast";
2282
-		} elseif ($direction >= 45 && $direction < 67.5){
2282
+		} elseif ($direction >= 45 && $direction < 67.5) {
2283 2283
 			$temp_array['direction_degree'] = $direction;
2284 2284
 			$temp_array['direction_shortname'] = "NE";
2285 2285
 			$temp_array['direction_fullname'] = "Northeast";
2286
-		} elseif ($direction >= 67.5 && $direction < 90){
2286
+		} elseif ($direction >= 67.5 && $direction < 90) {
2287 2287
 			$temp_array['direction_degree'] = $direction;
2288 2288
 			$temp_array['direction_shortname'] = "ENE";
2289 2289
 			$temp_array['direction_fullname'] = "East-Northeast";
2290
-		} elseif ($direction >= 90 && $direction < 112.5){
2290
+		} elseif ($direction >= 90 && $direction < 112.5) {
2291 2291
 			$temp_array['direction_degree'] = $direction;
2292 2292
 			$temp_array['direction_shortname'] = "E";
2293 2293
 			$temp_array['direction_fullname'] = "East";
2294
-		} elseif ($direction >= 112.5 && $direction < 135){
2294
+		} elseif ($direction >= 112.5 && $direction < 135) {
2295 2295
 			$temp_array['direction_degree'] = $direction;
2296 2296
 			$temp_array['direction_shortname'] = "ESE";
2297 2297
 			$temp_array['direction_fullname'] = "East-Southeast";
2298
-		} elseif ($direction >= 135 && $direction < 157.5){
2298
+		} elseif ($direction >= 135 && $direction < 157.5) {
2299 2299
 			$temp_array['direction_degree'] = $direction;
2300 2300
 			$temp_array['direction_shortname'] = "SE";
2301 2301
 			$temp_array['direction_fullname'] = "Southeast";
2302
-		} elseif ($direction >= 157.5 && $direction < 180){
2302
+		} elseif ($direction >= 157.5 && $direction < 180) {
2303 2303
 			$temp_array['direction_degree'] = $direction;
2304 2304
 			$temp_array['direction_shortname'] = "SSE";
2305 2305
 			$temp_array['direction_fullname'] = "South-Southeast";
2306
-		} elseif ($direction >= 180 && $direction < 202.5){
2306
+		} elseif ($direction >= 180 && $direction < 202.5) {
2307 2307
 			$temp_array['direction_degree'] = $direction;
2308 2308
 			$temp_array['direction_shortname'] = "S";
2309 2309
 			$temp_array['direction_fullname'] = "South";
2310
-		} elseif ($direction >= 202.5 && $direction < 225){
2310
+		} elseif ($direction >= 202.5 && $direction < 225) {
2311 2311
 			$temp_array['direction_degree'] = $direction;
2312 2312
 			$temp_array['direction_shortname'] = "SSW";
2313 2313
 			$temp_array['direction_fullname'] = "South-Southwest";
2314
-		} elseif ($direction >= 225 && $direction < 247.5){
2314
+		} elseif ($direction >= 225 && $direction < 247.5) {
2315 2315
 			$temp_array['direction_degree'] = $direction;
2316 2316
 			$temp_array['direction_shortname'] = "SW";
2317 2317
 			$temp_array['direction_fullname'] = "Southwest";
2318
-		} elseif ($direction >= 247.5 && $direction < 270){
2318
+		} elseif ($direction >= 247.5 && $direction < 270) {
2319 2319
 			$temp_array['direction_degree'] = $direction;
2320 2320
 			$temp_array['direction_shortname'] = "WSW";
2321 2321
 			$temp_array['direction_fullname'] = "West-Southwest";
2322
-		} elseif ($direction >= 270 && $direction < 292.5){
2322
+		} elseif ($direction >= 270 && $direction < 292.5) {
2323 2323
 			$temp_array['direction_degree'] = $direction;
2324 2324
 			$temp_array['direction_shortname'] = "W";
2325 2325
 			$temp_array['direction_fullname'] = "West";
2326
-		} elseif ($direction >= 292.5 && $direction < 315){
2326
+		} elseif ($direction >= 292.5 && $direction < 315) {
2327 2327
 			$temp_array['direction_degree'] = $direction;
2328 2328
 			$temp_array['direction_shortname'] = "WNW";
2329 2329
 			$temp_array['direction_fullname'] = "West-Northwest";
2330
-		} elseif ($direction >= 315 && $direction < 337.5){
2330
+		} elseif ($direction >= 315 && $direction < 337.5) {
2331 2331
 			$temp_array['direction_degree'] = $direction;
2332 2332
 			$temp_array['direction_shortname'] = "NW";
2333 2333
 			$temp_array['direction_fullname'] = "Northwest";
2334
-		} elseif ($direction >= 337.5 && $direction < 360){
2334
+		} elseif ($direction >= 337.5 && $direction < 360) {
2335 2335
 			$temp_array['direction_degree'] = $direction;
2336 2336
 			$temp_array['direction_shortname'] = "NNW";
2337 2337
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -2348,11 +2348,11 @@  discard block
 block discarded – undo
2348 2348
 	* @param Float $longitude longitute of the flight
2349 2349
 	* @return String the countries
2350 2350
 	*/
2351
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
2351
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
2352 2352
 	{
2353 2353
 		global $globalDebug;
2354
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2355
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2354
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2355
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2356 2356
 	
2357 2357
 		$Connection = new Connection($this->db);
2358 2358
 		if (!$Connection->tableExists('countries')) return '';
@@ -2392,7 +2392,7 @@  discard block
 block discarded – undo
2392 2392
 	public function getCountryFromISO2($iso2)
2393 2393
 	{
2394 2394
 		global $globalDebug;
2395
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
2395
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
2396 2396
 	
2397 2397
 		$Connection = new Connection($this->db);
2398 2398
 		if (!$Connection->tableExists('countries')) return '';
@@ -2440,7 +2440,7 @@  discard block
 block discarded – undo
2440 2440
 		
2441 2441
 		$bitly_data = json_decode($bitly_data);
2442 2442
 		$bitly_url = '';
2443
-		if ($bitly_data->status_txt = "OK"){
2443
+		if ($bitly_data->status_txt = "OK") {
2444 2444
 			$bitly_url = $bitly_data->data->url;
2445 2445
 		}
2446 2446
 
@@ -2460,11 +2460,11 @@  discard block
 block discarded – undo
2460 2460
      * @param string $day
2461 2461
      * @return array the vessel type list
2462 2462
      */
2463
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
2463
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
2464 2464
 	{
2465 2465
 		global $globalDBdriver;
2466
-		$filter_query = $this->getFilter($filters,true,true);
2467
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
2466
+		$filter_query = $this->getFilter($filters, true, true);
2467
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
2468 2468
 		    FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL";
2469 2469
 		if ($olderthanmonths > 0) {
2470 2470
 			if ($globalDBdriver == 'mysql') {
@@ -2484,28 +2484,28 @@  discard block
 block discarded – undo
2484 2484
 		if ($year != '') {
2485 2485
 			if ($globalDBdriver == 'mysql') {
2486 2486
 				$query .= " AND YEAR(marine_output.date) = :year";
2487
-				$query_values = array_merge($query_values,array(':year' => $year));
2487
+				$query_values = array_merge($query_values, array(':year' => $year));
2488 2488
 			} else {
2489 2489
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2490
-				$query_values = array_merge($query_values,array(':year' => $year));
2490
+				$query_values = array_merge($query_values, array(':year' => $year));
2491 2491
 			}
2492 2492
 		}
2493 2493
 		if ($month != '') {
2494 2494
 			if ($globalDBdriver == 'mysql') {
2495 2495
 				$query .= " AND MONTH(marine_output.date) = :month";
2496
-				$query_values = array_merge($query_values,array(':month' => $month));
2496
+				$query_values = array_merge($query_values, array(':month' => $month));
2497 2497
 			} else {
2498 2498
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2499
-				$query_values = array_merge($query_values,array(':month' => $month));
2499
+				$query_values = array_merge($query_values, array(':month' => $month));
2500 2500
 			}
2501 2501
 		}
2502 2502
 		if ($day != '') {
2503 2503
 			if ($globalDBdriver == 'mysql') {
2504 2504
 				$query .= " AND DAY(marine_output.date) = :day";
2505
-				$query_values = array_merge($query_values,array(':day' => $day));
2505
+				$query_values = array_merge($query_values, array(':day' => $day));
2506 2506
 			} else {
2507 2507
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
2508
-				$query_values = array_merge($query_values,array(':day' => $day));
2508
+				$query_values = array_merge($query_values, array(':day' => $day));
2509 2509
 			}
2510 2510
 		}
2511 2511
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
@@ -2514,9 +2514,9 @@  discard block
 block discarded – undo
2514 2514
 		$sth->execute($query_values);
2515 2515
 		$marine_array = array();
2516 2516
 		$temp_array = array();
2517
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2517
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2518 2518
 		{
2519
-			$temp_array['marine_type'] = html_entity_decode($row['marine_type'],ENT_QUOTES);
2519
+			$temp_array['marine_type'] = html_entity_decode($row['marine_type'], ENT_QUOTES);
2520 2520
 			$temp_array['marine_type_id'] = $row['marine_type_id'];
2521 2521
 			$temp_array['marine_type_count'] = $row['marine_type_count'];
2522 2522
 			$marine_array[] = $temp_array;
@@ -2545,13 +2545,13 @@  discard block
 block discarded – undo
2545 2545
      * @param array $filters
2546 2546
      * @return array the tracker information
2547 2547
      */
2548
-	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$filters = array())
2548
+	public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $filters = array())
2549 2549
 	{
2550 2550
 		global $globalTimezone, $globalDBdriver;
2551 2551
 		date_default_timezone_set('UTC');
2552 2552
 		$query_values = array();
2553 2553
 		$additional_query = '';
2554
-		$filter_query = $this->getFilter($filters,true,true);
2554
+		$filter_query = $this->getFilter($filters, true, true);
2555 2555
 		if ($q != "")
2556 2556
 		{
2557 2557
 			if (!is_string($q))
@@ -2559,8 +2559,8 @@  discard block
 block discarded – undo
2559 2559
 				return array();
2560 2560
 			} else {
2561 2561
 				$q_array = explode(" ", $q);
2562
-				foreach ($q_array as $q_item){
2563
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
2562
+				foreach ($q_array as $q_item) {
2563
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
2564 2564
 					$additional_query .= " AND (";
2565 2565
 					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2566 2566
 					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
@@ -2576,86 +2576,86 @@  discard block
 block discarded – undo
2576 2576
 		}
2577 2577
 		if ($callsign != "")
2578 2578
 		{
2579
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2579
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2580 2580
 			if (!is_string($callsign))
2581 2581
 			{
2582 2582
 				return array();
2583 2583
 			} else {
2584 2584
 				$additional_query .= " AND marine_output.ident = :callsign";
2585
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
2585
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
2586 2586
 			}
2587 2587
 		}
2588 2588
 		if ($mmsi != "")
2589 2589
 		{
2590
-			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
2590
+			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
2591 2591
 			if (!is_numeric($mmsi))
2592 2592
 			{
2593 2593
 				return array();
2594 2594
 			} else {
2595 2595
 				$additional_query .= " AND marine_output.mmsi = :mmsi";
2596
-				$query_values = array_merge($query_values,array(':mmsi' => $mmsi));
2596
+				$query_values = array_merge($query_values, array(':mmsi' => $mmsi));
2597 2597
 			}
2598 2598
 		}
2599 2599
 		if ($imo != "")
2600 2600
 		{
2601
-			$imo = filter_var($imo,FILTER_SANITIZE_STRING);
2601
+			$imo = filter_var($imo, FILTER_SANITIZE_STRING);
2602 2602
 			if (!is_numeric($imo))
2603 2603
 			{
2604 2604
 				return array();
2605 2605
 			} else {
2606 2606
 				$additional_query .= " AND marine_output.imo = :imo";
2607
-				$query_values = array_merge($query_values,array(':imo' => $imo));
2607
+				$query_values = array_merge($query_values, array(':imo' => $imo));
2608 2608
 			}
2609 2609
 		}
2610 2610
 		if ($captain_id != "")
2611 2611
 		{
2612
-			$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
2612
+			$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
2613 2613
 			if (!is_numeric($captain_id))
2614 2614
 			{
2615 2615
 				return array();
2616 2616
 			} else {
2617 2617
 				$additional_query .= " AND marine_output.captain_id = :captain_id";
2618
-				$query_values = array_merge($query_values,array(':captain_id' => $captain_id));
2618
+				$query_values = array_merge($query_values, array(':captain_id' => $captain_id));
2619 2619
 			}
2620 2620
 		}
2621 2621
 		if ($race_id != "")
2622 2622
 		{
2623
-			$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
2623
+			$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
2624 2624
 			if (!is_numeric($race_id))
2625 2625
 			{
2626 2626
 				return array();
2627 2627
 			} else {
2628 2628
 				$additional_query .= " AND marine_output.race_id = :race_id";
2629
-				$query_values = array_merge($query_values,array(':race_id' => $race_id));
2629
+				$query_values = array_merge($query_values, array(':race_id' => $race_id));
2630 2630
 			}
2631 2631
 		}
2632 2632
 		if ($captain_name != "")
2633 2633
 		{
2634
-			$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
2634
+			$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
2635 2635
 			if (!is_string($captain_name))
2636 2636
 			{
2637 2637
 				return array();
2638 2638
 			} else {
2639 2639
 				$additional_query .= " AND marine_output.captain_name = :captain_name";
2640
-				$query_values = array_merge($query_values,array(':captain_name' => $captain_name));
2640
+				$query_values = array_merge($query_values, array(':captain_name' => $captain_name));
2641 2641
 			}
2642 2642
 		}
2643 2643
 		if ($race_name != "")
2644 2644
 		{
2645
-			$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2645
+			$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2646 2646
 			if (!is_numeric($race_name))
2647 2647
 			{
2648 2648
 				return array();
2649 2649
 			} else {
2650 2650
 				$additional_query .= " AND marine_output.race_name = :race_name";
2651
-				$query_values = array_merge($query_values,array(':race_name' => $race_name));
2651
+				$query_values = array_merge($query_values, array(':race_name' => $race_name));
2652 2652
 			}
2653 2653
 		}
2654 2654
 		if ($date_posted != "")
2655 2655
 		{
2656 2656
 			$date_array = explode(",", $date_posted);
2657
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
2658
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
2657
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
2658
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
2659 2659
 			if ($globalTimezone != '') {
2660 2660
 				date_default_timezone_set($globalTimezone);
2661 2661
 				$datetime = new DateTime();
@@ -2682,8 +2682,8 @@  discard block
 block discarded – undo
2682 2682
 		if ($limit != "")
2683 2683
 		{
2684 2684
 			$limit_array = explode(",", $limit);
2685
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
2686
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
2685
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
2686
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
2687 2687
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2688 2688
 			{
2689 2689
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -2701,22 +2701,22 @@  discard block
 block discarded – undo
2701 2701
 			}
2702 2702
 		}
2703 2703
 		if ($origLat != "" && $origLon != "" && $dist != "") {
2704
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
2704
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
2705 2705
 			if ($globalDBdriver == 'mysql') {
2706
-				$query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
2706
+				$query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
2707 2707
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
2708 2708
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
2709 2709
 			} else {
2710
-				$query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
2710
+				$query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
2711 2711
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
2712 2712
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query;
2713 2713
 			}
2714 2714
 		} else {
2715
-			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2715
+			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2716 2716
 			    ".$additional_query."
2717 2717
 			    ".$orderby_query;
2718 2718
 		}
2719
-		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query);
2719
+		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query);
2720 2720
 		return $marine_array;
2721 2721
 	}
2722 2722
 
@@ -2728,12 +2728,12 @@  discard block
 block discarded – undo
2728 2728
      */
2729 2729
 	public function checkId($id)
2730 2730
 	{
2731
-		$query  = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
2731
+		$query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
2732 2732
 		$query_data = array(':id' => $id);
2733 2733
 		$sth = $this->db->prepare($query);
2734 2734
 		$sth->execute($query_data);
2735
-		$ident_result='';
2736
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2735
+		$ident_result = '';
2736
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2737 2737
 		{
2738 2738
 			$ident_result = $row['fammarine_id'];
2739 2739
 		}
@@ -2748,7 +2748,7 @@  discard block
 block discarded – undo
2748 2748
      */
2749 2749
 	public function getRaceByName($race_name)
2750 2750
 	{
2751
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2751
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2752 2752
 		$query  = "SELECT * FROM marine_race WHERE race_name = :race_name LIMIT 1";
2753 2753
 		$sth = $this->db->prepare($query);
2754 2754
 		$sth->execute(array(':race_name' => $race_name));
@@ -2765,7 +2765,7 @@  discard block
 block discarded – undo
2765 2765
      */
2766 2766
 	public function getRace($race_id)
2767 2767
 	{
2768
-		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
2768
+		$race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT);
2769 2769
 		$query  = "SELECT * FROM marine_race WHERE race_id = :race_id LIMIT 1";
2770 2770
 		$sth = $this->db->prepare($query);
2771 2771
 		$sth->execute(array(':race_id' => $race_id));
@@ -2783,24 +2783,24 @@  discard block
 block discarded – undo
2783 2783
      * @param $race_startdate
2784 2784
      * @param $race_markers
2785 2785
      */
2786
-	public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers)
2786
+	public function addRace($race_id, $race_name, $race_creator, $race_desc, $race_startdate, $race_markers)
2787 2787
 	{
2788
-		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
2788
+		$race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT);
2789 2789
 		if ($race_id != '') {
2790
-			$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2791
-			$race_creator = filter_var($race_creator,FILTER_SANITIZE_STRING);
2792
-			$race_desc = filter_var($race_desc,FILTER_SANITIZE_STRING);
2793
-			$race_startdate = filter_var($race_startdate,FILTER_SANITIZE_STRING);
2790
+			$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2791
+			$race_creator = filter_var($race_creator, FILTER_SANITIZE_STRING);
2792
+			$race_desc = filter_var($race_desc, FILTER_SANITIZE_STRING);
2793
+			$race_startdate = filter_var($race_startdate, FILTER_SANITIZE_STRING);
2794 2794
 			//$race_markers = filter_var($race_markers,FILTER_SANITIZE_STRING);
2795 2795
 			$allrace = $this->getRace($race_id);
2796 2796
 			if (empty($allrace)) {
2797 2797
 				$query  = "INSERT INTO marine_race (race_id,race_name,race_creator,race_desc,race_startdate,race_markers) VALUES (:race_id,:race_name,:race_creator,:race_desc,:race_startdate,:race_markers)";
2798 2798
 				$sth = $this->db->prepare($query);
2799
-				$sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_creator' => $race_creator,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers));
2799
+				$sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_creator' => $race_creator, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers));
2800 2800
 			} elseif ($race_id != '') {
2801
-				$query  = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id";
2801
+				$query = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id";
2802 2802
 				$sth = $this->db->prepare($query);
2803
-				$sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers));
2803
+				$sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers));
2804 2804
 			}
2805 2805
 		}
2806 2806
 	}
@@ -2809,7 +2809,7 @@  discard block
 block discarded – undo
2809 2809
 
2810 2810
 	public function getOrderBy()
2811 2811
 	{
2812
-		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
2812
+		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
2813 2813
 		return $orderby;
2814 2814
 	}
2815 2815
     
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
      * @param String $source source of data
38 38
      * @return string
39 39
      */
40
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
40
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
41 41
 		date_default_timezone_set('UTC');
42
-		$date = date("Y-m-d H:i:s",time());
42
+		$date = date("Y-m-d H:i:s", time());
43 43
 		//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
44 44
 		//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
45 45
 		$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -47,69 +47,69 @@  discard block
 block discarded – undo
47 47
 		 try {
48 48
 			$sth = $this->db->prepare($query);
49 49
 			$sth->execute($query_values);
50
-		} catch(PDOException $e) {
50
+		} catch (PDOException $e) {
51 51
 			return "error : ".$e->getMessage();
52 52
 		}
53 53
 		if ($sth->fetchColumn() > 0) {
54 54
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
55 55
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
56
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
56
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
57 57
 			} elseif ($arrival_airport_time == '') {
58 58
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
59
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
59
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
60 60
 			} elseif ($departure_airport_time == '') {
61 61
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
62
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
62
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
63 63
 			} else {
64 64
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
65 65
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
66
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
66
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
67 67
 			}
68 68
 			try {
69 69
 				$sth = $this->db->prepare($query);
70 70
 				$sth->execute($query_values);
71
-			} catch(PDOException $e) {
71
+			} catch (PDOException $e) {
72 72
 				return "error : ".$e->getMessage();
73 73
 			}
74 74
 			if ($sth->fetchColumn() == 0) {
75 75
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
76 76
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
77 77
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
78
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
78
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
79 79
 				} elseif ($arrival_airport_time == '') {
80 80
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
81
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
81
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
82 82
 				} elseif ($departure_airport_time == '') {
83 83
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
84
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
84
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
85 85
 				} else {
86 86
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
87
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
87
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
88 88
 				}
89 89
 				try {
90 90
 					$sth = $this->db->prepare($query);
91 91
 					$sth->execute($query_values);
92
-				} catch(PDOException $e) {
92
+				} catch (PDOException $e) {
93 93
 					return "error : ".$e->getMessage();
94 94
 				}
95 95
 			} else {
96 96
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
97 97
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
98
-				$query_values = array(':ident' => $ident,':date' => $date);
98
+				$query_values = array(':ident' => $ident, ':date' => $date);
99 99
 				try {
100 100
 					$sth = $this->db->prepare($query);
101 101
 					$sth->execute($query_values);
102
-				} catch(PDOException $e) {
102
+				} catch (PDOException $e) {
103 103
 					return "error : ".$e->getMessage();
104 104
 				}
105 105
 			}
106 106
 		} else {
107 107
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
108
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
108
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
109 109
 			 try {
110 110
 				$sth = $this->db->prepare($query);
111 111
 				$sth->execute($query_values);
112
-			} catch(PDOException $e) {
112
+			} catch (PDOException $e) {
113 113
 				return "error : ".$e->getMessage();
114 114
 			}
115 115
 		}
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 	*/
124 124
 	public function getSchedule($ident) {
125 125
 		$Translation = new Translation($this->db);
126
-		$operator = $Translation->checkTranslation($ident,false);
126
+		$operator = $Translation->checkTranslation($ident, false);
127 127
 		if ($ident != $operator) {
128 128
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
129
-			$query_values = array(':ident' => $ident,'operator' => $operator);
129
+			$query_values = array(':ident' => $ident, 'operator' => $operator);
130 130
 		} else {
131 131
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
132 132
 			$query_values = array(':ident' => $ident);
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		 try {
135 135
 			$sth = $this->db->prepare($query);
136 136
 			$sth->execute($query_values);
137
-		} catch(PDOException $e) {
137
+		} catch (PDOException $e) {
138 138
 			return "error : ".$e->getMessage();
139 139
 		}
140 140
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		 try {
164 164
 			$sth = $this->db->prepare($query);
165 165
 			$sth->execute($query_values);
166
-		} catch(PDOException $e) {
166
+		} catch (PDOException $e) {
167 167
 			return "error : ".$e->getMessage();
168 168
 		}
169 169
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
      * @param String $carrier IATA code
179 179
      * @return array departure and arrival airports and time
180 180
      */
181
-	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
181
+	public function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
182 182
 		$Common = new Common();
183 183
 		$check_date = new Datetime($date);
184
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
185
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
184
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
185
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
186 186
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
187 187
 		$json = $Common->getData($url);
188 188
 		var_dump($json);
189 189
 		$parsed_json = json_decode($json);
190
-		if (property_exists($parsed_json,'errors') === false) {
190
+		if (property_exists($parsed_json, 'errors') === false) {
191 191
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
192 192
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
193 193
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
198 198
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
199 199
 
200
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
200
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
201 201
 			$DepartureAirportIata = $originiata[1];
202
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
202
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
203 203
 			$ArrivalAirportIata = $destinationiata[1];
204 204
 
205 205
 			/*
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
209 209
 			*/
210 210
 		
211
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
211
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
212 212
 		} else return array();
213 213
 	}
214 214
 
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 		$Common = new Common();
224 224
 		date_default_timezone_set($globalTimezone);
225 225
 		$check_date = new Datetime($date);
226
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
227
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
226
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
227
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
228 228
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
229 229
 		$json = $Common->getData($url);
230 230
 		$parsed_json = json_decode($json);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
237 237
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
238 238
 
239
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
239
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
240 240
 		} else return array();
241 241
 	}
242 242
 
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
      */
248 248
 	private function getRyanair($callsign) {
249 249
 		$Common = new Common();
250
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
251
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
250
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
251
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
252 252
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
253 253
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
254
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
255
-		$json = $Common->getData($url,'post',$post,$headers);
254
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
255
+		$json = $Common->getData($url, 'post', $post, $headers);
256 256
 		$parsed_json = json_decode($json);
257 257
 		if (isset($parsed_json->{'flightInfo'})) {
258 258
 			$flights = $parsed_json->{'flightInfo'};
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
262 262
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
263 263
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
264
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
264
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
265 265
 			} else return array();
266 266
 		} else return array();
267 267
 	}
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 	*/
274 274
 	private function getSwiss($callsign) {
275 275
 		$Common = new Common();
276
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
277
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
276
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
277
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
278 278
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
279 279
 		$json = $Common->getData($url);
280 280
 		$parsed_json = json_decode($json);
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
289 289
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
290 290
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
291
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
292
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
291
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
292
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
293 293
 				}
294 294
 			}
295 295
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
296
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
296
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
297 297
 			} else return array();
298 298
 		} else return array();
299 299
 	}
@@ -308,21 +308,21 @@  discard block
 block discarded – undo
308 308
 		global $globalBritishAirwaysKey;
309 309
 		$Common = new Common();
310 310
 		$check_date = new Datetime($date);
311
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
312
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
311
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
312
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
313 313
 		if ($globalBritishAirwaysKey == '') return array();
314 314
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
315 315
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
316
-		$json = $Common->getData($url,'get','',$headers);
316
+		$json = $Common->getData($url, 'get', '', $headers);
317 317
 		if ($json == '') return array();
318 318
 		$parsed_json = json_decode($json);
319 319
 		$flights = $parsed_json->{'FlightsResponse'};
320 320
 		if (count($flights) > 0) {
321 321
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
322 322
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
323
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
324
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
325
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
323
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
324
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
325
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
326 326
 		} else return array();
327 327
 	}
328 328
 
@@ -336,27 +336,27 @@  discard block
 block discarded – undo
336 336
 		global $globalLufthansaKey;
337 337
 		$Common = new Common();
338 338
 		$check_date = new Datetime($date);
339
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
340
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
339
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
340
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
341 341
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
342 342
 		$url = "https://api.lufthansa.com/v1/oauth/token";
343
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
344
-		$data = $Common->getData($url,'post',$post);
343
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
344
+		$data = $Common->getData($url, 'post', $post);
345 345
 		$parsed_data = json_decode($data);
346 346
 		if (!isset($parsed_data->{'access_token'})) return array();
347 347
 		$token = $parsed_data->{'access_token'};
348 348
 		
349 349
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
350
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
351
-		$json = $Common->getData($url,'get','',$headers);
350
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
351
+		$json = $Common->getData($url, 'get', '', $headers);
352 352
 		if ($json == '') return array();
353 353
 		$parsed_json = json_decode($json);
354 354
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
355 355
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
356
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
356
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357 357
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
358
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
359
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
358
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
359
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
360 360
 		} else return array();
361 361
 	}
362 362
 
@@ -370,23 +370,23 @@  discard block
 block discarded – undo
370 370
 		global $globalTransaviaKey;
371 371
 		$Common = new Common();
372 372
 		$check_date = new Datetime($date);
373
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
374
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
373
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
374
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
375 375
 		if ($globalTransaviaKey == '') return array();
376 376
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
377 377
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
378 378
 		$headers = array('apikey: '.$globalTransaviaKey);
379
-		$json = $Common->getData($url,'get','',$headers);
379
+		$json = $Common->getData($url, 'get', '', $headers);
380 380
 		//echo 'result : '.$json;
381 381
 		if ($json == '') return array();
382 382
 		$parsed_json = json_decode($json);
383 383
 		
384 384
 		if (isset($parsed_json->{'data'}[0])) {
385 385
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
386
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
386
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
387 387
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
388
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
389
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
388
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
389
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
390 390
 		} else return array();
391 391
 	}
392 392
 
@@ -397,14 +397,14 @@  discard block
 block discarded – undo
397 397
 	*/
398 398
 	public function getTunisair($callsign) {
399 399
 		$Common = new Common();
400
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
401
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
400
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
401
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
402 402
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
403 403
 		$data = $Common->getData($url);
404 404
 		$table = $Common->table2array($data);
405 405
 		foreach ($table as $flight) {
406
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
407
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
406
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
407
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
408 408
 			}
409 409
 		}
410 410
 		return array();
@@ -416,21 +416,21 @@  discard block
 block discarded – undo
416 416
      * @param string $date
417 417
      * @return array Flight departure and arrival airports and time
418 418
      */
419
-	public function getVueling($callsign,$date = 'NOW') {
419
+	public function getVueling($callsign, $date = 'NOW') {
420 420
 		$Common = new Common();
421 421
 		$check_date = new Datetime($date);
422
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
424
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
422
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
423
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
424
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
425 425
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
426 426
 		$data = $Common->getData($url);
427
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
427
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
428 428
 		if ($data != '') {
429
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
430
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
431
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
432
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
433
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
429
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
430
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
431
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
432
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
433
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
434 434
 			else return array();
435 435
 		}
436 436
 		return array();
@@ -444,27 +444,27 @@  discard block
 block discarded – undo
444 444
 	*/
445 445
 	public function getIberia($callsign, $date = 'NOW') {
446 446
 		$Common = new Common();
447
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
447
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
448 448
 		$check_date = new Datetime($date);
449
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
449
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
450 450
 		$url = "https://www.iberia.com/web/flightDetail.do";
451
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
452
-		$data = $Common->getData($url,'post',$post);
451
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
452
+		$data = $Common->getData($url, 'post', $post);
453 453
 		if ($data != '') {
454 454
 			$table = $Common->table2array($data);
455 455
 			//print_r($table);
456 456
 			if (count($table) > 0) {
457 457
 				$flight = $table;
458
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
459
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
458
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
459
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
460 460
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
461 461
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
462
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
463
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
462
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
463
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
464 464
 				if ($arrivalTime == 'Hora estimada de llegada') {
465
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
466
-				} else $arrivalTime = substr($arrivalTime,0,5);
467
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
465
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
466
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
467
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
468 468
 			}
469 469
 		}
470 470
 		return array();
@@ -478,11 +478,11 @@  discard block
 block discarded – undo
478 478
      * @return array Flight departure and arrival airports and time
479 479
      */
480 480
 
481
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
481
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
482 482
 		$Common = new Common();
483
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
483
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
484 484
 		$check_date = new Datetime($date);
485
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
485
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
486 486
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
487 487
 		$data = $Common->getData($url);
488 488
 		if ($data != '') {
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 				$flight = $table;
492 492
 				//print_r($table);
493 493
 				if (isset($flight[25]) && isset($flight[29])) {
494
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
495
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
494
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
495
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
496 496
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
497 497
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
498
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
499
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
500
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
498
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
499
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
500
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
501 501
 				} else return array();
502 502
 			}
503 503
 			
@@ -515,10 +515,10 @@  discard block
 block discarded – undo
515 515
 	*/
516 516
 	private function getAlitalia($callsign, $date = 'NOW') {
517 517
 		$Common = new Common();
518
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
518
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
519 519
 		$check_date = new Datetime($date);
520
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
521
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
520
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
521
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
522 522
 		$data = $Common->getData($url);
523 523
 		if ($data != '') {
524 524
 			$table = $Common->text2array($data);
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 			$ArrivalAirportIata = '';
527 527
 			$departureTime = $table[4];
528 528
 			$arrivalTime = $table[5];
529
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
529
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
530 530
 		}
531 531
 		return array();
532 532
 	}
@@ -539,21 +539,21 @@  discard block
 block discarded – undo
539 539
 	*/
540 540
 	private function getBrussels($callsign, $date = 'NOW') {
541 541
 		$Common = new Common();
542
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
542
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
543 543
 		$check_date = new Datetime($date);
544
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
544
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
545 545
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
546
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
546
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
547 547
 		$data = $Common->getData($url);
548 548
 		if ($data != '') {
549 549
 		    //echo $data;
550
-		    $parsed_json = json_decode($data,true);
550
+		    $parsed_json = json_decode($data, true);
551 551
 		    if (isset($parsed_json[0]['FromAirportCode'])) {
552 552
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
553 553
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
554
-			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
555
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
556
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
554
+			$departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate']));
555
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate']));
556
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
557 557
 		    }
558 558
 		}
559 559
 		return array();
@@ -631,21 +631,21 @@  discard block
 block discarded – undo
631 631
 	*/
632 632
 	private function getFlyTap($callsign) {
633 633
 		$Common = new Common();
634
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
635
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
634
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
635
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
636 636
 		//$check_date = new Datetime($date);
637
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
638
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
639
-		$data = $Common->getData($url,'post',$post);
637
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
638
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
639
+		$data = $Common->getData($url, 'post', $post);
640 640
 		if ($data != '') {
641 641
 			$table = $Common->table2array($data);
642
-			$departureTime = trim(substr($table[15][0],0,5));
643
-			$arrivalTime = trim(substr($table[35][0],0,5));
644
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
645
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
642
+			$departureTime = trim(substr($table[15][0], 0, 5));
643
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
644
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
645
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
646 646
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
647 647
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
648
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
648
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
649 649
 		}
650 650
 		return array();
651 651
 	}
@@ -667,10 +667,10 @@  discard block
 block discarded – undo
667 667
 			} 
668 668
 		}
669 669
 		if ($airline_icao == '') return array();
670
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
671
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
670
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
671
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
672 672
 		//$check_date = new Datetime($date);
673
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
673
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
674 674
 		$data = $Common->getData($url);
675 675
 		if ($data != '') {
676 676
 			$table = $Common->table2array($data);
@@ -680,13 +680,13 @@  discard block
 block discarded – undo
680 680
 				$darr = '';
681 681
 				$ahour = '';
682 682
 				$aarr = '';
683
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
683
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
684 684
 				if ($n == 7) {
685 685
 				    $departureTime = $dhour;
686 686
 				    $arrivalTime = $ahour;
687
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
688
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
689
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
687
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
688
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
689
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
690 690
 				}
691 691
 			}
692 692
 		}
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 			$url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign;
719 719
 			$data = $Common->getData($url);
720 720
 			if ($data != '') {
721
-				$result = json_decode($data,true);
721
+				$result = json_decode($data, true);
722 722
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
723 723
 				if (isset($flight['origin'])) {
724 724
 					return array(
@@ -731,18 +731,18 @@  discard block
 block discarded – undo
731 731
 			}
732 732
 		}
733 733
 		
734
-		$url= "http://flightaware.com/live/flight/".$callsign;
734
+		$url = "http://flightaware.com/live/flight/".$callsign;
735 735
 		$data = $Common->getData($url);
736 736
 		if ($data != '') {
737
-			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result);
738
-			$flights = json_decode($result[1],true);
737
+			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result);
738
+			$flights = json_decode($result[1], true);
739 739
 			$flight = reset($flights['flights']);
740 740
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
741 741
 				return array(
742 742
 				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
743
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
743
+				    'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
744 744
 				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
745
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
745
+				    'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
746 746
 				    'Source' => 'website_flightaware');
747 747
 			}
748 748
 		}
@@ -756,20 +756,20 @@  discard block
 block discarded – undo
756 756
 	*/
757 757
 	public function getCostToTravel($callsign) {
758 758
 		$Common = new Common();
759
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
759
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
760 760
 		//$check_date = new Datetime($date);
761 761
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
762 762
 		$data = $Common->getData($url);
763 763
 		if ($data != '') {
764 764
 			$table = $Common->table2array($data);
765 765
 			if (isset($table[11][1])) {
766
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
766
+				if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5);
767 767
 				else $departureTime = '';
768
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
768
+				if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5);
769 769
 				else $arrivalTime = '';
770
-				$DepartureAirportIata = substr($table[13][1],0,3);
771
-				$ArrivalAirportIata = substr($table[15][1],0,3);
772
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
770
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
771
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
772
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
773 773
 			}
774 774
 		}
775 775
 		return array();
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
 	* @param string $date date we want flight number info
782 782
 	* @return array Flight departure and arrival airports and time
783 783
 	*/
784
-	private function getAirCanada($callsign,$date = 'NOW') {
784
+	private function getAirCanada($callsign, $date = 'NOW') {
785 785
 		$Common = new Common();
786 786
 		if (class_exists("DomDocument") === FALSE) return array();
787 787
 		date_default_timezone_set('UTC');
788 788
 		$check_date = new Datetime($date);
789
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
790
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
791
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
789
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
790
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
791
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
792 792
 		$data = $Common->getData($url);
793 793
 		$dom = new DomDocument();
794 794
 		$dom->loadXML($data);
@@ -796,11 +796,11 @@  discard block
 block discarded – undo
796 796
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
797 797
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
798 798
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
799
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
799
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
800 800
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
801 801
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
802
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
803
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
802
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
803
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
804 804
 		} else return array();
805 805
 	}
806 806
 
@@ -812,21 +812,21 @@  discard block
 block discarded – undo
812 812
 	*/
813 813
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
814 814
 		$Common = new Common();
815
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
815
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
816 816
 		$check_date = new Datetime($date);
817
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
818
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
817
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
818
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
819 819
 		$data = $Common->getData($url);
820 820
 		if ($data != '') {
821 821
 			$table = $Common->table2array($data);
822 822
 			$flight = $table;
823
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
824
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
823
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
824
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
825 825
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
826 826
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
827 827
 			$departureTime = $flight[5][1];
828 828
 			$arrivalTime = $flight[23][1];
829
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
829
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
830 830
 		}
831 831
 		return array();
832 832
 	}
@@ -838,16 +838,16 @@  discard block
 block discarded – undo
838 838
 	* @param String $carrier airline code
839 839
 	* @return array Flight departure and arrival airports and time
840 840
 	*/
841
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
841
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
842 842
 		$Common = new Common();
843 843
 		date_default_timezone_set('UTC');
844 844
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
845
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
845
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
846 846
 		$check_date = new Datetime($date);
847
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
848
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
849
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
850
-		$data = $Common->getData($url,'post',$post);
847
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
848
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
849
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
850
+		$data = $Common->getData($url, 'post', $post);
851 851
 		//echo $data;
852 852
 		$DepartureAirportIata = '';
853 853
 		$ArrivalAirportIata = '';
@@ -860,8 +860,8 @@  discard block
 block discarded – undo
860 860
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
861 861
 			else $departureAirport = '';
862 862
 		} else return array();
863
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
864
-		$data = $Common->getData($url,'post',$post);
863
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
864
+		$data = $Common->getData($url, 'post', $post);
865 865
 		if ($data != '') {
866 866
 			$table = $Common->table2array($data);
867 867
 			$flight = $table;
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 			}
890 890
 		}
891 891
 		if (isset($DepartureAirportIata)) {
892
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
892
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
893 893
 		} else return array();
894 894
 	}
895 895
 
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	 * @param String $date Date
900 900
 	 * @return array Schedules info
901 901
 	*/
902
-	public function fetchSchedule($ident,$date = 'NOW') {
902
+	public function fetchSchedule($ident, $date = 'NOW') {
903 903
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
904 904
 		//$Common = new Common();
905 905
 		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 				// Brussels Airlines
970 970
 				case "BEL":
971 971
 				case "SN":
972
-					return $this->getBrussels($ident,$date);
972
+					return $this->getBrussels($ident, $date);
973 973
 /*
974 974
 				// Copa Airlines
975 975
 				case "CMP":
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 				case "DS":
1069 1069
 				case "EZY":
1070 1070
 				case "EZS":
1071
-					return $this->getEasyJet($ident,$date);
1071
+					return $this->getEasyJet($ident, $date);
1072 1072
 				// Ryanair
1073 1073
 				case "FR":
1074 1074
 				case "RYR":
@@ -1120,19 +1120,19 @@  discard block
 block discarded – undo
1120 1120
 					return $this->getIberia($ident);
1121 1121
 				// Vietnam Airlines
1122 1122
 				case "HVN":
1123
-					return $this->getVietnamAirlines($ident,$date);
1123
+					return $this->getVietnamAirlines($ident, $date);
1124 1124
 				// Air Berlin
1125 1125
 				case "AB":
1126 1126
 				case "BER":
1127
-					return $this->getAirBerlin($ident,$date,'AB');
1127
+					return $this->getAirBerlin($ident, $date, 'AB');
1128 1128
 				// NIKI
1129 1129
 				case "HG":
1130 1130
 				case "NLY":
1131
-					return $this->getAirBerlin($ident,$date,'HG');
1131
+					return $this->getAirBerlin($ident, $date, 'HG');
1132 1132
 				// BelAir
1133 1133
 				case "4T":
1134 1134
 				case "BHP":
1135
-					return $this->getAirBerlin($ident,$date,'4T');
1135
+					return $this->getAirBerlin($ident, $date, '4T');
1136 1136
 				default:
1137 1137
 					if (strlen($airline_icao) == 3) {
1138 1138
 						$Spotter = new Spotter($this->db);
@@ -1141,9 +1141,9 @@  discard block
 block discarded – undo
1141 1141
 					}
1142 1142
 					// Randomly use a generic function to get hours
1143 1143
 					if (strlen($airline_icao) == 2) {
1144
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1144
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightaware');
1145 1145
 						if (count($globalSchedulesSources) > 0) {
1146
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1146
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1147 1147
 							$source = $globalSchedulesSources[$rand];
1148 1148
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1149 1149
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
require/class.Translation.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 			} else return $ident;
42 42
 		} else return $ident;
43 43
 		if ($airline_icao == 'AF') {
44
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
45
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
44
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
45
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
46 46
 		} else {
47 47
 			$identicao = $Spotter->getAllAirlineInfo($airline_icao);
48 48
 			if (isset($identicao[0])) {
49
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
49
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
50 50
 			} else $icao = $ident;
51 51
 		}
52 52
 		return $icao;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			$sth = $this->db->prepare($query);
64 64
 			$sth->execute($query_values);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function addOperator($ident, $correct_ident, $source) {
82 82
 		$query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
83
-		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
83
+		$query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source);
84 84
 		try {
85 85
 			$sth = $this->db->prepare($query);
86 86
 			$sth->execute($query_values);
87
-		} catch(PDOException $e) {
87
+		} catch (PDOException $e) {
88 88
 			return "error : ".$e->getMessage();
89 89
 		}
90 90
 	}
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function updateOperator($ident, $correct_ident, $source) {
99 99
 		$query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
100
-		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
100
+		$query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source);
101 101
 		try {
102 102
 			$sth = $this->db->prepare($query);
103 103
 			$sth->execute($query_values);
104
-		} catch(PDOException $e) {
104
+		} catch (PDOException $e) {
105 105
 			return "error : ".$e->getMessage();
106 106
 		}
107 107
 	}
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 require_once(dirname(__FILE__).'/class.Image.php');
12 12
 $global_tracker_query = "SELECT tracker_output.* FROM tracker_output";
13 13
 
14
-class Tracker{
14
+class Tracker {
15 15
 	public $db;
16 16
 	
17 17
 	public function __construct($dbc = null) {
@@ -28,33 +28,33 @@  discard block
 block discarded – undo
28 28
      * @return string the SQL part
29 29
      */
30 30
 	
31
-	public function getFilter($filter = array(),$where = false,$and = false) {
31
+	public function getFilter($filter = array(), $where = false, $and = false) {
32 32
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
33 33
 		$filters = array();
34 34
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
35 35
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
36 36
 				$filters = $globalStatsFilters[$globalFilterName];
37 37
 			} else {
38
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
38
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
39 39
 			}
40 40
 		}
41 41
 		if (isset($filter[0]['source'])) {
42
-			$filters = array_merge($filters,$filter);
42
+			$filters = array_merge($filters, $filter);
43 43
 		}
44
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
44
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
45 45
 		$filter_query_join = '';
46 46
 		$filter_query_where = '';
47
-		foreach($filters as $flt) {
47
+		foreach ($filters as $flt) {
48 48
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
49 49
 				if (isset($flt['source'])) {
50
-					$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'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
50
+					$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'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
51 51
 				} else {
52
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
52
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
53 53
 				}
54 54
 			}
55 55
 		}
56 56
 		if (isset($filter['source']) && !empty($filter['source'])) {
57
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
57
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
58 58
 		}
59 59
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
60 60
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
87 87
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
88 88
 		if ($filter_query_where != '') {
89
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
89
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
90 90
 		}
91 91
 		$filter_query = $filter_query_join.$filter_query_where;
92 92
 		return $filter_query;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @param bool $schedules
102 102
      * @return array the tracker information
103 103
      */
104
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
104
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
105 105
 	{
106 106
 		date_default_timezone_set('UTC');
107 107
 		if (!is_string($query))
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 			$sth = $this->db->prepare($query.$limitQuery);
122 122
 			$sth->execute($params);
123 123
 		} catch (PDOException $e) {
124
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
124
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
125 125
 			exit();
126 126
 		}
127 127
 		
128 128
 		$num_rows = 0;
129 129
 		$tracker_array = array();
130
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
130
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
131 131
 		{
132 132
 			$num_rows++;
133 133
 			$temp_array = array();
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 				{
184 184
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
185 185
 				} else {
186
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
186
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
187 187
 				}
188 188
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
189
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
190
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
189
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
190
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
191 191
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
192 192
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
193 193
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
194 194
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
195
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
196
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
195
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
196
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
197 197
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
198 198
 					}
199 199
 				}
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 		{
233 233
 			$limit_array = explode(",", $limit);
234 234
 			
235
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
236
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
235
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
236
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
237 237
 			
238 238
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
239 239
 			{
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 			$orderby_query = " ORDER BY tracker_output.date DESC";
251 251
 		}
252 252
 
253
-		$query  = $global_tracker_query.$filter_query." ".$orderby_query;
253
+		$query = $global_tracker_query.$filter_query." ".$orderby_query;
254 254
 
255
-		$tracker_array = $this->getDataFromDB($query, array(),$limit_query,true);
255
+		$tracker_array = $this->getDataFromDB($query, array(), $limit_query, true);
256 256
 
257 257
 		return $tracker_array;
258 258
 	}
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 		if ($id == '') return array();
272 272
 		$additional_query = "tracker_output.famtrackid = :id";
273 273
 		$query_values = array(':id' => $id);
274
-		$query  = $global_tracker_query." WHERE ".$additional_query." ";
275
-		$tracker_array = $this->getDataFromDB($query,$query_values);
274
+		$query = $global_tracker_query." WHERE ".$additional_query." ";
275
+		$tracker_array = $this->getDataFromDB($query, $query_values);
276 276
 		return $tracker_array;
277 277
 	}
278 278
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		$query_values = array();
295 295
 		$limit_query = '';
296 296
 		$additional_query = '';
297
-		$filter_query = $this->getFilter($filter,true,true);
297
+		$filter_query = $this->getFilter($filter, true, true);
298 298
 		if ($ident != "")
299 299
 		{
300 300
 			if (!is_string($ident))
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 		{
311 311
 			$limit_array = explode(",", $limit);
312 312
 			
313
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
314
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
313
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
314
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
315 315
 			
316 316
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
317 317
 			{
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		return $tracker_array;
336 336
 	}
337 337
 	
338
-	public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array())
338
+	public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array())
339 339
 	{
340 340
 		global $global_tracker_query, $globalTimezone, $globalDBdriver;
341 341
 		
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		$limit_query = '';
344 344
 		$additional_query = '';
345 345
 
346
-		$filter_query = $this->getFilter($filter,true,true);
346
+		$filter_query = $this->getFilter($filter, true, true);
347 347
 		
348 348
 		if ($date != "")
349 349
 		{
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 		{
370 370
 			$limit_array = explode(",", $limit);
371 371
 			
372
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
373
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
372
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
373
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
374 374
 			
375 375
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
376 376
 			{
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
      * @param array $filters
401 401
      * @return array list of source name
402 402
      */
403
-	public function getAllSourceName($type = '',$filters = array())
403
+	public function getAllSourceName($type = '', $filters = array())
404 404
 	{
405
-		$filter_query = $this->getFilter($filters,true,true);
405
+		$filter_query = $this->getFilter($filters, true, true);
406 406
 		$query_values = array();
407
-		$query  = "SELECT DISTINCT tracker_output.source_name 
407
+		$query = "SELECT DISTINCT tracker_output.source_name 
408 408
 				FROM tracker_output".$filter_query." tracker_output.source_name <> ''";
409 409
 		if ($type != '') {
410 410
 			$query_values = array(':type' => $type);
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 		$source_array = array();
420 420
 		$temp_array = array();
421 421
 		
422
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
422
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
423 423
 		{
424 424
 			$temp_array['source_name'] = $row['source_name'];
425 425
 			$source_array[] = $temp_array;
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
      */
437 437
 	public function getAllIdents($filters = array())
438 438
 	{
439
-		$filter_query = $this->getFilter($filters,true,true);
440
-		$query  = "SELECT DISTINCT tracker_output.ident
439
+		$filter_query = $this->getFilter($filters, true, true);
440
+		$query = "SELECT DISTINCT tracker_output.ident
441 441
 								FROM tracker_output".$filter_query." tracker_output.ident <> '' 
442 442
 								ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0";
443 443
 
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 		$ident_array = array();
448 448
 		$temp_array = array();
449 449
 		
450
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
450
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
451 451
 		{
452 452
 			$temp_array['ident'] = $row['ident'];
453 453
 			$ident_array[] = $temp_array;
@@ -472,12 +472,12 @@  discard block
 block discarded – undo
472 472
 		} else $offset = '+00:00';
473 473
 
474 474
 		if ($globalDBdriver == 'mysql') {
475
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
475
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
476 476
 								FROM tracker_output
477 477
 								WHERE tracker_output.date <> '' 
478 478
 								ORDER BY tracker_output.date ASC LIMIT 0,100";
479 479
 		} else {
480
-			$query  = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
480
+			$query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
481 481
 								FROM tracker_output
482 482
 								WHERE tracker_output.date <> '' 
483 483
 								ORDER BY tracker_output.date ASC LIMIT 0,100";
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		$date_array = array();
490 490
 		$temp_array = array();
491 491
 		
492
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
492
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
493 493
 		{
494 494
 			$temp_array['date'] = $row['date'];
495 495
 
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
      * @param null $fromsource
509 509
      * @return String success or false
510 510
      */
511
-	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
511
+	public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL)
512 512
 	{
513 513
 
514 514
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
515
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
515
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident);
516 516
 
517 517
 		try {
518 518
 			$sth = $this->db->prepare($query);
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
541 541
 	{
542 542
 		$query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid';
543
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
543
+                $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
544 544
 
545 545
 		try {
546 546
 			$sth = $this->db->prepare($query);
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
      * @param string $source_name
571 571
      * @return String success or false
572 572
      */
573
-	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
573
+	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '')
574 574
 	{
575 575
 		//$Image = new Image($this->db);
576 576
 		$Common = new Common();
@@ -636,21 +636,21 @@  discard block
 block discarded – undo
636 636
 		}
637 637
 
638 638
     
639
-		if ($date == "" || strtotime($date) < time()-20*60)
639
+		if ($date == "" || strtotime($date) < time() - 20*60)
640 640
 		{
641 641
 			$date = date("Y-m-d H:i:s", time());
642 642
 		}
643 643
 
644
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
645
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
646
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
647
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
648
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
649
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
650
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
651
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
652
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
653
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
644
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
645
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
646
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
647
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
648
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
649
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
650
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
651
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
652
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
653
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
654 654
 	
655 655
                 if ($latitude == '' && $longitude == '') {
656 656
             		$latitude = 0;
@@ -658,10 +658,10 @@  discard block
 block discarded – undo
658 658
             	}
659 659
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
660 660
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
661
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
661
+                $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
662 662
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
663 663
 
664
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
664
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type);
665 665
 
666 666
 		try {
667 667
 		        
@@ -687,13 +687,13 @@  discard block
 block discarded – undo
687 687
 	{
688 688
 		global $globalDBdriver;
689 689
 		if ($globalDBdriver == 'mysql') {
690
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
690
+			$query = "SELECT tracker_output.ident FROM tracker_output 
691 691
 								WHERE tracker_output.ident = :ident 
692 692
 								AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
693 693
 								AND tracker_output.date < UTC_TIMESTAMP()";
694 694
 			$query_data = array(':ident' => $ident);
695 695
 		} else {
696
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
696
+			$query = "SELECT tracker_output.ident FROM tracker_output 
697 697
 								WHERE tracker_output.ident = :ident 
698 698
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
699 699
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
@@ -702,8 +702,8 @@  discard block
 block discarded – undo
702 702
 		
703 703
 		$sth = $this->db->prepare($query);
704 704
 		$sth->execute($query_data);
705
-    		$ident_result='';
706
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
705
+    		$ident_result = '';
706
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
707 707
 		{
708 708
 			$ident_result = $row['ident'];
709 709
 		}
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
 				return array();
730 730
 			} else {
731 731
 				$q_array = explode(" ", $q);
732
-				foreach ($q_array as $q_item){
733
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
732
+				foreach ($q_array as $q_item) {
733
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
734 734
 					$additional_query .= " AND (";
735 735
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%')";
736 736
 					$additional_query .= ")";
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
 			}
739 739
 		}
740 740
 		if ($globalDBdriver == 'mysql') {
741
-			$query  = "SELECT tracker_output.* FROM tracker_output 
741
+			$query = "SELECT tracker_output.* FROM tracker_output 
742 742
 				WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
743 743
 				AND tracker_output.date < UTC_TIMESTAMP()";
744 744
 		} else {
745
-			$query  = "SELECT tracker_output.* FROM tracker_output 
745
+			$query = "SELECT tracker_output.* FROM tracker_output 
746 746
 				WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
747 747
 				AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
748 748
 		}
@@ -759,16 +759,16 @@  discard block
 block discarded – undo
759 759
      * @param array $filters
760 760
      * @return array the airline country list
761 761
      */
762
-	public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
762
+	public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
763 763
 	{
764 764
 		global $globalDBdriver, $globalArchive;
765 765
 		//$filter_query = $this->getFilter($filters,true,true);
766
-		$Connection= new Connection($this->db);
766
+		$Connection = new Connection($this->db);
767 767
 		if (!$Connection->tableExists('countries')) return array();
768 768
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
769 769
 			require_once('class.TrackerLive.php');
770 770
 			$TrackerLive = new TrackerLive($this->db);
771
-			$filter_query = $TrackerLive->getFilter($filters,true,true);
771
+			$filter_query = $TrackerLive->getFilter($filters, true, true);
772 772
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
773 773
 			if ($olderthanmonths > 0) {
774 774
 				if ($globalDBdriver == 'mysql') {
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 		} else {
789 789
 			require_once('class.TrackerArchive.php');
790 790
 			$TrackerArchive = new TrackerArchive($this->db);
791
-			$filter_query = $TrackerArchive->getFilter($filters,true,true);
791
+			$filter_query = $TrackerArchive->getFilter($filters, true, true);
792 792
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
793 793
 			if ($olderthanmonths > 0) {
794 794
 				if ($globalDBdriver == 'mysql') {
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 		$flight_array = array();
817 817
 		$temp_array = array();
818 818
         
819
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
819
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
820 820
 		{
821 821
 			$temp_array['tracker_count'] = $row['nb'];
822 822
 			$temp_array['tracker_country'] = $row['name'];
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
      * @param string $day
840 840
      * @return array the callsign list
841 841
      */
842
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
842
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
843 843
 	{
844 844
 		global $globalDBdriver;
845
-		$filter_query = $this->getFilter($filters,true,true);
846
-		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
845
+		$filter_query = $this->getFilter($filters, true, true);
846
+		$query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
847 847
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
848 848
 		 if ($olderthanmonths > 0) {
849 849
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -857,28 +857,28 @@  discard block
 block discarded – undo
857 857
 		if ($year != '') {
858 858
 			if ($globalDBdriver == 'mysql') {
859 859
 				$query .= " AND YEAR(tracker_output.date) = :year";
860
-				$query_values = array_merge($query_values,array(':year' => $year));
860
+				$query_values = array_merge($query_values, array(':year' => $year));
861 861
 			} else {
862 862
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
863
-				$query_values = array_merge($query_values,array(':year' => $year));
863
+				$query_values = array_merge($query_values, array(':year' => $year));
864 864
 			}
865 865
 		}
866 866
 		if ($month != '') {
867 867
 			if ($globalDBdriver == 'mysql') {
868 868
 				$query .= " AND MONTH(tracker_output.date) = :month";
869
-				$query_values = array_merge($query_values,array(':month' => $month));
869
+				$query_values = array_merge($query_values, array(':month' => $month));
870 870
 			} else {
871 871
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
872
-				$query_values = array_merge($query_values,array(':month' => $month));
872
+				$query_values = array_merge($query_values, array(':month' => $month));
873 873
 			}
874 874
 		}
875 875
 		if ($day != '') {
876 876
 			if ($globalDBdriver == 'mysql') {
877 877
 				$query .= " AND DAY(tracker_output.date) = :day";
878
-				$query_values = array_merge($query_values,array(':day' => $day));
878
+				$query_values = array_merge($query_values, array(':day' => $day));
879 879
 			} else {
880 880
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
881
-				$query_values = array_merge($query_values,array(':day' => $day));
881
+				$query_values = array_merge($query_values, array(':day' => $day));
882 882
 			}
883 883
 		}
884 884
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 		$callsign_array = array();
891 891
 		$temp_array = array();
892 892
         
893
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
893
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
894 894
 		{
895 895
 			$temp_array['callsign_icao'] = $row['ident'];
896 896
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 		$date_array = array();
943 943
 		$temp_array = array();
944 944
         
945
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
945
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
946 946
 		{
947 947
 			$temp_array['date_name'] = $row['date_name'];
948 948
 			$temp_array['date_count'] = $row['date_count'];
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			$datetime = new DateTime();
969 969
 			$offset = $datetime->format('P');
970 970
 		} else $offset = '+00:00';
971
-		$filter_query = $this->getFilter($filters,true,true);
971
+		$filter_query = $this->getFilter($filters, true, true);
972 972
 		if ($globalDBdriver == 'mysql') {
973 973
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
974 974
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 		$date_array = array();
990 990
 		$temp_array = array();
991 991
         
992
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
992
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
993 993
 		{
994 994
 			$temp_array['date_name'] = $row['date_name'];
995 995
 			$temp_array['date_count'] = $row['date_count'];
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 			$datetime = new DateTime();
1015 1015
 			$offset = $datetime->format('P');
1016 1016
 		} else $offset = '+00:00';
1017
-		$filter_query = $this->getFilter($filters,true,true);
1017
+		$filter_query = $this->getFilter($filters, true, true);
1018 1018
 		if ($globalDBdriver == 'mysql') {
1019 1019
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1020 1020
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		$date_array = array();
1036 1036
 		$temp_array = array();
1037 1037
         
1038
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1038
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1039 1039
 		{
1040 1040
 			$temp_array['date_name'] = $row['date_name'];
1041 1041
 			$temp_array['date_count'] = $row['date_count'];
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 		$date_array = array();
1082 1082
 		$temp_array = array();
1083 1083
         
1084
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1084
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1085 1085
 		{
1086 1086
 			$temp_array['month_name'] = $row['month_name'];
1087 1087
 			$temp_array['year_name'] = $row['year_name'];
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 			$datetime = new DateTime();
1109 1109
 			$offset = $datetime->format('P');
1110 1110
 		} else $offset = '+00:00';
1111
-		$filter_query = $this->getFilter($filters,true,true);
1111
+		$filter_query = $this->getFilter($filters, true, true);
1112 1112
 		if ($globalDBdriver == 'mysql') {
1113 1113
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1114 1114
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 		$date_array = array();
1130 1130
 		$temp_array = array();
1131 1131
         
1132
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1132
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1133 1133
 		{
1134 1134
 			$temp_array['year_name'] = $row['year_name'];
1135 1135
 			$temp_array['month_name'] = $row['month_name'];
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
      * @param array $filters
1150 1150
      * @return array the hour list
1151 1151
      */
1152
-	public function countAllHours($orderby,$filters = array())
1152
+	public function countAllHours($orderby, $filters = array())
1153 1153
 	{
1154 1154
 		global $globalTimezone, $globalDBdriver;
1155 1155
 		if ($globalTimezone != '') {
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 		$hour_array = array();
1198 1198
 		$temp_array = array();
1199 1199
         
1200
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1200
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1201 1201
 		{
1202 1202
 			$temp_array['hour_name'] = $row['hour_name'];
1203 1203
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1219,8 +1219,8 @@  discard block
 block discarded – undo
1219 1219
 	public function countAllHoursByDate($date, $filters = array())
1220 1220
 	{
1221 1221
 		global $globalTimezone, $globalDBdriver;
1222
-		$filter_query = $this->getFilter($filters,true,true);
1223
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1222
+		$filter_query = $this->getFilter($filters, true, true);
1223
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1224 1224
 		if ($globalTimezone != '') {
1225 1225
 			date_default_timezone_set($globalTimezone);
1226 1226
 			$datetime = new DateTime($date);
@@ -1228,12 +1228,12 @@  discard block
 block discarded – undo
1228 1228
 		} else $offset = '+00:00';
1229 1229
 
1230 1230
 		if ($globalDBdriver == 'mysql') {
1231
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1231
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1232 1232
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date
1233 1233
 								GROUP BY hour_name 
1234 1234
 								ORDER BY hour_name ASC";
1235 1235
 		} else {
1236
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1236
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1237 1237
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1238 1238
 								GROUP BY hour_name 
1239 1239
 								ORDER BY hour_name ASC";
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 		$hour_array = array();
1246 1246
 		$temp_array = array();
1247 1247
         
1248
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1248
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1249 1249
 		{
1250 1250
 			$temp_array['hour_name'] = $row['hour_name'];
1251 1251
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 	public function countAllHoursByIdent($ident, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
1270
-		$filter_query = $this->getFilter($filters,true,true);
1271
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1270
+		$filter_query = $this->getFilter($filters, true, true);
1271
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1272 1272
 		if ($globalTimezone != '') {
1273 1273
 			date_default_timezone_set($globalTimezone);
1274 1274
 			$datetime = new DateTime();
@@ -1276,12 +1276,12 @@  discard block
 block discarded – undo
1276 1276
 		} else $offset = '+00:00';
1277 1277
 
1278 1278
 		if ($globalDBdriver == 'mysql') {
1279
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1279
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1280 1280
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1281 1281
 								GROUP BY hour_name 
1282 1282
 								ORDER BY hour_name ASC";
1283 1283
 		} else {
1284
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1284
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1285 1285
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1286 1286
 								GROUP BY hour_name 
1287 1287
 								ORDER BY hour_name ASC";
@@ -1289,12 +1289,12 @@  discard block
 block discarded – undo
1289 1289
       
1290 1290
 		
1291 1291
 		$sth = $this->db->prepare($query);
1292
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1292
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1293 1293
       
1294 1294
 		$hour_array = array();
1295 1295
 		$temp_array = array();
1296 1296
         
1297
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1297
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1298 1298
 		{
1299 1299
 			$temp_array['hour_name'] = $row['hour_name'];
1300 1300
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1314,33 +1314,33 @@  discard block
 block discarded – undo
1314 1314
      * @param string $month
1315 1315
      * @return Integer the number of trackers
1316 1316
      */
1317
-	public function countOverallTracker($filters = array(),$year = '',$month = '')
1317
+	public function countOverallTracker($filters = array(), $year = '', $month = '')
1318 1318
 	{
1319 1319
 		global $globalDBdriver;
1320 1320
 		//$queryi  = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1321
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output";
1321
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output";
1322 1322
 		$query_values = array();
1323 1323
 		$query = '';
1324 1324
 		if ($year != '') {
1325 1325
 			if ($globalDBdriver == 'mysql') {
1326 1326
 				$query .= " AND YEAR(tracker_output.date) = :year";
1327
-				$query_values = array_merge($query_values,array(':year' => $year));
1327
+				$query_values = array_merge($query_values, array(':year' => $year));
1328 1328
 			} else {
1329 1329
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1330
-				$query_values = array_merge($query_values,array(':year' => $year));
1330
+				$query_values = array_merge($query_values, array(':year' => $year));
1331 1331
 			}
1332 1332
 		}
1333 1333
 		if ($month != '') {
1334 1334
 			if ($globalDBdriver == 'mysql') {
1335 1335
 				$query .= " AND MONTH(tracker_output.date) = :month";
1336
-				$query_values = array_merge($query_values,array(':month' => $month));
1336
+				$query_values = array_merge($query_values, array(':month' => $month));
1337 1337
 			} else {
1338 1338
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1339
-				$query_values = array_merge($query_values,array(':month' => $month));
1339
+				$query_values = array_merge($query_values, array(':month' => $month));
1340 1340
 			}
1341 1341
 		}
1342 1342
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1343
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1343
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1344 1344
 		
1345 1345
 		$sth = $this->db->prepare($queryi);
1346 1346
 		$sth->execute($query_values);
@@ -1355,32 +1355,32 @@  discard block
 block discarded – undo
1355 1355
      * @param string $month
1356 1356
      * @return Integer the number of flights
1357 1357
      */
1358
-	public function countOverallTrackerTypes($filters = array(),$year = '',$month = '')
1358
+	public function countOverallTrackerTypes($filters = array(), $year = '', $month = '')
1359 1359
 	{
1360 1360
 		global $globalDBdriver;
1361
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output";
1361
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output";
1362 1362
 		$query_values = array();
1363 1363
 		$query = '';
1364 1364
 		if ($year != '') {
1365 1365
 			if ($globalDBdriver == 'mysql') {
1366 1366
 				$query .= " AND YEAR(tracker_output.date) = :year";
1367
-				$query_values = array_merge($query_values,array(':year' => $year));
1367
+				$query_values = array_merge($query_values, array(':year' => $year));
1368 1368
 			} else {
1369 1369
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1370
-				$query_values = array_merge($query_values,array(':year' => $year));
1370
+				$query_values = array_merge($query_values, array(':year' => $year));
1371 1371
 			}
1372 1372
 		}
1373 1373
 		if ($month != '') {
1374 1374
 			if ($globalDBdriver == 'mysql') {
1375 1375
 				$query .= " AND MONTH(tracker_output.date) = :month";
1376
-				$query_values = array_merge($query_values,array(':month' => $month));
1376
+				$query_values = array_merge($query_values, array(':month' => $month));
1377 1377
 			} else {
1378 1378
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1379
-				$query_values = array_merge($query_values,array(':month' => $month));
1379
+				$query_values = array_merge($query_values, array(':month' => $month));
1380 1380
 			}
1381 1381
 		}
1382 1382
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1383
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1383
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1384 1384
 		
1385 1385
 		$sth = $this->db->prepare($queryi);
1386 1386
 		$sth->execute($query_values);
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 	public function countAllHoursFromToday($filters = array())
1398 1398
 	{
1399 1399
 		global $globalTimezone, $globalDBdriver;
1400
-		$filter_query = $this->getFilter($filters,true,true);
1400
+		$filter_query = $this->getFilter($filters, true, true);
1401 1401
 		if ($globalTimezone != '') {
1402 1402
 			date_default_timezone_set($globalTimezone);
1403 1403
 			$datetime = new DateTime();
@@ -1405,12 +1405,12 @@  discard block
 block discarded – undo
1405 1405
 		} else $offset = '+00:00';
1406 1406
 
1407 1407
 		if ($globalDBdriver == 'mysql') {
1408
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1408
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1409 1409
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE()
1410 1410
 								GROUP BY hour_name 
1411 1411
 								ORDER BY hour_name ASC";
1412 1412
 		} else {
1413
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1413
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1414 1414
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1415 1415
 								GROUP BY hour_name 
1416 1416
 								ORDER BY hour_name ASC";
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 		$hour_array = array();
1423 1423
 		$temp_array = array();
1424 1424
         
1425
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1425
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1426 1426
 		{
1427 1427
 			$temp_array['hour_name'] = $row['hour_name'];
1428 1428
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1441,9 +1441,9 @@  discard block
 block discarded – undo
1441 1441
      */
1442 1442
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1443 1443
 	{
1444
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
1444
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
1445 1445
 
1446
-		$query  = "SELECT tracker_output.tracker_id
1446
+		$query = "SELECT tracker_output.tracker_id
1447 1447
 				FROM tracker_output 
1448 1448
 				WHERE tracker_output.famtrackid = '".$famtrackid."'";
1449 1449
         
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 		$sth = $this->db->prepare($query);
1452 1452
 		$sth->execute();
1453 1453
 
1454
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1454
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1455 1455
 		{
1456 1456
 			return $row['tracker_id'];
1457 1457
 		}
@@ -1476,23 +1476,23 @@  discard block
 block discarded – undo
1476 1476
 		}
1477 1477
 		
1478 1478
 		$current_date = date("Y-m-d H:i:s");
1479
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1479
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1480 1480
 		
1481 1481
 		$diff = abs(strtotime($current_date) - strtotime($date));
1482 1482
 
1483
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1483
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1484 1484
 		$years = $time_array['years'];
1485 1485
 		
1486
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1486
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1487 1487
 		$months = $time_array['months'];
1488 1488
 		
1489
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1489
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1490 1490
 		$days = $time_array['days'];
1491
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1491
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1492 1492
 		$hours = $time_array['hours'];
1493
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1493
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1494 1494
 		$minutes = $time_array['minutes'];
1495
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1495
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1496 1496
 		
1497 1497
 		return $time_array;
1498 1498
 	}
@@ -1515,63 +1515,63 @@  discard block
 block discarded – undo
1515 1515
 			$temp_array['direction_degree'] = $direction;
1516 1516
 			$temp_array['direction_shortname'] = "N";
1517 1517
 			$temp_array['direction_fullname'] = "North";
1518
-		} elseif ($direction >= 22.5 && $direction < 45){
1518
+		} elseif ($direction >= 22.5 && $direction < 45) {
1519 1519
 			$temp_array['direction_degree'] = $direction;
1520 1520
 			$temp_array['direction_shortname'] = "NNE";
1521 1521
 			$temp_array['direction_fullname'] = "North-Northeast";
1522
-		} elseif ($direction >= 45 && $direction < 67.5){
1522
+		} elseif ($direction >= 45 && $direction < 67.5) {
1523 1523
 			$temp_array['direction_degree'] = $direction;
1524 1524
 			$temp_array['direction_shortname'] = "NE";
1525 1525
 			$temp_array['direction_fullname'] = "Northeast";
1526
-		} elseif ($direction >= 67.5 && $direction < 90){
1526
+		} elseif ($direction >= 67.5 && $direction < 90) {
1527 1527
 			$temp_array['direction_degree'] = $direction;
1528 1528
 			$temp_array['direction_shortname'] = "ENE";
1529 1529
 			$temp_array['direction_fullname'] = "East-Northeast";
1530
-		} elseif ($direction >= 90 && $direction < 112.5){
1530
+		} elseif ($direction >= 90 && $direction < 112.5) {
1531 1531
 			$temp_array['direction_degree'] = $direction;
1532 1532
 			$temp_array['direction_shortname'] = "E";
1533 1533
 			$temp_array['direction_fullname'] = "East";
1534
-		} elseif ($direction >= 112.5 && $direction < 135){
1534
+		} elseif ($direction >= 112.5 && $direction < 135) {
1535 1535
 			$temp_array['direction_degree'] = $direction;
1536 1536
 			$temp_array['direction_shortname'] = "ESE";
1537 1537
 			$temp_array['direction_fullname'] = "East-Southeast";
1538
-		} elseif ($direction >= 135 && $direction < 157.5){
1538
+		} elseif ($direction >= 135 && $direction < 157.5) {
1539 1539
 			$temp_array['direction_degree'] = $direction;
1540 1540
 			$temp_array['direction_shortname'] = "SE";
1541 1541
 			$temp_array['direction_fullname'] = "Southeast";
1542
-		} elseif ($direction >= 157.5 && $direction < 180){
1542
+		} elseif ($direction >= 157.5 && $direction < 180) {
1543 1543
 			$temp_array['direction_degree'] = $direction;
1544 1544
 			$temp_array['direction_shortname'] = "SSE";
1545 1545
 			$temp_array['direction_fullname'] = "South-Southeast";
1546
-		} elseif ($direction >= 180 && $direction < 202.5){
1546
+		} elseif ($direction >= 180 && $direction < 202.5) {
1547 1547
 			$temp_array['direction_degree'] = $direction;
1548 1548
 			$temp_array['direction_shortname'] = "S";
1549 1549
 			$temp_array['direction_fullname'] = "South";
1550
-		} elseif ($direction >= 202.5 && $direction < 225){
1550
+		} elseif ($direction >= 202.5 && $direction < 225) {
1551 1551
 			$temp_array['direction_degree'] = $direction;
1552 1552
 			$temp_array['direction_shortname'] = "SSW";
1553 1553
 			$temp_array['direction_fullname'] = "South-Southwest";
1554
-		} elseif ($direction >= 225 && $direction < 247.5){
1554
+		} elseif ($direction >= 225 && $direction < 247.5) {
1555 1555
 			$temp_array['direction_degree'] = $direction;
1556 1556
 			$temp_array['direction_shortname'] = "SW";
1557 1557
 			$temp_array['direction_fullname'] = "Southwest";
1558
-		} elseif ($direction >= 247.5 && $direction < 270){
1558
+		} elseif ($direction >= 247.5 && $direction < 270) {
1559 1559
 			$temp_array['direction_degree'] = $direction;
1560 1560
 			$temp_array['direction_shortname'] = "WSW";
1561 1561
 			$temp_array['direction_fullname'] = "West-Southwest";
1562
-		} elseif ($direction >= 270 && $direction < 292.5){
1562
+		} elseif ($direction >= 270 && $direction < 292.5) {
1563 1563
 			$temp_array['direction_degree'] = $direction;
1564 1564
 			$temp_array['direction_shortname'] = "W";
1565 1565
 			$temp_array['direction_fullname'] = "West";
1566
-		} elseif ($direction >= 292.5 && $direction < 315){
1566
+		} elseif ($direction >= 292.5 && $direction < 315) {
1567 1567
 			$temp_array['direction_degree'] = $direction;
1568 1568
 			$temp_array['direction_shortname'] = "WNW";
1569 1569
 			$temp_array['direction_fullname'] = "West-Northwest";
1570
-		} elseif ($direction >= 315 && $direction < 337.5){
1570
+		} elseif ($direction >= 315 && $direction < 337.5) {
1571 1571
 			$temp_array['direction_degree'] = $direction;
1572 1572
 			$temp_array['direction_shortname'] = "NW";
1573 1573
 			$temp_array['direction_fullname'] = "Northwest";
1574
-		} elseif ($direction >= 337.5 && $direction < 360){
1574
+		} elseif ($direction >= 337.5 && $direction < 360) {
1575 1575
 			$temp_array['direction_degree'] = $direction;
1576 1576
 			$temp_array['direction_shortname'] = "NNW";
1577 1577
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1588,11 +1588,11 @@  discard block
 block discarded – undo
1588 1588
 	* @param Float $longitude longitute of the flight
1589 1589
 	* @return String the countrie
1590 1590
 	*/
1591
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1591
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1592 1592
 	{
1593 1593
 		global $globalDebug;
1594
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1595
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1594
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1595
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1596 1596
 	
1597 1597
 		$Connection = new Connection($this->db);
1598 1598
 		if (!$Connection->tableExists('countries')) return '';
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 	public function getCountryFromISO2($iso2)
1624 1624
 	{
1625 1625
 		global $globalDebug;
1626
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1626
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1627 1627
 	
1628 1628
 		$Connection = new Connection($this->db);
1629 1629
 		if (!$Connection->tableExists('countries')) return '';
@@ -1658,11 +1658,11 @@  discard block
 block discarded – undo
1658 1658
      * @param string $day
1659 1659
      * @return array the vessel type list
1660 1660
      */
1661
-	public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1661
+	public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1662 1662
 	{
1663 1663
 		global $globalDBdriver;
1664
-		$filter_query = $this->getFilter($filters,true,true);
1665
-		$query  = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count 
1664
+		$filter_query = $this->getFilter($filters, true, true);
1665
+		$query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count 
1666 1666
 		    FROM tracker_output ".$filter_query." tracker_output.type  <> ''";
1667 1667
 		if ($olderthanmonths > 0) {
1668 1668
 			if ($globalDBdriver == 'mysql') {
@@ -1682,28 +1682,28 @@  discard block
 block discarded – undo
1682 1682
 		if ($year != '') {
1683 1683
 			if ($globalDBdriver == 'mysql') {
1684 1684
 				$query .= " AND YEAR(tracker_output.date) = :year";
1685
-				$query_values = array_merge($query_values,array(':year' => $year));
1685
+				$query_values = array_merge($query_values, array(':year' => $year));
1686 1686
 			} else {
1687 1687
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1688
-				$query_values = array_merge($query_values,array(':year' => $year));
1688
+				$query_values = array_merge($query_values, array(':year' => $year));
1689 1689
 			}
1690 1690
 		}
1691 1691
 		if ($month != '') {
1692 1692
 			if ($globalDBdriver == 'mysql') {
1693 1693
 				$query .= " AND MONTH(tracker_output.date) = :month";
1694
-				$query_values = array_merge($query_values,array(':month' => $month));
1694
+				$query_values = array_merge($query_values, array(':month' => $month));
1695 1695
 			} else {
1696 1696
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1697
-				$query_values = array_merge($query_values,array(':month' => $month));
1697
+				$query_values = array_merge($query_values, array(':month' => $month));
1698 1698
 			}
1699 1699
 		}
1700 1700
 		if ($day != '') {
1701 1701
 			if ($globalDBdriver == 'mysql') {
1702 1702
 				$query .= " AND DAY(tracker_output.date) = :day";
1703
-				$query_values = array_merge($query_values,array(':day' => $day));
1703
+				$query_values = array_merge($query_values, array(':day' => $day));
1704 1704
 			} else {
1705 1705
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
1706
-				$query_values = array_merge($query_values,array(':day' => $day));
1706
+				$query_values = array_merge($query_values, array(':day' => $day));
1707 1707
 			}
1708 1708
 		}
1709 1709
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 		$sth->execute($query_values);
1713 1713
 		$tracker_array = array();
1714 1714
 		$temp_array = array();
1715
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1715
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1716 1716
 		{
1717 1717
 			$temp_array['tracker_type'] = $row['tracker_type'];
1718 1718
 			$temp_array['tracker_type_count'] = $row['tracker_type_count'];
@@ -1736,13 +1736,13 @@  discard block
 block discarded – undo
1736 1736
      * @param array $filters
1737 1737
      * @return array the tracker information
1738 1738
      */
1739
-	public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1739
+	public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
1740 1740
 	{
1741 1741
 		global $globalTimezone, $globalDBdriver;
1742 1742
 		date_default_timezone_set('UTC');
1743 1743
 		$query_values = array();
1744 1744
 		$additional_query = '';
1745
-		$filter_query = $this->getFilter($filters,true,true);
1745
+		$filter_query = $this->getFilter($filters, true, true);
1746 1746
 		if ($q != "")
1747 1747
 		{
1748 1748
 			if (!is_string($q))
@@ -1750,8 +1750,8 @@  discard block
 block discarded – undo
1750 1750
 				return array();
1751 1751
 			} else {
1752 1752
 				$q_array = explode(" ", $q);
1753
-				foreach ($q_array as $q_item){
1754
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1753
+				foreach ($q_array as $q_item) {
1754
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1755 1755
 					$additional_query .= " AND (";
1756 1756
 					if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1757 1757
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%') OR ";
@@ -1761,20 +1761,20 @@  discard block
 block discarded – undo
1761 1761
 		}
1762 1762
 		if ($callsign != "")
1763 1763
 		{
1764
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1764
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1765 1765
 			if (!is_string($callsign))
1766 1766
 			{
1767 1767
 				return array();
1768 1768
 			} else {
1769 1769
 				$additional_query .= " AND tracker_output.ident = :callsign";
1770
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
1770
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
1771 1771
 			}
1772 1772
 		}
1773 1773
 		if ($date_posted != "")
1774 1774
 		{
1775 1775
 			$date_array = explode(",", $date_posted);
1776
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
1777
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
1776
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
1777
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
1778 1778
 			if ($globalTimezone != '') {
1779 1779
 				date_default_timezone_set($globalTimezone);
1780 1780
 				$datetime = new DateTime();
@@ -1801,8 +1801,8 @@  discard block
 block discarded – undo
1801 1801
 		if ($limit != "")
1802 1802
 		{
1803 1803
 			$limit_array = explode(",", $limit);
1804
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1805
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1804
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1805
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1806 1806
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1807 1807
 			{
1808 1808
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1820,22 +1820,22 @@  discard block
 block discarded – undo
1820 1820
 			}
1821 1821
 		}
1822 1822
 		if ($origLat != "" && $origLon != "" && $dist != "") {
1823
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
1823
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
1824 1824
 			if ($globalDBdriver == 'mysql') {
1825
-				$query="SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance 
1825
+				$query = "SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance 
1826 1826
 				    FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND tracker_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and tracker_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
1827 1827
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
1828 1828
 			} else {
1829
-				$query="SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(tracker_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
1829
+				$query = "SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(tracker_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
1830 1830
 				    FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
1831 1831
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(tracker_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query;
1832 1832
 			}
1833 1833
 		} else {
1834
-			$query  = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' 
1834
+			$query = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' 
1835 1835
 			    ".$additional_query."
1836 1836
 			    ".$orderby_query;
1837 1837
 		}
1838
-		$tracker_array = $this->getDataFromDB($query, $query_values,$limit_query);
1838
+		$tracker_array = $this->getDataFromDB($query, $query_values, $limit_query);
1839 1839
 		return $tracker_array;
1840 1840
 	}
1841 1841
 
@@ -1860,7 +1860,7 @@  discard block
 block discarded – undo
1860 1860
 		curl_close($ch);
1861 1861
 		$bitly_data = json_decode($bitly_data);
1862 1862
 		$bitly_url = '';
1863
-		if ($bitly_data->status_txt = "OK"){
1863
+		if ($bitly_data->status_txt = "OK") {
1864 1864
 			$bitly_url = $bitly_data->data->url;
1865 1865
 		}
1866 1866
 		return $bitly_url;
@@ -1868,7 +1868,7 @@  discard block
 block discarded – undo
1868 1868
 
1869 1869
 	public function getOrderBy()
1870 1870
 	{
1871
-		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1871
+		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1872 1872
 		
1873 1873
 		return $orderby;
1874 1874
 		
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
 */
9 9
 require_once(dirname(__FILE__).'/settings.php');
10 10
 
11
-class Connection{
11
+class Connection {
12 12
 	/** @var $db PDO */
13 13
 	public $db;
14 14
 	public $dbs = array();
15 15
 	public $latest_schema = 55;
16 16
 
17
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
17
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
18 18
 		global $globalNoDB;
19 19
 		if (!isset($globalNoDB) || $globalNoDB === FALSE) {
20 20
 			if ($dbc === null) {
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 					if ($user === null && $pass === null) {
23 23
 						$this->createDBConnection();
24 24
 					} else {
25
-						$this->createDBConnection(null,$user,$pass);
25
+						$this->createDBConnection(null, $user, $pass);
26 26
 					}
27 27
 				} else {
28 28
 					$this->createDBConnection($dbname);
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 		while (true) {
105 105
 			try {
106 106
 				if ($globalDBSdriver == 'mysql') {
107
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
107
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
108 108
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
109 109
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
110
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
111
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
112
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
113
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
114
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
110
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
111
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
112
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
113
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
114
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
115 115
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
116 116
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
117 117
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -121,19 +121,19 @@  discard block
 block discarded – undo
121 121
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
122 122
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
123 123
 				} else {
124
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
124
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
125 125
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
126 126
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
127
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
128
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
129
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
130
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
131
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
127
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
128
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
129
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
130
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
131
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
132 132
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
133 133
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
134 134
 				}
135 135
 				break;
136
-			} catch(PDOException $e) {
136
+			} catch (PDOException $e) {
137 137
 				$i++;
138 138
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
139 139
 				//exit;
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 		try {
159 159
 			//$Connection = new Connection();
160 160
 			$results = $this->db->query($query);
161
-		} catch(PDOException $e) {
161
+		} catch (PDOException $e) {
162 162
 			return false;
163 163
 		}
164
-		if($results->rowCount()>0) {
164
+		if ($results->rowCount() > 0) {
165 165
 		    return true; 
166 166
 		}
167 167
 		else return false;
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 			     return false;
184 184
 			}
185 185
 			
186
-		} catch(PDOException $e) {
187
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
186
+		} catch (PDOException $e) {
187
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
188 188
             			throw $e;
189 189
 	                }
190 190
 	                //echo 'error ! '.$e->getMessage();
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	/*
197 197
 	* Check if index exist
198 198
 	*/
199
-	public function indexExists($table,$index)
199
+	public function indexExists($table, $index)
200 200
 	{
201 201
 		global $globalDBdriver;
202 202
 		if ($globalDBdriver == 'mysql') {
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
 		try {
208 208
 			//$Connection = new Connection();
209 209
 			$results = $this->db->query($query);
210
-		} catch(PDOException $e) {
210
+		} catch (PDOException $e) {
211 211
 			return false;
212 212
 		}
213 213
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
214
-		if($nb[0]['nb'] > 0) {
214
+		if ($nb[0]['nb'] > 0) {
215 215
 			return true; 
216 216
 		}
217 217
 		else return false;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		$query = "SELECT * FROM ".$table." LIMIT 0";
227 227
 		try {
228 228
 			$results = $this->db->query($query);
229
-		} catch(PDOException $e) {
229
+		} catch (PDOException $e) {
230 230
 			return "error : ".$e->getMessage()."\n";
231 231
 		}
232 232
 		$columns = array();
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		return $columns;
239 239
 	}
240 240
 
241
-	public function getColumnType($table,$column) {
241
+	public function getColumnType($table, $column) {
242 242
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
243 243
 		$tomet = $select->getColumnMeta(0);
244 244
 		return $tomet['native_type'];
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	* Check if a column name exist in a table
249 249
 	* @return Boolean column exist or not
250 250
 	*/
251
-	public function checkColumnName($table,$name)
251
+	public function checkColumnName($table, $name)
252 252
 	{
253 253
 		global $globalDBdriver, $globalDBname;
254 254
 		if ($globalDBdriver == 'mysql') {
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 		}
259 259
 			try {
260 260
 				$sth = $this->db()->prepare($query);
261
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
262
-			} catch(PDOException $e) {
261
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
262
+			} catch (PDOException $e) {
263 263
 				echo "error : ".$e->getMessage()."\n";
264 264
 				return false;
265 265
 			}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 				try {
300 300
 					$sth = $this->db->prepare($query);
301 301
 					$sth->execute();
302
-				} catch(PDOException $e) {
302
+				} catch (PDOException $e) {
303 303
 					return "error : ".$e->getMessage()."\n";
304 304
 				}
305 305
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
require/class.NOTAM.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 		try {
989 989
 			$sth = $this->db->prepare($query);
990 990
 			$sth->execute($query_values);
991
-		} catch(PDOException $e) {
991
+		} catch (PDOException $e) {
992 992
 			echo "error : ".$e->getMessage();
993 993
 			return array();
994 994
 		}
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 		try {
1007 1007
 			$sth = $this->db->prepare($query);
1008 1008
 			$sth->execute($query_values);
1009
-		} catch(PDOException $e) {
1009
+		} catch (PDOException $e) {
1010 1010
 			echo "error : ".$e->getMessage();
1011 1011
 			return array();
1012 1012
 		}
@@ -1014,12 +1014,12 @@  discard block
 block discarded – undo
1014 1014
 		return $all;
1015 1015
 	}
1016 1016
 	public function getAllNOTAMtext() {
1017
-		$query  = 'SELECT full_notam FROM notam';
1017
+		$query = 'SELECT full_notam FROM notam';
1018 1018
 		$query_values = array();
1019 1019
 		try {
1020 1020
 			$sth = $this->db->prepare($query);
1021 1021
 			$sth->execute($query_values);
1022
-		} catch(PDOException $e) {
1022
+		} catch (PDOException $e) {
1023 1023
 			echo "error : ".$e->getMessage();
1024 1024
 			return array();
1025 1025
 		}
@@ -1029,12 +1029,12 @@  discard block
 block discarded – undo
1029 1029
 	public function createNOTAMtextFile($filename) {
1030 1030
 		$allnotam_result = $this->getAllNOTAMtext();
1031 1031
 		$notamtext = '';
1032
-		foreach($allnotam_result as $notam) {
1032
+		foreach ($allnotam_result as $notam) {
1033 1033
 			$notamtext .= '%%'."\n";
1034 1034
 			$notamtext .= $notam['full_notam'];
1035 1035
 			$notamtext .= "\n".'%%'."\n";
1036 1036
 		}
1037
-		file_put_contents($filename,$notamtext);
1037
+		file_put_contents($filename, $notamtext);
1038 1038
 	}
1039 1039
 	public function parseNOTAMtextFile($filename) {
1040 1040
 		$data = file_get_contents($filename);
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 		try {
1054 1054
 			$sth = $this->db->prepare($query);
1055 1055
 			$sth->execute($query_values);
1056
-		} catch(PDOException $e) {
1056
+		} catch (PDOException $e) {
1057 1057
 			echo "error : ".$e->getMessage();
1058 1058
 			return array();
1059 1059
 		}
@@ -1063,10 +1063,10 @@  discard block
 block discarded – undo
1063 1063
 	public function getAllNOTAMbyCoord($coord) {
1064 1064
 		global $globalDBdriver;
1065 1065
 		if (is_array($coord)) {
1066
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1067
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1068
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1069
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1066
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1067
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1068
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1069
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1070 1070
 			if ($minlat > $maxlat) {
1071 1071
 				$tmplat = $minlat;
1072 1072
 				$minlat = $maxlat;
@@ -1087,20 +1087,20 @@  discard block
 block discarded – undo
1087 1087
 		try {
1088 1088
 			$sth = $this->db->prepare($query);
1089 1089
 			$sth->execute($query_values);
1090
-		} catch(PDOException $e) {
1090
+		} catch (PDOException $e) {
1091 1091
 			echo "error : ".$e->getMessage();
1092 1092
 			return array();
1093 1093
 		}
1094 1094
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1095 1095
 		return $all;
1096 1096
 	}
1097
-	public function getAllNOTAMbyCoordScope($coord,$scope) {
1097
+	public function getAllNOTAMbyCoordScope($coord, $scope) {
1098 1098
 		global $globalDBdriver;
1099 1099
 		if (is_array($coord)) {
1100
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1101
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1102
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1103
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1100
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1101
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1102
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1103
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1104 1104
 		} else return array();
1105 1105
 		if ($globalDBdriver == 'mysql') {
1106 1106
 			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope';
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 		try {
1112 1112
 			$sth = $this->db->prepare($query);
1113 1113
 			$sth->execute($query_values);
1114
-		} catch(PDOException $e) {
1114
+		} catch (PDOException $e) {
1115 1115
 			echo "error : ".$e->getMessage();
1116 1116
 			return array();
1117 1117
 		}
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 		try {
1125 1125
 			$sth = $this->db->prepare($query);
1126 1126
 			$sth->execute($query_values);
1127
-		} catch(PDOException $e) {
1127
+		} catch (PDOException $e) {
1128 1128
 			return "error : ".$e->getMessage();
1129 1129
 		}
1130 1130
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1132,13 +1132,13 @@  discard block
 block discarded – undo
1132 1132
 		else return array();
1133 1133
 	}
1134 1134
 
1135
-	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
1135
+	public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) {
1136 1136
 		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
1137
-		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
1137
+		$query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam);
1138 1138
 		try {
1139 1139
 			$sth = $this->db->prepare($query);
1140 1140
 			$sth->execute($query_values);
1141
-		} catch(PDOException $e) {
1141
+		} catch (PDOException $e) {
1142 1142
 			return "error : ".$e->getMessage();
1143 1143
 		}
1144 1144
 		return '';
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 		try {
1151 1151
 			$sth = $this->db->prepare($query);
1152 1152
 			$sth->execute($query_values);
1153
-		} catch(PDOException $e) {
1153
+		} catch (PDOException $e) {
1154 1154
 			return "error : ".$e->getMessage();
1155 1155
 		}
1156 1156
 		return '';
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 		try {
1167 1167
 			$sth = $this->db->prepare($query);
1168 1168
 			$sth->execute($query_values);
1169
-		} catch(PDOException $e) {
1169
+		} catch (PDOException $e) {
1170 1170
 			return "error : ".$e->getMessage();
1171 1171
 		}
1172 1172
 		return '';
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		try {
1178 1178
 			$sth = $this->db->prepare($query);
1179 1179
 			$sth->execute($query_values);
1180
-		} catch(PDOException $e) {
1180
+		} catch (PDOException $e) {
1181 1181
 			return "error : ".$e->getMessage();
1182 1182
 		}
1183 1183
 		return '';
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 		try {
1188 1188
 			$sth = $this->db->prepare($query);
1189 1189
 			$sth->execute();
1190
-		} catch(PDOException $e) {
1190
+		} catch (PDOException $e) {
1191 1191
 			return "error : ".$e->getMessage();
1192 1192
 		}
1193 1193
 		return '';
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 		try {
1198 1198
 			$sth = $this->db->prepare($query);
1199 1199
 			$sth->execute();
1200
-		} catch(PDOException $e) {
1200
+		} catch (PDOException $e) {
1201 1201
 			return "error : ".$e->getMessage();
1202 1202
 		}
1203 1203
 		return '';
@@ -1206,14 +1206,14 @@  discard block
 block discarded – undo
1206 1206
 	public function updateNOTAM() {
1207 1207
 		global $globalNOTAMAirports;
1208 1208
 		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
1209
-			foreach (array_chunk($globalNOTAMAirports,10) as $airport) {
1210
-				$airport_icao = implode(',',$airport);
1209
+			foreach (array_chunk($globalNOTAMAirports, 10) as $airport) {
1210
+				$airport_icao = implode(',', $airport);
1211 1211
 				$alldata = $this->downloadNOTAM($airport_icao);
1212 1212
 				if (count($alldata) > 0) {
1213 1213
 					foreach ($alldata as $initial_data) {
1214 1214
 						$data = $this->parse($initial_data);
1215 1215
 						$notamref = $this->getNOTAMbyRef($data['ref']);
1216
-						if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1216
+						if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1217 1217
 					}
1218 1218
 				}
1219 1219
 			}
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
 				$j++;
1231 1231
 				$data = $this->parse($initial_data);
1232 1232
 				$notamref = $this->getNOTAMbyRef($data['ref']);
1233
-				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1234
-				if ($globalTransaction && $j % 1000 == 0) {
1233
+				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1234
+				if ($globalTransaction && $j%1000 == 0) {
1235 1235
 					$this->db->commit();
1236 1236
 					if ($globalDebug) echo '.';
1237 1237
 					$this->db->beginTransaction();
@@ -1245,12 +1245,12 @@  discard block
 block discarded – undo
1245 1245
 		global $globalTransaction;
1246 1246
 		$Spotter = new Spotter($this->db);
1247 1247
 		$allairports = $Spotter->getAllAirportInfo();
1248
-		foreach (array_chunk($allairports,20) as $airport) {
1248
+		foreach (array_chunk($allairports, 20) as $airport) {
1249 1249
 			$airports_icao = array();
1250
-			foreach($airport as $icao) {
1250
+			foreach ($airport as $icao) {
1251 1251
 				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
1252 1252
 			}
1253
-			$airport_icao = implode(',',$airports_icao);
1253
+			$airport_icao = implode(',', $airports_icao);
1254 1254
 			$alldata = $this->downloadNOTAM($airport_icao);
1255 1255
 			if ($globalTransaction) $this->db->beginTransaction();
1256 1256
 			if (count($alldata) > 0) {
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 						if (count($notamref) == 0) {
1264 1264
 							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
1265 1265
 							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
1266
-							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1266
+							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1267 1267
 						}
1268 1268
 					}
1269 1269
 				}
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 		date_default_timezone_set("UTC");
1278 1278
 		$Common = new Common();
1279 1279
 		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1280
-		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1280
+		$url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1281 1281
 		$data = $Common->getData($url);
1282 1282
 		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
1283 1283
 		//print_r($matches);
@@ -1294,8 +1294,8 @@  discard block
 block discarded – undo
1294 1294
 		$result['permanent'] = '';
1295 1295
 		$result['date_begin'] = NULL;
1296 1296
 		$result['date_end'] = NULL;
1297
-		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
1298
-		$data = preg_split('#\s(?=([A-Z]\)\s))#',$data);
1297
+		$data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data);
1298
+		$data = preg_split('#\s(?=([A-Z]\)\s))#', $data);
1299 1299
 		$q = false;
1300 1300
 		$a = false;
1301 1301
 		$b = false;
@@ -1303,9 +1303,9 @@  discard block
 block discarded – undo
1303 1303
 		$e = false;
1304 1304
 		foreach ($data as $line) {
1305 1305
 			$line = trim($line);
1306
-			if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) {
1307
-				$line = str_replace(' ','',$line);
1308
-				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) {
1306
+			if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) {
1307
+				$line = str_replace(' ', '', $line);
1308
+				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) {
1309 1309
 				//if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
1310 1310
 					$result['fir'] = $matches[1];
1311 1311
 					$result['code'] = $matches[2];
@@ -1350,9 +1350,9 @@  discard block
 block discarded – undo
1350 1350
 					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
1351 1351
 					$result['lower_limit'] = $matches[6];
1352 1352
 					$result['upper_limit'] = $matches[7];
1353
-					$latitude = $Common->convertDec($matches[8],'latitude');
1353
+					$latitude = $Common->convertDec($matches[8], 'latitude');
1354 1354
 					if ($matches[9] == 'S') $latitude = -$latitude;
1355
-					$longitude = $Common->convertDec($matches[10],'longitude');
1355
+					$longitude = $Common->convertDec($matches[10], 'longitude');
1356 1356
 					if ($matches[11] == 'W') $longitude = -$longitude;
1357 1357
 					$result['latitude'] = $latitude;
1358 1358
 					$result['longitude'] = $longitude;
@@ -1364,24 +1364,24 @@  discard block
 block discarded – undo
1364 1364
 					echo "Can't parse : ".$line."\n";
1365 1365
 				}
1366 1366
 			}
1367
-			elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) {
1367
+			elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) {
1368 1368
 				$result['icao'] = $matches[2];
1369 1369
 				$a = true;
1370 1370
 			}
1371
-			elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) {
1371
+			elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches) && $b === false) {
1372 1372
 				if ($matches[1] > 50) $year = '19'.$matches[2];
1373 1373
 				else $year = '20'.$matches[2];
1374 1374
 				$result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1375 1375
 				$b = true;
1376 1376
 			}
1377
-			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) {
1377
+			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches) && $c === false) {
1378 1378
 				if ($matches[2] > 50) $year = '19'.$matches[2];
1379 1379
 				else $year = '20'.$matches[2];
1380 1380
 				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1381 1381
 				$result['permanent'] = 0;
1382 1382
 				$c = true;
1383 1383
 			}
1384
-			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) {
1384
+			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches) && $c === false) {
1385 1385
 				if ($matches[2] > 50) $year = '19'.$matches[2];
1386 1386
 				else $year = '20'.$matches[2];
1387 1387
 				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 				else $result['permanent'] = 0;
1392 1392
 				$c = true;
1393 1393
 			}
1394
-			elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) {
1394
+			elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) {
1395 1395
 				$result['date_end'] = '2030/12/20 12:00';
1396 1396
 				if ($matches[2] == 'EST') $result['estimated'] = 1;
1397 1397
 				else $result['estimated'] = 0;
@@ -1399,20 +1399,20 @@  discard block
 block discarded – undo
1399 1399
 				else $result['permanent'] = 0;
1400 1400
 				$c = true;
1401 1401
 			}
1402
-			elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) {
1402
+			elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) {
1403 1403
 				$rtext = array();
1404
-				$text = explode(' ',$matches[2]);
1404
+				$text = explode(' ', $matches[2]);
1405 1405
 				foreach ($text as $word) {
1406 1406
 					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
1407
-					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
1407
+					elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3);
1408 1408
 					else $rtext[] = $word;
1409 1409
 				}
1410
-				$result['text'] = implode(' ',$rtext);
1410
+				$result['text'] = implode(' ', $rtext);
1411 1411
 				$e = true;
1412 1412
 			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
1413 1413
 			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
1414
-			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
1415
-				$text = explode(' ',$line);
1414
+			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) {
1415
+				$text = explode(' ', $line);
1416 1416
 				$result['ref'] = $text[0];
1417 1417
 				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
1418 1418
 				if ($matches[1] == 'NOTAMC') {
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
 	* @param String $date get data for a date
43 43
 	* @return array Return Accidents data in array
44 44
 	*/
45
-	public function getAccidentData($limit = '',$type = '',$date = '') {
45
+	public function getAccidentData($limit = '', $type = '', $date = '') {
46 46
 		global $globalDBdriver;
47 47
 		$Image = new Image($this->db);
48 48
 		$Spotter = new Spotter($this->db);
49 49
 		$Translation = new Translation($this->db);
50
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
50
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
51 51
 		date_default_timezone_set('UTC');
52 52
 		$result = array();
53 53
 		$limit_query = '';
54 54
 		if ($limit != "")
55 55
 		{
56 56
 			$limit_array = explode(",", $limit);
57
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
58
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
57
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
58
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
59 59
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
60 60
 			{
61 61
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -64,29 +64,29 @@  discard block
 block discarded – undo
64 64
 
65 65
 		if ($type != '') {
66 66
 			if ($date != '') {
67
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
67
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
68 68
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
69 69
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
70
-					$query_values = array(':type' => $type,':date' => $date);
71
-				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) {
70
+					$query_values = array(':type' => $type, ':date' => $date);
71
+				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) {
72 72
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
73
-					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31');
74
-				} elseif (preg_match("/^[0-9]{4}$/",$date)) {
73
+					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31');
74
+				} elseif (preg_match("/^[0-9]{4}$/", $date)) {
75 75
 					if ($globalDBdriver == 'mysql') {
76 76
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
77 77
 					} else {
78 78
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
79 79
 					}
80
-					$query_values = array(':type' => $type,':date' => $date);
80
+					$query_values = array(':type' => $type, ':date' => $date);
81 81
 				} else {
82 82
 					$date = $date.'%';
83 83
 					if ($globalDBdriver == 'mysql') {
84 84
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
85
-						$query_values = array(':type' => $type,':date' => $date);
85
+						$query_values = array(':type' => $type, ':date' => $date);
86 86
 					} else {
87 87
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
88 88
 						//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
89
-						$query_values = array(':type' => $type,':date' => $date);
89
+						$query_values = array(':type' => $type, ':date' => $date);
90 90
 					}
91 91
 				}
92 92
 			} else {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			}
98 98
 		} else {
99 99
 			if ($date != '') {
100
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
100
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
101 101
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
102 102
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
103 103
 				} else {
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 		try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
119
-		} catch(PDOException $e) {
119
+		} catch (PDOException $e) {
120 120
 			echo "error : ".$e->getMessage();
121 121
 			return array();
122 122
 		}
123 123
 		$i = 0;
124 124
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
125
-			if (preg_match('/^[\w\-]+$/',$row['registration'])) {
125
+			if (preg_match('/^[\w\-]+$/', $row['registration'])) {
126 126
 				$data = array();
127 127
 				if ($row['registration'] != '') {
128 128
 					$image_array = $Image->getSpotterImage($row['registration']);
129
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
130
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
129
+					if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
130
+					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
131 131
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
132 132
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
133 133
 					if (!empty($aircraft_info)) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 						$data['aircraft_name'] = $aircraft_info[0]['type'];
136 136
 						$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
137 137
 					} else {
138
-						$data = array_merge($data,array('aircraft_type' => 'NA'));
138
+						$data = array_merge($data, array('aircraft_type' => 'NA'));
139 139
 					}
140 140
 					$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
141 141
 					if (!empty($owner_data)) {
@@ -143,18 +143,18 @@  discard block
 block discarded – undo
143 143
 						$data['aircraft_base'] = $owner_data['base'];
144 144
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
145 145
 					}
146
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
146
+				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
147 147
 				if ($row['registration'] == '') $row['registration'] = 'NA';
148 148
 				if ($row['ident'] == '') $row['ident'] = 'NA';
149
-				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
149
+				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
150 150
 				if (isset($identicao[0])) {
151
-					if (substr($row['ident'],0,2) == 'AF') {
152
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
154
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
155
-					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
151
+					if (substr($row['ident'], 0, 2) == 'AF') {
152
+						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
+						else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
154
+					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
155
+					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
156 156
 				} else $icao = $row['ident'];
157
-				$icao = $Translation->checkTranslation($icao,false);
157
+				$icao = $Translation->checkTranslation($icao, false);
158 158
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
159 159
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
160 160
 					//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 					if (!empty($airline_info)) {
164 164
 						//echo 'data found !'."\n";
165 165
 						//print_r($airline_info);
166
-						$data = array_merge($data,$airline_info);
166
+						$data = array_merge($data, $airline_info);
167 167
 					} 
168 168
 					//else echo 'No data...'."\n";
169 169
 				}
170
-				$data = array_merge($row,$data);
170
+				$data = array_merge($row, $data);
171 171
 				if ($data['ident'] == null) $data['ident'] = $icao;
172 172
 				if ($data['title'] == null) {
173 173
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
174 174
 				} else $data['message'] = strtolower($data['title']);
175
-				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
175
+				$ids = $Spotter->getAllIDByRegistration($data['registration'], true);
176 176
 				$date = $data['date'];
177 177
 				if (isset($ids[$date])) {
178 178
 					$data['spotted'] = TRUE;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		try {
205 205
 			$sth = $this->db->prepare($query);
206 206
 			$sth->execute();
207
-		} catch(PDOException $e) {
207
+		} catch (PDOException $e) {
208 208
 			echo "Error : ".$e->getMessage();
209 209
 			return array();
210 210
 		}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		try {
226 226
 			$sth = $this->db->prepare($query);
227 227
 			$sth->execute();
228
-		} catch(PDOException $e) {
228
+		} catch (PDOException $e) {
229 229
 			echo "Error : ".$e->getMessage();
230 230
 			return array();
231 231
 		}
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 		if ($globalDebug) echo 'Import '.$file."\n";
242 242
 		$result = array();
243 243
 		if (file_exists($file)) {
244
-			if (($handle = fopen($file,'r')) !== FALSE) {
245
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
244
+			if (($handle = fopen($file, 'r')) !== FALSE) {
245
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
246 246
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
247
-						$result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam');
247
+						$result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam');
248 248
 					}
249 249
 				}
250 250
 				fclose($handle);
251 251
 			}
252
-			if (!empty($result)) $this->add($result,true);
252
+			if (!empty($result)) $this->add($result, true);
253 253
 			elseif ($globalDebug) echo 'Nothing to import';
254 254
 		}
255 255
 	}
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 		$all_md5_new = array();
266 266
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
267 267
 			if ($this->check_accidents_nb() > 0) {
268
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
269
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
268
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
269
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
270 270
 						if (isset($data[1])) {
271 271
 							$year = $data[0];
272 272
 							$all_md5[$year] = $data[1];
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 				}
277 277
 			}
278 278
 		}
279
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
279
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
280 280
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
281
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
282
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
281
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
282
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
283 283
 					if (isset($data[1])) {
284 284
 						$year = $data[0];
285 285
 						$all_md5_new[$year] = $data[1];
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 				fclose($handle);
289 289
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
290 290
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
291
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
291
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
292 292
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
293 293
 		foreach ($result as $file => $md5) {
294
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
294
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
295 295
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
296 296
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
297 297
 		}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	* Add data to DB
302 302
 	* @param Array $crash An array with accidents/incidents data
303 303
 	*/
304
-	public function add($crash,$new = false) {
304
+	public function add($crash, $new = false) {
305 305
 		global $globalTransaction, $globalDebug, $globalAircraftImageFetch;
306 306
 		require_once('class.Connection.php');
307 307
 		require_once('class.Image.php');
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 			$sthd->execute(array(':source' => $crash[0]['source']));
318 318
 		}
319 319
 		if ($globalTransaction) $Connection->db->beginTransaction();
320
-		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
320
+		$initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null);
321 321
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
322 322
 		$sth_check = $Connection->db->prepare($query_check);
323 323
 		$query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)';
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
 				$cr = array_map(function($value) {
331 331
 					return $value === "" ? NULL : $value;
332 332
 				}, $cr);
333
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
334
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
333
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
334
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
336 336
 					$sth_check->execute($query_check_values);
337 337
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
338 338
 					if ($result_check[0]['nb'] == 0) {
339
-						$query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']);
339
+						$query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']);
340 340
 						$sth->execute($query_values);
341
-						if ($cr['date'] > time()-(30*86400)) {
341
+						if ($cr['date'] > time() - (30*86400)) {
342 342
 							if ($globalAircraftImageFetch) {
343 343
 								$imgchk = $Image->getSpotterImage($cr['registration']);
344 344
 								if (empty($imgchk)) {
@@ -349,17 +349,17 @@  discard block
 block discarded – undo
349 349
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
350 350
 							}
351 351
 							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
352
-							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
352
+							$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
353 353
 						}
354 354
 					}
355 355
 				}
356
-				if ($globalTransaction && $j % 1000 == 0) {
356
+				if ($globalTransaction && $j%1000 == 0) {
357 357
 					$Connection->db->commit();
358 358
 					$Connection->db->beginTransaction();
359 359
 				}
360 360
 			}
361 361
 			if ($globalTransaction) $Connection->db->commit();
362
-		} catch(PDOException $e) {
362
+		} catch (PDOException $e) {
363 363
 			if ($globalTransaction) $Connection->db->rollBack();
364 364
 			echo $e->getMessage();
365 365
 		}
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 			$Connection = new Connection();
378 378
 			$sth = $Connection->db->prepare($query);
379 379
 			$sth->execute();
380
-		} catch(PDOException $e) {
380
+		} catch (PDOException $e) {
381 381
 			return "error : ".$e->getMessage();
382 382
 		}
383 383
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 			$Connection = new Connection();
400 400
 			$sth = $Connection->db->prepare($query);
401 401
 			$sth->execute();
402
-		} catch(PDOException $e) {
402
+		} catch (PDOException $e) {
403 403
 			return "error : ".$e->getMessage();
404 404
 		}
405 405
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			$Connection = new Connection();
419 419
 			$sth = $Connection->db->prepare($query);
420 420
 			$sth->execute();
421
-		} catch(PDOException $e) {
421
+		} catch (PDOException $e) {
422 422
 			return "error : ".$e->getMessage();
423 423
 		}
424 424
 		return '';
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -17,62 +17,62 @@  discard block
 block discarded – undo
17 17
 	* @param array $filter the filter
18 18
 	* @return string the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
38 38
 				if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') {
39 39
 					if (isset($flt['source'])) {
40
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41 41
 					} else {
42
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
43 43
 					}
44 44
 				}
45 45
 			}
46 46
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
47 47
 				if (isset($flt['source'])) {
48
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49 49
 				} else {
50
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
51 51
 				}
52 52
 			}
53 53
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
54 54
 				if (isset($flt['source'])) {
55
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56 56
 				} else {
57
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
58 58
 				}
59 59
 			}
60 60
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
61 61
 				if (isset($flt['source'])) {
62
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63 63
 				} else {
64
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
65 65
 				}
66 66
 			}
67 67
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
68 68
 				if (isset($flt['source'])) {
69
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
70 70
 				}
71 71
 			}
72 72
 		}
73 73
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
74 74
 			if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') {
75
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
76 76
 			}
77 77
 		}
78 78
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
83 83
 		}
84 84
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
85
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
86 86
 		}
87 87
 		if (isset($filter['blocked']) && $filter['blocked'] == true) {
88 88
 			$filter_query_join .= " INNER JOIN (SELECT callsign FROM aircraft_block) cblk ON cblk.callsign = spotter_live.ident";
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			if (count($filter['source']) == 1) {
92 92
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
93 93
 			} else {
94
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
94
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
95 95
 			}
96 96
 		}
97 97
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
125 125
 				}
126 126
 			}
127
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
127
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
128 128
 		}
129 129
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
130
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
130
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
131 131
 		}
132 132
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
133 133
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
134 134
 		if ($filter_query_where != '') {
135
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
135
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
136 136
 		}
137 137
 		$filter_query = $filter_query_join.$filter_query_where;
138 138
 		return $filter_query;
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 		if ($limit != '')
158 158
 		{
159 159
 			$limit_array = explode(',', $limit);
160
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
161
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
160
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
161
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
162 162
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
163 163
 			{
164 164
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		} else {
183 183
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query;
184 184
 		}
185
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
185
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
186 186
 
187 187
 		return $spotter_array;
188 188
 	}
@@ -194,34 +194,34 @@  discard block
 block discarded – undo
194 194
      * @param array $filter
195 195
      * @return array the spotter information
196 196
      */
197
-	public function getMinLiveSpotterData($limit = 0,$filter = array())
197
+	public function getMinLiveSpotterData($limit = 0, $filter = array())
198 198
 	{
199 199
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
200 200
 		date_default_timezone_set('UTC');
201
-		$filter_query = $this->getFilter($filter,true,true);
201
+		$filter_query = $this->getFilter($filter, true, true);
202 202
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
203 203
 		if ($globalDBdriver == 'mysql') {
204 204
 			if (isset($globalArchive) && $globalArchive === TRUE) {
205 205
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
206 206
 			//	FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC";
207
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
207
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
208 208
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
209 209
 			} else {
210 210
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
211 211
 			//	FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC";
212
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
212
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
213 213
 				FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
214 214
 			}
215 215
 		} else {
216 216
 			if (isset($globalArchive) && $globalArchive === TRUE) {
217 217
 			//	$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
218 218
 			//	FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND  spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
219
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
219
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
220 220
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND  spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
221 221
 			} else {
222 222
 			//	$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
223 223
 			//	FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
224
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
224
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
225 225
 				FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
226 226
 			}
227 227
 		}
@@ -229,14 +229,14 @@  discard block
 block discarded – undo
229 229
 		if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') {
230 230
 			$limit = $globalMap2DAircraftsLimit;
231 231
 		}
232
-		if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) {
232
+		if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) {
233 233
 			$query .= ' LIMIT '.$limit;
234 234
 		}
235 235
 
236 236
 		try {
237 237
 			$sth = $this->db->prepare($query);
238 238
 			$sth->execute();
239
-		} catch(PDOException $e) {
239
+		} catch (PDOException $e) {
240 240
 			echo $e->getMessage();
241 241
 			die;
242 242
 		}
@@ -253,20 +253,20 @@  discard block
 block discarded – undo
253 253
      * @param string $id
254 254
      * @return array the spotter information
255 255
      */
256
-	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = 0, $id = '')
256
+	public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = 0, $id = '')
257 257
 	{
258 258
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
259 259
 		date_default_timezone_set('UTC');
260 260
 		$usecoord = false;
261 261
 		if (is_array($coord) && !empty($coord)) {
262
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
263
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
264
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
265
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
262
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
263
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
264
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
265
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
266 266
 			if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true;
267 267
 		}
268
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
269
-		$filter_query = $this->getFilter($filter,true,true);
268
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
269
+		$filter_query = $this->getFilter($filter, true, true);
270 270
 
271 271
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
272 272
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 				ORDER BY flightaware_id, date";
297 297
 				if ($limit > 0) $query .= " LIMIT ".$limit;
298 298
 			} else {
299
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
299
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
300 300
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
301 301
 				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
302 302
 				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		try {
347 347
 			$sth = $this->db->prepare($query);
348 348
 			$sth->execute($query_values);
349
-		} catch(PDOException $e) {
349
+		} catch (PDOException $e) {
350 350
 			echo $e->getMessage();
351 351
 			die;
352 352
 		}
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
      * @param int $limit
363 363
      * @return array the spotter information
364 364
      */
365
-	public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = 0)
365
+	public function getMinLastLiveSpotterDataByID($id = '', $filter = array(), $limit = 0)
366 366
 	{
367 367
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
368 368
 		date_default_timezone_set('UTC');
369
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
370
-		$filter_query = $this->getFilter($filter,true,true);
369
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
370
+		$filter_query = $this->getFilter($filter, true, true);
371 371
 
372 372
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
373 373
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
 			}
393 393
 		} else {
394 394
 			if (isset($globalArchive) && $globalArchive === TRUE) {
395
-				$query  = "SELECT * FROM (
395
+				$query = "SELECT * FROM (
396 396
 				SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
397 397
 				FROM spotter_archive 
398 398
 				INNER JOIN (
399 399
 				    SELECT flightaware_id 
400 400
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
401
-				$query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
401
+				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
402 402
 				$query .= "UNION
403 403
 				    SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
404 404
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 		try {
418 418
 			$sth = $this->db->prepare($query);
419 419
 			$sth->execute($query_values);
420
-		} catch(PDOException $e) {
420
+		} catch (PDOException $e) {
421 421
 			echo $e->getMessage();
422 422
 			die;
423 423
 		}
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	public function getLiveSpotterCount($filter = array())
435 435
 	{
436 436
 		global $globalDBdriver, $globalLiveInterval;
437
-		$filter_query = $this->getFilter($filter,true,true);
437
+		$filter_query = $this->getFilter($filter, true, true);
438 438
 
439 439
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
440 440
 		if ($globalDBdriver == 'mysql') {
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 		try {
448 448
 			$sth = $this->db->prepare($query);
449 449
 			$sth->execute();
450
-		} catch(PDOException $e) {
450
+		} catch (PDOException $e) {
451 451
 			echo $e->getMessage();
452 452
 			die;
453 453
 		}
@@ -465,16 +465,16 @@  discard block
 block discarded – undo
465 465
      */
466 466
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
467 467
 	{
468
-		global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit;
468
+		global $globalDBdriver, $globalLiveInterval, $globalMap2DAircraftsLimit;
469 469
 		$Spotter = new Spotter($this->db);
470 470
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
471 471
 		$filter_query = $this->getFilter($filter);
472 472
 
473 473
 		if (is_array($coord)) {
474
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
475
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
476
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
477
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
474
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
475
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
476
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
477
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
478 478
 		} else return array();
479 479
 		if ($globalDBdriver == 'mysql') {
480 480
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -497,27 +497,27 @@  discard block
 block discarded – undo
497 497
      * @param array $filter
498 498
      * @return array the spotter information
499 499
      */
500
-	public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array())
500
+	public function getMinLiveSpotterDatabyCoord($coord, $limit = 0, $filter = array())
501 501
 	{
502
-		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
502
+		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
503 503
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
504
-		$filter_query = $this->getFilter($filter,true,true);
504
+		$filter_query = $this->getFilter($filter, true, true);
505 505
 
506 506
 		if (is_array($coord)) {
507
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
508
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
509
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
510
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
507
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
508
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
509
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
510
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
511 511
 		} else return array();
512 512
 		if ($globalDBdriver == 'mysql') {
513 513
 			if (isset($globalArchive) && $globalArchive === TRUE) {
514
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
514
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
515 515
 				FROM spotter_live 
516 516
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
517 517
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
518 518
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC';
519 519
 			} else {
520
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
520
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
521 521
 				FROM spotter_live 
522 522
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
523 523
 				    FROM spotter_live l 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
538 538
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
539 539
 				*/
540
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
540
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
541 541
 				FROM spotter_live 
542 542
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
543 543
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 				) s on spotter_live.flightaware_id = s.flightaware_id 
557 557
 				AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
558 558
 				*/
559
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
559
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
560 560
 				FROM spotter_live 
561 561
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
562 562
 				    FROM spotter_live l 
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
 		if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') {
572 572
 			$limit = $globalMap2DAircraftsLimit;
573 573
 		}
574
-		if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) {
574
+		if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) {
575 575
 			$query .= ' LIMIT '.$limit;
576 576
 		}
577 577
 		try {
578 578
 			$sth = $this->db->prepare($query);
579 579
 			$sth->execute();
580
-		} catch(PDOException $e) {
580
+		} catch (PDOException $e) {
581 581
 			echo $e->getMessage();
582 582
 			die;
583 583
 		}
@@ -627,21 +627,21 @@  discard block
 block discarded – undo
627 627
                 if ($interval == '1m')
628 628
                 {
629 629
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
630
-                } else if ($interval == '15m'){
630
+                } else if ($interval == '15m') {
631 631
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
632 632
                 } 
633 633
             }
634 634
         } else {
635 635
         	$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
636 636
         }
637
-	        $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
637
+	        $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
638 638
                    WHERE spotter_live.latitude <> '' 
639 639
                    AND spotter_live.longitude <> '' 
640 640
                   ".$additional_query."
641 641
                    HAVING distance < :radius  
642 642
                    ORDER BY distance";
643 643
 
644
-            $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
644
+            $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
645 645
             return $spotter_array;
646 646
         }
647 647
 
@@ -658,9 +658,9 @@  discard block
 block discarded – undo
658 658
 		date_default_timezone_set('UTC');
659 659
 
660 660
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
661
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
661
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
662 662
 
663
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
663
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
664 664
 
665 665
 		return $spotter_array;
666 666
 	}
@@ -672,16 +672,16 @@  discard block
 block discarded – undo
672 672
      * @param $date
673 673
      * @return array the spotter information
674 674
      */
675
-	public function getDateLiveSpotterDataByIdent($ident,$date)
675
+	public function getDateLiveSpotterDataByIdent($ident, $date)
676 676
 	{
677 677
 		$Spotter = new Spotter($this->db);
678 678
 		date_default_timezone_set('UTC');
679 679
 
680 680
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
681
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
681
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
682 682
 
683
-                $date = date('c',$date);
684
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
683
+                $date = date('c', $date);
684
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
685 685
 
686 686
 		return $spotter_array;
687 687
 	}
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 		$Spotter = new Spotter($this->db);
698 698
 		date_default_timezone_set('UTC');
699 699
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
700
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
701
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
700
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
701
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
702 702
 		return $spotter_array;
703 703
 	}
704 704
 
@@ -709,15 +709,15 @@  discard block
 block discarded – undo
709 709
      * @param $date
710 710
      * @return array the spotter information
711 711
      */
712
-	public function getDateLiveSpotterDataById($id,$date)
712
+	public function getDateLiveSpotterDataById($id, $date)
713 713
 	{
714 714
 		$Spotter = new Spotter($this->db);
715 715
 		date_default_timezone_set('UTC');
716 716
 
717 717
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
718
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
719
-		$date = date('c',$date);
720
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
718
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
719
+		$date = date('c', $date);
720
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
721 721
 		return $spotter_array;
722 722
 	}
723 723
 
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
 		date_default_timezone_set('UTC');
734 734
 
735 735
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
736
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
736
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
737 737
 
738 738
     		try {
739 739
 			
740 740
 			$sth = $this->db->prepare($query);
741 741
 			$sth->execute(array(':ident' => $ident));
742
-		} catch(PDOException $e) {
742
+		} catch (PDOException $e) {
743 743
 			echo $e->getMessage();
744 744
 			die;
745 745
 		}
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
      * @param bool $liveinterval
756 756
      * @return array the spotter information
757 757
      */
758
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
758
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
759 759
 	{
760 760
 		global $globalDBdriver, $globalLiveInterval;
761 761
 		date_default_timezone_set('UTC');
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		try {
775 775
 			$sth = $this->db->prepare($query);
776 776
 			$sth->execute(array(':id' => $id));
777
-		} catch(PDOException $e) {
777
+		} catch (PDOException $e) {
778 778
 			echo $e->getMessage();
779 779
 			die;
780 780
 		}
@@ -792,12 +792,12 @@  discard block
 block discarded – undo
792 792
 	{
793 793
 		date_default_timezone_set('UTC');
794 794
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
795
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
795
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
796 796
     		try {
797 797
 			
798 798
 			$sth = $this->db->prepare($query);
799 799
 			$sth->execute(array(':ident' => $ident));
800
-		} catch(PDOException $e) {
800
+		} catch (PDOException $e) {
801 801
 			echo $e->getMessage();
802 802
 			die;
803 803
 		}
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 			
828 828
 			$sth = $this->db->prepare($query);
829 829
 			$sth->execute();
830
-		} catch(PDOException $e) {
830
+		} catch (PDOException $e) {
831 831
 			return "error";
832 832
 		}
833 833
 
@@ -850,14 +850,14 @@  discard block
 block discarded – undo
850 850
 				
851 851
 				$sth = $this->db->prepare($query);
852 852
 				$sth->execute();
853
-			} catch(PDOException $e) {
853
+			} catch (PDOException $e) {
854 854
 				return "error";
855 855
 			}
856 856
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
857 857
                         $i = 0;
858
-                        $j =0;
858
+                        $j = 0;
859 859
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
860
-			foreach($all as $row)
860
+			foreach ($all as $row)
861 861
 			{
862 862
 				$i++;
863 863
 				$j++;
@@ -865,9 +865,9 @@  discard block
 block discarded – undo
865 865
 					if ($globalDebug) echo ".";
866 866
 				    	try {
867 867
 						
868
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
868
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
869 869
 						$sth->execute();
870
-					} catch(PDOException $e) {
870
+					} catch (PDOException $e) {
871 871
 						return "error";
872 872
 					}
873 873
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -878,9 +878,9 @@  discard block
 block discarded – undo
878 878
 			if ($i > 0) {
879 879
     				try {
880 880
 					
881
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
881
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
882 882
 					$sth->execute();
883
-				} catch(PDOException $e) {
883
+				} catch (PDOException $e) {
884 884
 					return "error";
885 885
 				}
886 886
 			}
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 				
894 894
 				$sth = $this->db->prepare($query);
895 895
 				$sth->execute();
896
-			} catch(PDOException $e) {
896
+			} catch (PDOException $e) {
897 897
 				return "error";
898 898
 			}
899 899
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -941,13 +941,13 @@  discard block
 block discarded – undo
941 941
 	public function deleteLiveSpotterDataByIdent($ident)
942 942
 	{
943 943
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
944
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
944
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
945 945
         
946 946
     		try {
947 947
 			
948 948
 			$sth = $this->db->prepare($query);
949 949
 			$sth->execute(array(':ident' => $ident));
950
-		} catch(PDOException $e) {
950
+		} catch (PDOException $e) {
951 951
 			return "error";
952 952
 		}
953 953
 
@@ -963,13 +963,13 @@  discard block
 block discarded – undo
963 963
 	public function deleteLiveSpotterDataById($id)
964 964
 	{
965 965
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
966
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
966
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
967 967
         
968 968
     		try {
969 969
 			
970 970
 			$sth = $this->db->prepare($query);
971 971
 			$sth->execute(array(':id' => $id));
972
-		} catch(PDOException $e) {
972
+		} catch (PDOException $e) {
973 973
 			return "error";
974 974
 		}
975 975
 
@@ -987,13 +987,13 @@  discard block
 block discarded – undo
987 987
 	{
988 988
 		global $globalDBdriver, $globalTimezone;
989 989
 		if ($globalDBdriver == 'mysql') {
990
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
990
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
991 991
 				WHERE spotter_live.ident = :ident 
992 992
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
993 993
 				AND spotter_live.date < UTC_TIMESTAMP()';
994 994
 			$query_data = array(':ident' => $ident);
995 995
 		} else {
996
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
996
+			$query = "SELECT spotter_live.ident FROM spotter_live 
997 997
 				WHERE spotter_live.ident = :ident 
998 998
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
999 999
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 		
1003 1003
 		$sth = $this->db->prepare($query);
1004 1004
 		$sth->execute($query_data);
1005
-		$ident_result='';
1006
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1005
+		$ident_result = '';
1006
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1007 1007
 		{
1008 1008
 			$ident_result = $row['ident'];
1009 1009
 		}
@@ -1020,13 +1020,13 @@  discard block
 block discarded – undo
1020 1020
 	{
1021 1021
 		global $globalDBdriver, $globalTimezone;
1022 1022
 		if ($globalDBdriver == 'mysql') {
1023
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1023
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1024 1024
 				WHERE spotter_live.ident = :ident 
1025 1025
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
1026 1026
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1027 1027
 			$query_data = array(':ident' => $ident);
1028 1028
 		} else {
1029
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1029
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1030 1030
 				WHERE spotter_live.ident = :ident 
1031 1031
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'";
1032 1032
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 		
1036 1036
 		$sth = $this->db->prepare($query);
1037 1037
 		$sth->execute($query_data);
1038
-		$ident_result='';
1039
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1038
+		$ident_result = '';
1039
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1040 1040
 		{
1041 1041
 			$ident_result = $row['flightaware_id'];
1042 1042
 		}
@@ -1053,13 +1053,13 @@  discard block
 block discarded – undo
1053 1053
 	{
1054 1054
 		global $globalDBdriver, $globalTimezone;
1055 1055
 		if ($globalDBdriver == 'mysql') {
1056
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1056
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1057 1057
 				WHERE spotter_live.flightaware_id = :id 
1058 1058
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
1059 1059
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1060 1060
 			$query_data = array(':id' => $id);
1061 1061
 		} else {
1062
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1062
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1063 1063
 				WHERE spotter_live.flightaware_id = :id 
1064 1064
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
1065 1065
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
 		
1069 1069
 		$sth = $this->db->prepare($query);
1070 1070
 		$sth->execute($query_data);
1071
-		$ident_result='';
1072
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1071
+		$ident_result = '';
1072
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1073 1073
 		{
1074 1074
 			$ident_result = $row['flightaware_id'];
1075 1075
 		}
@@ -1086,13 +1086,13 @@  discard block
 block discarded – undo
1086 1086
 	{
1087 1087
 		global $globalDBdriver, $globalTimezone;
1088 1088
 		if ($globalDBdriver == 'mysql') {
1089
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1089
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1090 1090
 				WHERE spotter_live.ModeS = :modes 
1091 1091
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
1092 1092
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1093 1093
 			$query_data = array(':modes' => $modes);
1094 1094
 		} else {
1095
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1095
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1096 1096
 				WHERE spotter_live.ModeS = :modes 
1097 1097
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'";
1098 1098
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
 		
1102 1102
 		$sth = $this->db->prepare($query);
1103 1103
 		$sth->execute($query_data);
1104
-		$ident_result='';
1105
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1104
+		$ident_result = '';
1105
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1106 1106
 		{
1107 1107
 			//$ident_result = $row['spotter_live_id'];
1108 1108
 			$ident_result = $row['flightaware_id'];
@@ -1127,8 +1127,8 @@  discard block
 block discarded – undo
1127 1127
 				return array();
1128 1128
 			} else {
1129 1129
 				$q_array = explode(" ", $q);
1130
-				foreach ($q_array as $q_item){
1131
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1130
+				foreach ($q_array as $q_item) {
1131
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1132 1132
 					$additional_query .= " AND (";
1133 1133
 					$additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR ";
1134 1134
 					$additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR ";
@@ -1143,11 +1143,11 @@  discard block
 block discarded – undo
1143 1143
 			}
1144 1144
 		}
1145 1145
 		if ($globalDBdriver == 'mysql') {
1146
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1146
+			$query = "SELECT spotter_live.* FROM spotter_live 
1147 1147
 			    WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
1148 1148
 			    AND spotter_live.date < UTC_TIMESTAMP()";
1149 1149
 		} else {
1150
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1150
+			$query = "SELECT spotter_live.* FROM spotter_live 
1151 1151
 			    WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1152 1152
 			    AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1153 1153
 		}
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
      * @param string $over_country
1190 1190
      * @return String success or false
1191 1191
      */
1192
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
1192
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
1193 1193
 	{
1194 1194
 		global $globalURL, $globalArchive, $globalDebug;
1195 1195
 		$Common = new Common();
@@ -1289,27 +1289,27 @@  discard block
 block discarded – undo
1289 1289
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1290 1290
 
1291 1291
         
1292
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1293
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1294
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1295
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1296
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1297
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1298
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1299
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1300
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1301
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1302
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1303
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1304
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1305
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1306
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1307
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1308
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1309
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1310
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1311
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1312
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1292
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1293
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1294
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1295
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1296
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1297
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1298
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1299
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1300
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1301
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1302
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1303
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1304
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1305
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1306
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1307
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1308
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1309
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1310
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1311
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1312
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1313 1313
 
1314 1314
 		$airline_name = '';
1315 1315
 		$airline_icao = '';
@@ -1331,10 +1331,10 @@  discard block
 block discarded – undo
1331 1331
 		$arrival_airport_country = '';
1332 1332
 		
1333 1333
             	
1334
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1335
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1336
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1337
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1334
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1335
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1336
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1337
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1338 1338
 		
1339 1339
 		$query = '';
1340 1340
 		if ($globalArchive) {
@@ -1345,19 +1345,19 @@  discard block
 block discarded – undo
1345 1345
 		$query  .= 'INSERT INTO spotter_live (flightaware_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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) 
1346 1346
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)';
1347 1347
 
1348
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real);
1348
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real);
1349 1349
 		try {
1350 1350
 			
1351 1351
 			$sth = $this->db->prepare($query);
1352 1352
 			$sth->execute($query_values);
1353 1353
 			$sth->closeCursor();
1354
-		} catch(PDOException $e) {
1354
+		} catch (PDOException $e) {
1355 1355
 			return "error : ".$e->getMessage();
1356 1356
 		}
1357 1357
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1358 1358
 		    if ($globalDebug) echo '(Add to Spotter archive : ';
1359 1359
 		    $SpotterArchive = new SpotterArchive($this->db);
1360
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_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, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1360
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_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, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1361 1361
 		    if ($globalDebug) echo $result.')';
1362 1362
 		} elseif ($globalDebug && $putinarchive !== true) {
1363 1363
 			echo '(Not adding to archive)';
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
 
1371 1371
 	public function getOrderBy()
1372 1372
 	{
1373
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1373
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1374 1374
 		return $orderby;
1375 1375
 	}
1376 1376
 
Please login to merge, or discard this patch.
table-output.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -4,15 +4,15 @@  discard block
 block discarded – undo
4 4
 
5 5
 require_once(dirname(__FILE__).'/require/class.Common.php');
6 6
 $Common = new Common();
7
-$showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
7
+$showRouteStop = $Common->multiKeyExists($spotter_array, 'route_stop');
8 8
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
9
-	$showDuration = $Common->multiKeyExists($spotter_array,'race_time');
10
-	if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array,'duration');
9
+	$showDuration = $Common->multiKeyExists($spotter_array, 'race_time');
10
+	if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array, 'duration');
11 11
 } else {
12
-	$showDuration = $Common->multiKeyExists($spotter_array,'duration');
12
+	$showDuration = $Common->multiKeyExists($spotter_array, 'duration');
13 13
 }
14 14
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
15
-	$showDistance = $Common->multiKeyExists($spotter_array,'distance');
15
+	$showDistance = $Common->multiKeyExists($spotter_array, 'distance');
16 16
 }
17 17
 
18 18
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	}
179 179
 	print '<th class="more"></th>';
180 180
 	print '</thead>';
181
-} else if (strtolower($current_page) == "upcoming"){
181
+} else if (strtolower($current_page) == "upcoming") {
182 182
 	print '<thead>';
183 183
 	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
184 184
 		if ($_GET['sort'] == "airline_name_asc")
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	}
233 233
 	*/
234 234
 	print '</thead>';
235
-} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive"){
235
+} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
236 236
 	print '<thead>';
237 237
 	print '<th class="aircraft_thumbnail"></th>';
238 238
 	print '<th class="logo">'._("Airline").'</th>';
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	print '</thead>';
270 270
 } else {
271 271
 
272
-	if ($hide_th_links === true){
272
+	if ($hide_th_links === true) {
273 273
 		print '<thead>';
274 274
 		if ($type == 'marine' && isset($globalVM) && $globalVM) {
275 275
 			print '<th class="rank">'._("Rank").'</th>';
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 }
588 588
 
589 589
 print '<tbody>'."\n";
590
-foreach($spotter_array as $spotter_item)
590
+foreach ($spotter_array as $spotter_item)
591 591
 {
592 592
 	if (isset($globalTimezone))
593 593
 	{
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
623 623
 					}
624 624
 					if (isset($spotter_item['airline_name'])) {
625
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
625
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
626 626
 					} else {
627
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
627
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
628 628
 					}
629 629
 				} else {
630 630
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
631
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
631
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
632 632
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
633 633
 					if (isset($spotter_item['airline_name'])) {
634 634
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			{
655 655
 				print '<td class="aircraft_thumbnail">'."\n";
656 656
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
657
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
657
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
658 658
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
659 659
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
660 660
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			{
677 677
 				print '<td class="aircraft_thumbnail">'."\n";
678 678
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
679
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
679
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
680 680
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
681 681
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
682 682
 				print '</td>'."\n";
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 				print '</td>'."\n";
721 721
 			}
722 722
 		}
723
-	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
723
+	} elseif (strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed") {
724 724
 		if ($type == 'aircraft') {
725 725
 			if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
726 726
 			    $spotter_item['squawk'] = '-';
@@ -737,17 +737,17 @@  discard block
 block discarded – undo
737 737
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
738 738
 					}
739 739
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
740
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
740
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
741 741
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
742
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
742
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
743 743
 					} elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) {
744
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
744
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
745 745
 					} else {
746
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
746
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
747 747
 					}
748 748
 				} else {
749 749
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
750
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
750
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
751 751
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
752 752
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
753 753
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 			{
788 788
 				print '<td class="aircraft_thumbnail">'."\n";
789 789
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
790
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
790
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
791 791
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
792 792
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
793 793
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n";
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 			{
812 812
 				print '<td class="aircraft_thumbnail">'."\n";
813 813
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
814
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
814
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
815 815
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
816 816
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
817 817
 				print '</td>'."\n";
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 		print '</td>'."\n";
921 921
 	}
922 922
 	// Aircraft type
923
-	if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){
923
+	if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") {
924 924
 		print '<td class="type">'."\n";
925 925
 		if ($type == 'aircraft') {
926 926
 			if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) {
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 				//print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'._("Not available").'</a></span>'."\n";
930 930
 				print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
931 931
 			} else {
932
-				$aircraft_names = explode('/',$spotter_item['aircraft_name']);
932
+				$aircraft_names = explode('/', $spotter_item['aircraft_name']);
933 933
 				if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
934 934
 				else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
935 935
 			}
@@ -973,22 +973,22 @@  discard block
 block discarded – undo
973 973
 			}
974 974
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
975 975
 				if ($spotter_item['departure_airport_time'] > 2460) {
976
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
977
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
976
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
977
+				} else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
978 978
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
979
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
979
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
980 980
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
981 981
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
982 982
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
983 983
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
984
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
984
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
985 985
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
986 986
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
987 987
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
988 988
 				if ($spotter_item['departure_airport_time'] > 2460) {
989
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
989
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
990 990
 				} else {
991
-					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
991
+					$departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
992 992
 				}
993 993
 				print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n";
994 994
 			}
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 						$latitude = $spotter_item['latitude'];
1004 1004
 						$longitude = $spotter_item['longitude'];
1005 1005
 					}
1006
-					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
1006
+					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude);
1007 1007
 				} else $distance = '';
1008 1008
 				if ($distance != '') {
1009 1009
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 					if (!isset($Spotter)) $Spotter = new Spotter();
1035 1035
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
1036 1036
 					if (isset($arrival_airport_info[0])) {
1037
-                        print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
1037
+                        print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
1038 1038
                     }
1039 1039
                     print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
1040 1040
                     if (isset($arrival_airport_info[0])) {
@@ -1050,20 +1050,20 @@  discard block
 block discarded – undo
1050 1050
 			}
1051 1051
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
1052 1052
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1053
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1053
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
1054 1054
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1055 1055
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1056
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1056
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
1057 1057
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1058 1058
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
1059 1059
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
1060 1060
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1061
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1061
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
1062 1062
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1063 1063
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
1064 1064
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
1065 1065
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1066
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1066
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
1067 1067
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1068 1068
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
1069 1069
 			}
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 						$latitude = $spotter_item['latitude'];
1077 1077
 						$longitude = $spotter_item['longitude'];
1078 1078
 					}
1079
-					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
1079
+					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude);
1080 1080
 				} else $distance = '';
1081 1081
 				if ($distance != '') {
1082 1082
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -1138,19 +1138,19 @@  discard block
 block discarded – undo
1138 1138
 				print '<span class="mobile">-</span>'."\n";
1139 1139
 			} else {
1140 1140
 				if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1141
-					print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
1142
-					print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
1141
+					print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
1142
+					print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
1143 1143
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1144
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
1145
-					print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
1144
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
1145
+					print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
1146 1146
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1147
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
1148
-					print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
1147
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
1148
+					print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
1149 1149
 				}
1150 1150
 			}
1151 1151
 			print '</td>'."\n";
1152 1152
 		}
1153
-		if(strtolower($current_page) != "upcoming"){
1153
+		if (strtolower($current_page) != "upcoming") {
1154 1154
 			if ($type == 'aircraft') {
1155 1155
 				//if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
1156 1156
 				if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
@@ -1195,14 +1195,14 @@  discard block
 block discarded – undo
1195 1195
 						if (isset($spotter_item['distance'])) {
1196 1196
 							print '<td class="distance">';
1197 1197
 							if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1198
-								print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
1199
-								print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
1198
+								print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
1199
+								print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
1200 1200
 							} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1201
-								print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
1202
-								print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
1201
+								print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
1202
+								print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
1203 1203
 							} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1204
-								print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
1205
-								print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
1204
+								print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
1205
+								print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
1206 1206
 							}
1207 1207
 							print '</td>'."\n";
1208 1208
 						} else {
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 		
1234 1234
 		if ($showRouteStop) {
1235 1235
 		// Route stop
1236
-			if(strtolower($current_page) != "upcoming"){
1236
+			if (strtolower($current_page) != "upcoming") {
1237 1237
 				print '<td class="route_stop">'."\n";
1238 1238
 				if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') {
1239 1239
 					print '<span class="nomobile">-</span>'."\n";
@@ -1256,19 +1256,19 @@  discard block
 block discarded – undo
1256 1256
 				print '<td class="duration">'."\n";
1257 1257
 				if (isset($spotter_item['race_time'])) {
1258 1258
 					if ($spotter_item['race_time'] > 86400) {
1259
-						print '<span class="nomobile">'.gmdate("z\d. H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1260
-						print '<span class="mobile">'.gmdate("z\d. H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1259
+						print '<span class="nomobile">'.gmdate("z\d. H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1260
+						print '<span class="mobile">'.gmdate("z\d. H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1261 1261
 					} else {
1262
-						print '<span class="nomobile">'.gmdate("H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1263
-						print '<span class="mobile">'.gmdate("H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1262
+						print '<span class="nomobile">'.gmdate("H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1263
+						print '<span class="mobile">'.gmdate("H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1264 1264
 					}
1265 1265
 				} elseif (isset($spotter_item['duration'])) {
1266 1266
 					if ($spotter_item['duration'] > 86400) {
1267
-						print '<span class="nomobile">'.gmdate('z\d. H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1268
-						print '<span class="mobile">'.gmdate('z\d. H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1267
+						print '<span class="nomobile">'.gmdate('z\d. H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1268
+						print '<span class="mobile">'.gmdate('z\d. H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1269 1269
 					} else {
1270
-						print '<span class="nomobile">'.gmdate('H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1271
-						print '<span class="mobile">'.gmdate('H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1270
+						print '<span class="nomobile">'.gmdate('H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1271
+						print '<span class="mobile">'.gmdate('H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1272 1272
 					}
1273 1273
 				} else {
1274 1274
 					print '<span class="nomobile">-</span>'."\n";
@@ -1276,11 +1276,11 @@  discard block
 block discarded – undo
1276 1276
 				}
1277 1277
 				print '</td>'."\n";
1278 1278
 			} else {
1279
-				if(strtolower($current_page) != "upcoming"){
1279
+				if (strtolower($current_page) != "upcoming") {
1280 1280
 					print '<td class="duration">'."\n";
1281 1281
 					if (isset($spotter_item['duration'])) {
1282
-						print '<span class="nomobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
1283
-						print '<span class="mobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
1282
+						print '<span class="nomobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
1283
+						print '<span class="mobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
1284 1284
 					} else {
1285 1285
 						print '<span class="nomobile">-</span>'."\n";
1286 1286
 						print '<span class="mobile">-</span>'."\n";
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
1295 1295
 		if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') {
1296 1296
 			print '<td class="message"><p>'."\n";
1297
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1297
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1298 1298
 			print '</p><p class="decode">';
1299 1299
 			$decode_array = json_decode($spotter_item['decode']);
1300 1300
 			foreach ($decode_array as $key => $value) {
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 			print '</td>'."\n";
1305 1305
 		} else {
1306 1306
 			print '<td class="message">'."\n";
1307
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1307
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1308 1308
 			print '</td>'."\n";
1309 1309
 		}
1310 1310
 	}
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 		}
1330 1330
 		print '</td>'."\n";
1331 1331
 		print '<td class="message">'."\n";
1332
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1332
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1333 1333
 		print '</td>'."\n";
1334 1334
 	}
1335 1335
 	if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") {
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 		print '</td>'."\n";
1356 1356
 		*/
1357 1357
 		print '<td class="message">'."\n";
1358
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1358
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1359 1359
 		print '</td>'."\n";
1360 1360
 	}
1361 1361
 
Please login to merge, or discard this patch.