Completed
Push — master ( bb48eb...8e257c )
by Yannick
34:24
created
require/class.Weather.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 	public function buildcloudlayer($metar) {
12 12
 		//print_r($metar);
13 13
 		$result = array();
14
-		foreach($metar['cloud'] as $key => $data) {
14
+		foreach ($metar['cloud'] as $key => $data) {
15 15
 			$alt_m = $metar['cloud'][$key]['level'];
16 16
 			$alt_ft = $alt_m*3.28084;
17 17
 			$pressure = $metar['QNH'];
18
-			$cumulus_base = 122.0 * ($metar['temperature'] - $metar['dew']);
19
-			$stratus_base = 100.0 * (100.0 * $metar['rh'])*0.3048;
18
+			$cumulus_base = 122.0*($metar['temperature'] - $metar['dew']);
19
+			$stratus_base = 100.0*(100.0*$metar['rh'])*0.3048;
20 20
 			$coverage_norm = 0.0;
21 21
 			if ($metar['cloud'][$key]['type'] == 'Few') {
22 22
 				$coverage_norm = 2.0/8.0;
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 					$layer_type = 'ns';
39 39
 				}
40 40
 			} else {
41
-				if ($cumulus_base * 0.80 < $alt_m && $cumulus_base * 1.20 > $alt_m) {
41
+				if ($cumulus_base*0.80 < $alt_m && $cumulus_base*1.20 > $alt_m) {
42 42
 					$layer_type = 'cu';
43
-				} elseif ($stratus_base * 0.80 < $alt_m && $stratus_base * 1.40 > $alt_m) {
43
+				} elseif ($stratus_base*0.80 < $alt_m && $stratus_base*1.40 > $alt_m) {
44 44
 					$layer_type = 'st';
45 45
 				} else {
46 46
 					if ($alt_ft < 2000) {
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 				}
54 54
 			}
55 55
 			//echo 'coverage norm : '.$coverage_norm.' - layer_type: '.$layer_type."\n";
56
-			$result[] = array('cov' => $coverage_norm, 'type' => $layer_type,'alt' => $alt_m,'rh' => $metar['rh']);
56
+			$result[] = array('cov' => $coverage_norm, 'type' => $layer_type, 'alt' => $alt_m, 'rh' => $metar['rh']);
57 57
 		}
58 58
 		if (count($result) < 2 && $metar['rh'] > 60) {
59
-			$result[] = array('cov' => 0.75, 'type' => 'ci','alt' => 4000,'rh' => $metar['rh']);
59
+			$result[] = array('cov' => 0.75, 'type' => 'ci', 'alt' => 4000, 'rh' => $metar['rh']);
60 60
 		}
61 61
 		return $result;
62 62
 	}
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 		
77 77
 		// http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl?file=gfs.t05z.pgrb2full.0p50.f000&lev_10_m_above_ground=on&lev_surface=on&var_TMP=on&var_UGRD=on&var_VGRD=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=/gfs.2017111717
78 78
 		$resolution = '0.5';
79
-		$baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00':'0p50').'.pl';
80
-		$get = array('file' => 'gfs.t'.sprintf('%02d',(6*floor($hour/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'),
79
+		$baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00' : '0p50').'.pl';
80
+		$get = array('file' => 'gfs.t'.sprintf('%02d', (6*floor($hour/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'),
81 81
 			'lev_10_m_above_ground' => 'on',
82 82
 			'lev_surface' => 'on',
83 83
 			'var_TMP' => 'on',
@@ -87,21 +87,21 @@  discard block
 block discarded – undo
87 87
 			'rightlon' => 360,
88 88
 			'toplat' => 90,
89 89
 			'bottomlat' => -90,
90
-			'dir' => '/gfs.'.date('Ymd').sprintf('%02d',(6*floor($hour/6)))
90
+			'dir' => '/gfs.'.date('Ymd').sprintf('%02d', (6*floor($hour/6)))
91 91
 		);
92 92
 		$url = $baseurl.'?'.http_build_query($get);
93 93
 		echo $url;
94 94
 		$Common = new Common();
95
-		$Common->download($url,$windpathsrc);
95
+		$Common->download($url, $windpathsrc);
96 96
 		// Check if the downloaded file is in GRIB format
97
-		$file = fopen($windpathsrc,"r");
97
+		$file = fopen($windpathsrc, "r");
98 98
 		$firc = fgetc($file);
99 99
 		fclose($file);
100 100
 		if ($firc == 'G') {
101 101
 			system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc);
102 102
 		} else {
103 103
 			// if not try previous run
104
-			if ($hour == date('G')) $this->nomad_wind(date('G')-6);
104
+			if ($hour == date('G')) $this->nomad_wind(date('G') - 6);
105 105
 		}
106 106
 	}
107 107
 
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 		$url = 'https://podaac.jpl.nasa.gov/ws/search/granule/?datasetId=PODAAC-OSCAR-03D01&itemsPerPage=1&sortBy=timeDesc&format=atom&pretty=false';
121 121
 		$Common = new Common();
122 122
 		$oscarlst = $Common->getData($url);
123
-		$oscarlst_xml = json_decode(json_encode(simplexml_load_string($oscarlst)),true);
123
+		$oscarlst_xml = json_decode(json_encode(simplexml_load_string($oscarlst)), true);
124 124
 		foreach ($oscarlst_xml['entry']['link'] as $oscarlnk) {
125 125
 			if ($oscarlnk['@attributes']['type'] == 'application/x-netcdf') {
126
-				$Common->download($oscarlnk['@attributes']['href'],$wavepathsrc.'.gz');
126
+				$Common->download($oscarlnk['@attributes']['href'], $wavepathsrc.'.gz');
127 127
 				break;
128 128
 			}
129 129
 		}
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	
64 64
 	public function nomad_wind($hour = '') {
65 65
 		global $globalWindsPath;
66
-		if ($hour == '') $hour = date('G');
66
+		if ($hour == '') {
67
+			$hour = date('G');
68
+		}
67 69
 		if (isset($globalWindsPath) && $globalWindsPath != '') {
68 70
 			$grib2json = $globalWindsPath['grib2json'];
69 71
 			$windpathsrc = $globalWindsPath['source'];
@@ -101,7 +103,9 @@  discard block
 block discarded – undo
101 103
 			system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc);
102 104
 		} else {
103 105
 			// if not try previous run
104
-			if ($hour == date('G')) $this->nomad_wind(date('G')-6);
106
+			if ($hour == date('G')) {
107
+				$this->nomad_wind(date('G')-6);
108
+			}
105 109
 		}
106 110
 	}
107 111
 
Please login to merge, or discard this patch.
require/class.MarineImport.php 3 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -16,25 +16,25 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/class.Stats.php');
17 17
 require_once(dirname(__FILE__).'/class.Source.php');
18 18
 if (isset($globalServerAPRS) && $globalServerAPRS) {
19
-    require_once(dirname(__FILE__).'/class.APRS.php');
19
+	require_once(dirname(__FILE__).'/class.APRS.php');
20 20
 }
21 21
 
22 22
 class MarineImport {
23
-    private $all_tracked = array();
24
-    private $last_delete_hourly = 0;
25
-    private $last_delete = 0;
26
-    private $stats = array();
27
-    private $tmd = 0;
28
-    private $source_location = array();
29
-    public $db = null;
30
-    public $nb = 0;
23
+	private $all_tracked = array();
24
+	private $last_delete_hourly = 0;
25
+	private $last_delete = 0;
26
+	private $stats = array();
27
+	private $tmd = 0;
28
+	private $source_location = array();
29
+	public $db = null;
30
+	public $nb = 0;
31 31
 
32
-    public function __construct($dbc = null) {
32
+	public function __construct($dbc = null) {
33 33
 	global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB;
34 34
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
35
-	    $Connection = new Connection($dbc);
36
-	    $this->db = $Connection->db();
37
-	    date_default_timezone_set('UTC');
35
+		$Connection = new Connection($dbc);
36
+		$this->db = $Connection->db();
37
+		date_default_timezone_set('UTC');
38 38
 	}
39 39
 	// Get previous source stats
40 40
 	/*
@@ -53,79 +53,79 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 	*/
55 55
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
56
-	    $APRSMarine = new APRSMarine();
57
-	    //$APRSSpotter->connect();
56
+		$APRSMarine = new APRSMarine();
57
+		//$APRSSpotter->connect();
58
+	}
58 59
 	}
59
-    }
60 60
 
61
-    public function checkAll() {
61
+	public function checkAll() {
62 62
 	global $globalDebug, $globalNoDB, $globalVM;
63 63
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
64
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
65
-	    foreach ($this->all_tracked as $key => $flight) {
64
+		if ($globalDebug) echo "Update last seen tracked data...\n";
65
+		foreach ($this->all_tracked as $key => $flight) {
66 66
 		if (isset($this->all_tracked[$key]['id'])) {
67
-		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
68
-    		    $Marine = new Marine($this->db);
69
-    		    if (isset($globalVM) && $globalVM) {
67
+			//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
68
+				$Marine = new Marine($this->db);
69
+				if (isset($globalVM) && $globalVM) {
70 70
 			if ($this->all_tracked[$key]['status'] == 'Racing') {
71
-    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72
-    			} else {
73
-    			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
-    			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
-    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77
-    			}
78
-    		    } else {
71
+					$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72
+				} else {
73
+					$timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
+					if ($timerace > time()) $finaldatetime = NULL;
75
+					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
+					$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77
+				}
78
+				} else {
79 79
 			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
80
-		    }
80
+			}
81
+		}
81 82
 		}
82
-	    }
83 83
 	}
84
-    }
84
+	}
85 85
 
86
-    public function del() {
86
+	public function del() {
87 87
 	global $globalDebug, $globalNoDB, $globalNoImport;
88 88
 	// Delete old infos
89 89
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
90 90
 	foreach ($this->all_tracked as $key => $flight) {
91
-    	    if (isset($flight['lastupdate'])) {
92
-        	if ($flight['lastupdate'] < (time()-3000)) {
93
-            	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94
-            		if (isset($this->all_tracked[$key]['id'])) {
95
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
96
-			    /*
91
+			if (isset($flight['lastupdate'])) {
92
+			if ($flight['lastupdate'] < (time()-3000)) {
93
+					if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94
+					if (isset($this->all_tracked[$key]['id'])) {
95
+						if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
96
+				/*
97 97
 			    $MarineLive = new MarineLive();
98 98
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
99 99
 			    $MarineLive->db = null;
100 100
 			    */
101
-            		    //$real_arrival = $this->arrival($key);
102
-            		    $Marine = new Marine($this->db);
103
-            		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
101
+						//$real_arrival = $this->arrival($key);
102
+						$Marine = new Marine($this->db);
103
+						if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
104 104
 				if (isset($globalVM) && $globalVM) {
105
-				    if ($this->all_tracked[$key]['status'] == 'Racing') {
105
+					if ($this->all_tracked[$key]['status'] == 'Racing') {
106 106
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
107
-				    } else {
107
+					} else {
108 108
 					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
109
-	        			if ($timerace > time()) $finaldatetime = NULL;
109
+						if ($timerace > time()) $finaldatetime = NULL;
110 110
 					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
111 111
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
112
-				    }
112
+					}
113 113
 				} else {
114 114
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
115 115
 				}
116 116
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
117
-			    }
118
-			    // Put in archive
117
+				}
118
+				// Put in archive
119 119
 //				$Marine->db = null;
120 120
 			}
121
-            	    }
122
-            	    unset($this->all_tracked[$key]);
123
-    	        }
124
-	    }
125
-        }
126
-    }
121
+					}
122
+					unset($this->all_tracked[$key]);
123
+				}
124
+		}
125
+		}
126
+	}
127 127
 
128
-    public function add($line) {
128
+	public function add($line) {
129 129
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM;
130 130
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
131 131
 	date_default_timezone_set('UTC');
@@ -134,106 +134,106 @@  discard block
 block discarded – undo
134 134
 	
135 135
 	// SBS format is CSV format
136 136
 	if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
137
-	    //print_r($line);
138
-  	    if (isset($line['mmsi']) || isset($line['id'])) {
137
+		//print_r($line);
138
+  		if (isset($line['mmsi']) || isset($line['id'])) {
139 139
 
140 140
 		
141 141
 		// Increment message number
142 142
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
143
-		    $current_date = date('Y-m-d');
144
-		    if (isset($line['source_name'])) $source = $line['source_name'];
145
-		    else $source = '';
146
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
147
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
148
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
149
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
143
+			$current_date = date('Y-m-d');
144
+			if (isset($line['source_name'])) $source = $line['source_name'];
145
+			else $source = '';
146
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
147
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
148
+				$this->stats[$current_date][$source]['msg']['date'] = time();
149
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
151 151
 		}
152 152
 		
153 153
 		
154 154
 		$Common = new Common();
155 155
 		$AIS = new AIS();
156
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
157
-	        else $id = trim($line['id']);
156
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
157
+			else $id = trim($line['id']);
158 158
 		
159 159
 		if (!isset($this->all_tracked[$id])) {
160
-		    $this->all_tracked[$id] = array();
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
162
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164
-		    if (!isset($line['id'])) {
160
+			$this->all_tracked[$id] = array();
161
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
162
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164
+			if (!isset($line['id'])) {
165 165
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
166 166
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
167
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
+			if ($globalAllTracked !== FALSE) $dataFound = true;
169 169
 		}
170 170
 		
171 171
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
173
-		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
172
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
173
+			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
174 174
 			$Marine = new Marine($this->db);
175 175
 			$identity = $Marine->getIdentity($line['mmsi']);
176 176
 			if (!empty($identity)) {
177
-			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
178
-			    $this->all_tracked[$id]['type'] = $identity['type'];
179
-			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
177
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
178
+				$this->all_tracked[$id]['type'] = $identity['type'];
179
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
180 180
 			}
181 181
 			//print_r($identity);
182 182
 			unset($Marine);
183 183
 			//$dataFound = true;
184
-		    }
184
+			}
185 185
 		}
186 186
 		if (isset($line['type_id'])) {
187
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
188
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
187
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
188
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
189 189
 		}
190 190
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
191
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
192
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
191
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
192
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
193 193
 		} elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') {
194
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
194
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
195 195
 		}
196 196
 		if (isset($line['status']) && $line['status'] != '') {
197
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
197
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
198 198
 		}
199 199
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
200
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
201
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
200
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
201
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
202 202
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
203
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
203
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
204 204
 				$Marine = new Marine($this->db);
205 205
 				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
206 206
 				unset($Marine);
207
-			    }
207
+				}
208
+			}
208 209
 			}
209
-		    }
210 210
 		}
211 211
 
212 212
 
213 213
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
214
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
214
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
215 215
 		}
216 216
 		if (isset($line['imo']) && $line['imo'] != '') {
217
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
217
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
218 218
 		}
219 219
 		if (isset($line['callsign']) && $line['callsign'] != '') {
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
220
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
221 221
 		}
222 222
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223
-		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
223
+			if (!isset($this->all_tracked[$id]['arrival_code'])) {
224 224
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
225 225
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
226 226
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227
-			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
227
+				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 228
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
229
-				    $Marine = new Marine($this->db);
230
-				    $fromsource = NULL;
231
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
232
-				    $Marine->db = null;
229
+					$Marine = new Marine($this->db);
230
+					$fromsource = NULL;
231
+					$Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
232
+					$Marine->db = null;
233
+				}
233 234
 				}
234
-			    }
235 235
 			}
236
-		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
236
+			} elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
237 237
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
238 238
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
239 239
 			if (!isset($line['id'])) {
@@ -241,50 +241,50 @@  discard block
 block discarded – undo
241 241
 				$this->all_tracked[$id]['forcenew'] = 1;
242 242
 				$this->all_tracked[$id]['addedMarine'] = 0;
243 243
 			}
244
-		    }
244
+			}
245 245
 		}
246 246
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
247
+			if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
248 248
 		}
249 249
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
251 251
 		}
252 252
 		if (isset($line['captain_name']) && $line['captain_name'] != '') {
253
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
253
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
254 254
 		}
255 255
 		if (isset($line['race_id']) && $line['race_id'] != '') {
256
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
256
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
257 257
 		}
258 258
 		if (isset($line['race_name']) && $line['race_name'] != '') {
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
259
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
260 260
 		}
261 261
 		if (isset($line['race_rank']) && $line['race_rank'] != '') {
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank']));
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank']));
263 263
 		}
264 264
 		if (isset($line['race_time']) && $line['race_time'] != '') {
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time']));
265
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time']));
266 266
 		}
267 267
 		if (isset($line['race_begin']) && $line['race_begin'] != '') {
268
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin']));
268
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin']));
269 269
 		}
270 270
 		if (isset($line['distance']) && $line['distance'] != '') {
271
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance']));
271
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance']));
272 272
 		}
273 273
 
274 274
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
275 275
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
276
-		    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
276
+			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
277 277
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
278
-			    $timeelapsed = microtime(true);
279
-			    $Marine = new Marine($this->db);
280
-			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
281
-			    $Marine->db = null;
278
+				$timeelapsed = microtime(true);
279
+				$Marine = new Marine($this->db);
280
+				$Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
281
+				$Marine->db = null;
282
+			}
282 283
 			}
283
-		    }
284
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
285
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
284
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
285
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
286 286
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
287
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
287
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
288 288
 				$timeelapsed = microtime(true);
289 289
 				$Marine = new Marine($this->db);
290 290
 				$fromsource = NULL;
@@ -292,20 +292,20 @@  discard block
 block discarded – undo
292 292
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
293 293
 				$Marine->db = null;
294 294
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
295
-			    }
295
+				}
296
+			}
296 297
 			}
297
-		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
298
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
299 299
 		}
300 300
 
301 301
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
302
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
302
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303 303
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
304
-		    } else {
304
+			} else {
305 305
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
306 306
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
307 307
 				return '';
308
-		    }
308
+			}
309 309
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
310 310
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
311 311
 			return '';
@@ -322,33 +322,33 @@  discard block
 block discarded – undo
322 322
 
323 323
 
324 324
 		if (isset($line['speed'])) {
325
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2)));
326
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
325
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2)));
326
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
327 327
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
328
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
329
-		    if ($distance > 1000 && $distance < 10000) {
328
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
329
+			if ($distance > 1000 && $distance < 10000) {
330 330
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 331
 			$speed = $speed*3.6;
332 332
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
333 333
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
334
-		    }
334
+			}
335 335
 		}
336 336
 
337
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
-	    	    else unset($timediff);
340
-	    	    if ($this->tmd > 5 ||
341
-	    		!isset($timediff) ||
342
-	    		$timediff > $globalLiveInterval ||
343
-	    		(
344
-	    		    $timediff > 30 && 
345
-	    		    isset($this->all_tracked[$id]['latitude']) &&
346
-	    		    isset($this->all_tracked[$id]['longitude']) &&
347
-	    		    $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
348
-	    		)
349
-	    		) {
337
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
+				else unset($timediff);
340
+				if ($this->tmd > 5 ||
341
+				!isset($timediff) ||
342
+				$timediff > $globalLiveInterval ||
343
+				(
344
+					$timediff > 30 && 
345
+					isset($this->all_tracked[$id]['latitude']) &&
346
+					isset($this->all_tracked[$id]['longitude']) &&
347
+					$Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
348
+				)
349
+				) {
350 350
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
351
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
351
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
352 352
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
353 353
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 354
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -356,217 +356,217 @@  discard block
 block discarded – undo
356 356
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
357 357
 				$timeelapsed = microtime(true);
358 358
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359
-				    $Marine = new Marine($this->db);
360
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
362
-				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+					$Marine = new Marine($this->db);
360
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
362
+					$Marine->db = null;
363
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364 364
 				}
365 365
 				$this->tmd = 0;
366 366
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
367
-			    }
367
+				}
368 368
 			}
369 369
 
370 370
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371 371
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
372 372
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
373
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374
-				    $dataFound = true;
375
-				    $this->all_tracked[$id]['time_last_coord'] = time();
373
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374
+					$dataFound = true;
375
+					$this->all_tracked[$id]['time_last_coord'] = time();
376 376
 				}
377 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
378 378
 			}
379 379
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
380
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381 381
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
382 382
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
383
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384
-				    $dataFound = true;
385
-				    $this->all_tracked[$id]['time_last_coord'] = time();
383
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384
+					$dataFound = true;
385
+					$this->all_tracked[$id]['time_last_coord'] = time();
386 386
 				}
387 387
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
388 388
 			}
389 389
 
390
-		    } else if ($globalDebug && $timediff > 20) {
390
+			} else if ($globalDebug && $timediff > 20) {
391 391
 			$this->tmd = $this->tmd + 1;
392 392
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
393 393
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
394 394
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
395 395
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
396
-		    }
396
+			}
397 397
 		}
398 398
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
400
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
399
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
400
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
401 401
 		}
402 402
 		if (isset($line['format_source']) && $line['format_source'] != '') {
403
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
403
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
404 404
 		}
405 405
 		if (isset($line['source_name']) && $line['source_name'] != '') {
406
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
406
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
407 407
 		}
408 408
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
409
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
409
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
410 410
 		}
411 411
 		
412 412
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416
-		    //$dataFound = true;
413
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416
+			//$dataFound = true;
417 417
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
418
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
419
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
418
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
419
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
422 422
   		}
423 423
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
424 424
 
425 425
 
426 426
 
427 427
 		if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) {
428
-		    $this->all_tracked[$id]['lastupdate'] = time();
429
-		    if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) {
430
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
431
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
428
+			$this->all_tracked[$id]['lastupdate'] = time();
429
+			if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) {
430
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
431
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 432
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
434
-				    $timeelapsed = microtime(true);
435
-				    $MarineLive = new MarineLive($this->db);
436
-				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
433
+					if ($globalDebug) echo "Check if vessel is already in DB...";
434
+					$timeelapsed = microtime(true);
435
+					$MarineLive = new MarineLive($this->db);
436
+					if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 437
 					$Marine = new Marine($this->db);
438 438
 					$recent_ident = $Marine->checkId($line['id']);
439 439
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
440 440
 					$Marine->db=null;
441
-				    } elseif (isset($line['id'])) {
441
+					} elseif (isset($line['id'])) {
442 442
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443 443
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
444
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
444
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 445
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446 446
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
447
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
447
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 448
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449 449
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
450
-				    } else $recent_ident = '';
451
-				    $MarineLive->db=null;
452
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
450
+					} else $recent_ident = '';
451
+					$MarineLive->db=null;
452
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454 454
 				} else $recent_ident = '';
455
-			    } else {
455
+				} else {
456 456
 				$recent_ident = '';
457 457
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
458
-			    }
459
-			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
460
-			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461
-			    {
458
+				}
459
+				//if there was no vessel with the same callsign within the last hour and go post it into the archive
460
+				if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461
+				{
462 462
 				if ($globalDebug) {
463 463
 					if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
464 464
 					else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
465 465
 				}
466 466
 				//adds the spotter data for the archive
467
-				    $highlight = '';
468
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
469
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
467
+					$highlight = '';
468
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
469
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 470
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471
-					    $timeelapsed = microtime(true);
472
-					    $Marine = new Marine($this->db);
473
-					    if (isset($globalVM) && $globalVM && $this->all_tracked[$id]['race_begin'] != '') {
471
+						$timeelapsed = microtime(true);
472
+						$Marine = new Marine($this->db);
473
+						if (isset($globalVM) && $globalVM && $this->all_tracked[$id]['race_begin'] != '') {
474 474
 						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['race_begin'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
475
-					    } else {
475
+						} else {
476 476
 						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
477
-					    }
478
-					    $Marine->db = null;
479
-					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
477
+						}
478
+						$Marine->db = null;
479
+						if ($globalDebug && isset($result)) echo $result."\n";
480
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481 481
 					}
482
-				    }
483
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
482
+					}
483
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
484 484
 					// Add source stat in DB
485 485
 					$Stats = new Stats($this->db);
486 486
 					if (!empty($this->stats)) {
487
-					    if ($globalDebug) echo 'Add source stats : ';
488
-				    	    foreach($this->stats as $date => $data) {
487
+						if ($globalDebug) echo 'Add source stats : ';
488
+							foreach($this->stats as $date => $data) {
489 489
 						foreach($data as $source => $sourced) {
490
-					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
493
-				    		    if (isset($sourced['msg'])) {
494
-				    			if (time() - $sourced['msg']['date'] > 10) {
495
-				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
496
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
497
-			    			    	    unset($this->stats[$date][$source]['msg']);
498
-			    				}
499
-			    			    }
500
-			    			}
501
-			    			if ($date != date('Y-m-d')) {
502
-			    			    unset($this->stats[$date]);
503
-			    			}
504
-				    	    }
505
-				    	    if ($globalDebug) echo 'Done'."\n";
490
+								//print_r($sourced);
491
+									if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
+									if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
493
+								if (isset($sourced['msg'])) {
494
+								if (time() - $sourced['msg']['date'] > 10) {
495
+										$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
496
+										echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
497
+										unset($this->stats[$date][$source]['msg']);
498
+								}
499
+								}
500
+							}
501
+							if ($date != date('Y-m-d')) {
502
+								unset($this->stats[$date]);
503
+							}
504
+							}
505
+							if ($globalDebug) echo 'Done'."\n";
506 506
 					}
507 507
 					$Stats->db = null;
508
-				    }
508
+					}
509 509
 				    
510
-				    $this->del();
510
+					$this->del();
511 511
 				//$ignoreImport = false;
512 512
 				$this->all_tracked[$id]['addedMarine'] = 1;
513 513
 				//print_r($this->all_tracked[$id]);
514 514
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
515
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
516
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
517
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
515
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
516
+					//MarineLive->deleteLiveMarineDataNotUpdated();
517
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 518
 					$MarineLive = new MarineLive($this->db);
519 519
 					$MarineLive->deleteLiveMarineData();
520 520
 					$MarineLive->db=null;
521 521
 					if ($globalDebug) echo " Done\n";
522
-				    }
523
-				    $this->last_delete = time();
522
+					}
523
+					$this->last_delete = time();
524 524
 				}
525
-			    } elseif ($recent_ident != '') {
525
+				} elseif ($recent_ident != '') {
526 526
 				$this->all_tracked[$id]['id'] = $recent_ident;
527 527
 				$this->all_tracked[$id]['addedMarine'] = 1;
528 528
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
529
-				    if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) {
529
+					if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) {
530 530
 					$Marine = new Marine($this->db);
531 531
 					if (isset($globalVM) && $globalVM) {
532
-					    if ($this->all_tracked[$id]['status'] == 'Racing') {
532
+						if ($this->all_tracked[$id]['status'] == 'Racing') {
533 533
 						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
534
-					    } else {
534
+						} else {
535 535
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536 536
 						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
537 537
 						if ($timerace > time()) $finaldatetime = NULL;
538 538
 						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
539 539
 
540 540
 						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
541
-					    }
541
+						}
542 542
 					} else {
543
-					    $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
543
+						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
544 544
 					}
545 545
 					$Marine->db = null;
546
-				    }
546
+					}
547 547
 				}
548 548
 				
549
-			    }
549
+				}
550 550
 			}
551
-		    }
552
-		    //adds the spotter LIVE data
553
-		    if ($globalDebug) {
551
+			}
552
+			//adds the spotter LIVE data
553
+			if ($globalDebug) {
554 554
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
555
-		    }
556
-		    $ignoreImport = false;
557
-		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
558
-		    if (!$ignoreImport) {
555
+			}
556
+			$ignoreImport = false;
557
+			if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
558
+			if (!$ignoreImport) {
559 559
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
560 560
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
561 561
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
562
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 563
 					$timeelapsed = microtime(true);
564 564
 					$MarineLive = new MarineLive($this->db);
565 565
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
566 566
 					$MarineLive->db = null;
567 567
 					if ($globalDebug) echo $result."\n";
568 568
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
569
-				    }
569
+					}
570 570
 				}
571 571
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
572 572
 					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 					if ($stats_heading == 16) $stats_heading = 0;
602 602
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603 603
 						for ($i=0;$i<=15;$i++) {
604
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
604
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
605 605
 						}
606 606
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
607 607
 					} else {
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
 					//var_dump($this->stats);
615 615
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
616 616
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617
-						    end($this->stats[$current_date][$source]['hist']);
618
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
617
+							end($this->stats[$current_date][$source]['hist']);
618
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
619 619
 						} else $mini = 0;
620 620
 						for ($i=$mini;$i<=$distance;$i+=10) {
621
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
621
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
622 622
 						}
623 623
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
624 624
 					} else {
@@ -634,30 +634,30 @@  discard block
 block discarded – undo
634 634
 			
635 635
 			
636 636
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
637
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
637
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
638 638
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
639 639
 				$MarineLive = new MarineLive($this->db);
640 640
 				$MarineLive->deleteLiveMarineDataNotUpdated();
641 641
 				$MarineLive->db = null;
642 642
 				//MarineLive->deleteLiveMarineData();
643 643
 				if ($globalDebug) echo " Done\n";
644
-			    }
645
-			    $this->last_delete_hourly = time();
644
+				}
645
+				$this->last_delete_hourly = time();
646 646
 			}
647 647
 			
648
-		    }
649
-		    //$ignoreImport = false;
648
+			}
649
+			//$ignoreImport = false;
650 650
 		}
651 651
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
652 652
 		if ($send) return $this->all_tracked[$id];
653
-	    }
653
+		}
654
+	}
654 655
 	}
655
-    }
656 656
     
657
-    public function race_add($data) {
658
-        $Marine = new Marine();
659
-        $Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']);
660
-        $Marine->db = null;
661
-    }
657
+	public function race_add($data) {
658
+		$Marine = new Marine();
659
+		$Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']);
660
+		$Marine->db = null;
661
+	}
662 662
 }
663 663
 ?>
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
     		    $Marine = new Marine($this->db);
69 69
     		    if (isset($globalVM) && $globalVM) {
70 70
 			if ($this->all_tracked[$key]['status'] == 'Racing') {
71
-    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
71
+    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
72 72
     			} else {
73
-    			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
73
+    			    $timerace = (strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time']);
74 74
     			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
-    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
75
+    			    else $finaldatetime = date('Y-m-d H:i:s', $timerace);
76
+    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $finaldatetime, $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
77 77
     			}
78 78
     		    } else {
79
-			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
79
+			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
80 80
 		    }
81 81
 		}
82 82
 	    }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
90 90
 	foreach ($this->all_tracked as $key => $flight) {
91 91
     	    if (isset($flight['lastupdate'])) {
92
-        	if ($flight['lastupdate'] < (time()-3000)) {
92
+        	if ($flight['lastupdate'] < (time() - 3000)) {
93 93
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94 94
             		if (isset($this->all_tracked[$key]['id'])) {
95 95
             		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
104 104
 				if (isset($globalVM) && $globalVM) {
105 105
 				    if ($this->all_tracked[$key]['status'] == 'Racing') {
106
-					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
106
+					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
107 107
 				    } else {
108
-					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
108
+					$timerace = strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time'];
109 109
 	        			if ($timerace > time()) $finaldatetime = NULL;
110
-					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
111
-					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
110
+					else $finaldatetime = date('Y-m-d H:i:s', $timerace);
111
+					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $finaldatetime, $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
112 112
 				    }
113 113
 				} else {
114
-					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
114
+					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
115 115
 				}
116 116
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
117 117
 			    }
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
     }
127 127
 
128 128
     public function add($line) {
129
-	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM;
129
+	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine, $globalLiveInterval, $globalVM;
130 130
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
131 131
 	date_default_timezone_set('UTC');
132 132
 	$dataFound = false;
133 133
 	$send = false;
134 134
 	
135 135
 	// SBS format is CSV format
136
-	if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
136
+	if (is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
137 137
 	    //print_r($line);
138 138
   	    if (isset($line['mmsi']) || isset($line['id'])) {
139 139
 
@@ -158,25 +158,25 @@  discard block
 block discarded – undo
158 158
 		
159 159
 		if (!isset($this->all_tracked[$id])) {
160 160
 		    $this->all_tracked[$id] = array();
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
162
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
161
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
162
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '', 'captain_id' => '', 'captain_name' => '', 'race_id' => '', 'race_name' => '', 'distance' => NULL, 'race_rank' => NULL, 'race_time' => NULL, 'race_begin' => ''));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
164 164
 		    if (!isset($line['id'])) {
165 165
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
166
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
167
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
168 168
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
169 169
 		}
170 170
 		
171 171
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
172
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
173 173
 		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
174 174
 			$Marine = new Marine($this->db);
175 175
 			$identity = $Marine->getIdentity($line['mmsi']);
176 176
 			if (!empty($identity)) {
177 177
 			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
178 178
 			    $this->all_tracked[$id]['type'] = $identity['type'];
179
-			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
179
+			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($identity['type'])));
180 180
 			}
181 181
 			//print_r($identity);
182 182
 			unset($Marine);
@@ -184,25 +184,25 @@  discard block
 block discarded – undo
184 184
 		    }
185 185
 		}
186 186
 		if (isset($line['type_id'])) {
187
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
188
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
187
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
188
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id']));
189 189
 		}
190 190
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
191
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
192
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
191
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
192
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type'])));
193 193
 		} elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') {
194
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
194
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
195 195
 		}
196 196
 		if (isset($line['status']) && $line['status'] != '') {
197
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
197
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
198 198
 		}
199 199
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
200
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
200
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id']));
201 201
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
202 202
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
203 203
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
204 204
 				$Marine = new Marine($this->db);
205
-				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
205
+				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']);
206 206
 				unset($Marine);
207 207
 			    }
208 208
 			}
@@ -211,24 +211,24 @@  discard block
 block discarded – undo
211 211
 
212 212
 
213 213
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
214
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
214
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
215 215
 		}
216 216
 		if (isset($line['imo']) && $line['imo'] != '') {
217
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
217
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
218 218
 		}
219 219
 		if (isset($line['callsign']) && $line['callsign'] != '') {
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
220
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
221 221
 		}
222 222
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223 223
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
224
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
224
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
225 225
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
226 226
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227 227
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 228
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
229 229
 				    $Marine = new Marine($this->db);
230 230
 				    $fromsource = NULL;
231
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
231
+				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource);
232 232
 				    $Marine->db = null;
233 233
 				}
234 234
 			    }
@@ -244,31 +244,31 @@  discard block
 block discarded – undo
244 244
 		    }
245 245
 		}
246 246
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
247
+		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
248 248
 		}
249 249
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
250
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_id' => $line['captain_id']));
251 251
 		}
252 252
 		if (isset($line['captain_name']) && $line['captain_name'] != '') {
253
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
253
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_name' => $line['captain_name']));
254 254
 		}
255 255
 		if (isset($line['race_id']) && $line['race_id'] != '') {
256
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
256
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_id' => $line['race_id']));
257 257
 		}
258 258
 		if (isset($line['race_name']) && $line['race_name'] != '') {
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
259
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_name' => $line['race_name']));
260 260
 		}
261 261
 		if (isset($line['race_rank']) && $line['race_rank'] != '') {
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank']));
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_rank' => $line['race_rank']));
263 263
 		}
264 264
 		if (isset($line['race_time']) && $line['race_time'] != '') {
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time']));
265
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_time' => $line['race_time']));
266 266
 		}
267 267
 		if (isset($line['race_begin']) && $line['race_begin'] != '') {
268
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin']));
268
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_begin' => $line['race_begin']));
269 269
 		}
270 270
 		if (isset($line['distance']) && $line['distance'] != '') {
271
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance']));
271
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('distance' => $line['distance']));
272 272
 		}
273 273
 
274 274
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
@@ -277,44 +277,44 @@  discard block
 block discarded – undo
277 277
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
278 278
 			    $timeelapsed = microtime(true);
279 279
 			    $Marine = new Marine($this->db);
280
-			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
280
+			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']);
281 281
 			    $Marine->db = null;
282 282
 			}
283 283
 		    }
284
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
284
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
285 285
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
286 286
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
287 287
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
288 288
 				$timeelapsed = microtime(true);
289 289
 				$Marine = new Marine($this->db);
290 290
 				$fromsource = NULL;
291
-				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
291
+				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
292 292
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
293 293
 				$Marine->db = null;
294
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
294
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
295 295
 			    }
296 296
 			}
297 297
 		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
298
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
299 299
 		}
300 300
 
301
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
301
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) {
302 302
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
303
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
304 304
 		    } else {
305 305
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
306 306
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
307 307
 				return '';
308 308
 		    }
309
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
309
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) {
310 310
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
311 311
 			return '';
312
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
312
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) {
313 313
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
314 314
 			return '';
315 315
 		} elseif (!isset($line['datetime'])) {
316 316
 			date_default_timezone_set('UTC');
317
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
317
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
318 318
 		} else {
319 319
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
320 320
 			return '';
@@ -322,20 +322,20 @@  discard block
 block discarded – undo
322 322
 
323 323
 
324 324
 		if (isset($line['speed'])) {
325
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2)));
326
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
325
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'], 2)));
326
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
327 327
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
328
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
328
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
329 329
 		    if ($distance > 1000 && $distance < 10000) {
330 330
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 331
 			$speed = $speed*3.6;
332
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
332
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed, 2)));
333 333
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
334 334
 		    }
335 335
 		}
336 336
 
337 337
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
338
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
339 339
 	    	    else unset($timediff);
340 340
 	    	    if ($this->tmd > 5 ||
341 341
 	    		!isset($timediff) ||
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 	    		    $timediff > 30 && 
345 345
 	    		    isset($this->all_tracked[$id]['latitude']) &&
346 346
 	    		    isset($this->all_tracked[$id]['longitude']) &&
347
-	    		    $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
347
+	    		    $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'))
348 348
 	    		)
349 349
 	    		) {
350 350
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
351
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
351
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
352 352
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
353 353
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 354
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 				$timeelapsed = microtime(true);
358 358
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359 359
 				    $Marine = new Marine($this->db);
360
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
360
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
361 361
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
362 362
 				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
363
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
364 364
 				}
365 365
 				$this->tmd = 0;
366 366
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -369,55 +369,55 @@  discard block
 block discarded – undo
369 369
 
370 370
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371 371
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
372
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
372
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
373 373
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374 374
 				    $dataFound = true;
375 375
 				    $this->all_tracked[$id]['time_last_coord'] = time();
376 376
 				}
377
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
377
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
378 378
 			}
379 379
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380 380
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381 381
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
382
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
382
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
383 383
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384 384
 				    $dataFound = true;
385 385
 				    $this->all_tracked[$id]['time_last_coord'] = time();
386 386
 				}
387
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
387
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
388 388
 			}
389 389
 
390 390
 		    } else if ($globalDebug && $timediff > 20) {
391 391
 			$this->tmd = $this->tmd + 1;
392 392
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
393
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
394
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
393
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
394
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
395 395
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
396 396
 		    }
397 397
 		}
398 398
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399 399
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
400
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
400
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
401 401
 		}
402 402
 		if (isset($line['format_source']) && $line['format_source'] != '') {
403
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
403
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
404 404
 		}
405 405
 		if (isset($line['source_name']) && $line['source_name'] != '') {
406
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
406
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
407 407
 		}
408 408
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
409
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
409
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
410 410
 		}
411 411
 		
412 412
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
413
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
415
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
416 416
 		    //$dataFound = true;
417 417
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
418
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
419
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
418
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
419
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
420
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421 421
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
422 422
   		}
423 423
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) {
428 428
 		    $this->all_tracked[$id]['lastupdate'] = time();
429 429
 		    if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) {
430
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
430
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
431 431
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 432
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433 433
 				    if ($globalDebug) echo "Check if vessel is already in DB...";
@@ -436,28 +436,28 @@  discard block
 block discarded – undo
436 436
 				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 437
 					$Marine = new Marine($this->db);
438 438
 					$recent_ident = $Marine->checkId($line['id']);
439
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
440
-					$Marine->db=null;
439
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
440
+					$Marine->db = null;
441 441
 				    } elseif (isset($line['id'])) {
442 442
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
443
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
444 444
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 445
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
446
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
447 447
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 448
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
449
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
450 450
 				    } else $recent_ident = '';
451
-				    $MarineLive->db=null;
451
+				    $MarineLive->db = null;
452 452
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453 453
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454 454
 				} else $recent_ident = '';
455 455
 			    } else {
456 456
 				$recent_ident = '';
457
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
457
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
458 458
 			    }
459 459
 			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
460
-			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
460
+			    if ($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461 461
 			    {
462 462
 				if ($globalDebug) {
463 463
 					if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
@@ -465,19 +465,19 @@  discard block
 block discarded – undo
465 465
 				}
466 466
 				//adds the spotter data for the archive
467 467
 				    $highlight = '';
468
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
468
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
469 469
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 470
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471 471
 					    $timeelapsed = microtime(true);
472 472
 					    $Marine = new Marine($this->db);
473 473
 					    if (isset($globalVM) && $globalVM && $this->all_tracked[$id]['race_begin'] != '') {
474
-						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['race_begin'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
474
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['race_begin'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']);
475 475
 					    } else {
476
-						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
476
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']);
477 477
 					    }
478 478
 					    $Marine->db = null;
479 479
 					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
480
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
481 481
 					}
482 482
 				    }
483 483
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
 					$Stats = new Stats($this->db);
486 486
 					if (!empty($this->stats)) {
487 487
 					    if ($globalDebug) echo 'Add source stats : ';
488
-				    	    foreach($this->stats as $date => $data) {
489
-						foreach($data as $source => $sourced) {
488
+				    	    foreach ($this->stats as $date => $data) {
489
+						foreach ($data as $source => $sourced) {
490 490
 					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
491
+				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date);
492
+				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date);
493 493
 				    		    if (isset($sourced['msg'])) {
494 494
 				    			if (time() - $sourced['msg']['date'] > 10) {
495 495
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
496
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
496
+				    		    	    echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date);
497 497
 			    			    	    unset($this->stats[$date][$source]['msg']);
498 498
 			    				}
499 499
 			    			    }
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 518
 					$MarineLive = new MarineLive($this->db);
519 519
 					$MarineLive->deleteLiveMarineData();
520
-					$MarineLive->db=null;
520
+					$MarineLive->db = null;
521 521
 					if ($globalDebug) echo " Done\n";
522 522
 				    }
523 523
 				    $this->last_delete = time();
@@ -530,17 +530,17 @@  discard block
 block discarded – undo
530 530
 					$Marine = new Marine($this->db);
531 531
 					if (isset($globalVM) && $globalVM) {
532 532
 					    if ($this->all_tracked[$id]['status'] == 'Racing') {
533
-						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
533
+						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']);
534 534
 					    } else {
535 535
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536
-						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536
+						$timerace = (strtotime($this->all_tracked[$id]['race_begin']) + $this->all_tracked[$id]['race_time']);
537 537
 						if ($timerace > time()) $finaldatetime = NULL;
538
-						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
538
+						else $finaldatetime = date('Y-m-d H:i:s', $timerace);
539 539
 
540
-						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
540
+						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $finaldatetime, $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']);
541 541
 					    }
542 542
 					} else {
543
-					    $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
543
+					    $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']);
544 544
 					}
545 545
 					$Marine->db = null;
546 546
 				    }
@@ -556,20 +556,20 @@  discard block
 block discarded – undo
556 556
 		    $ignoreImport = false;
557 557
 		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
558 558
 		    if (!$ignoreImport) {
559
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
559
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
560 560
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
561 561
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562 562
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 563
 					$timeelapsed = microtime(true);
564 564
 					$MarineLive = new MarineLive($this->db);
565
-					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
565
+					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']);
566 566
 					$MarineLive->db = null;
567 567
 					if ($globalDebug) echo $result."\n";
568
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
568
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
569 569
 				    }
570 570
 				}
571 571
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
572
-					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
572
+					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
573 573
 				}
574 574
 				$this->all_tracked[$id]['putinarchive'] = false;
575 575
 
@@ -588,19 +588,19 @@  discard block
 block discarded – undo
588 588
 							$latitude = $globalCenterLatitude;
589 589
 							$longitude = $globalCenterLongitude;
590 590
 						}
591
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
591
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
592 592
 					} else {
593 593
 						$latitude = $this->source_location[$source]['latitude'];
594 594
 						$longitude = $this->source_location[$source]['longitude'];
595 595
 					}
596
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
596
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
597 597
 					//$stats_heading = $stats_heading%22.5;
598 598
 					$stats_heading = round($stats_heading/22.5);
599
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
599
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
600 600
 					$current_date = date('Y-m-d');
601 601
 					if ($stats_heading == 16) $stats_heading = 0;
602 602
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603
-						for ($i=0;$i<=15;$i++) {
603
+						for ($i = 0; $i <= 15; $i++) {
604 604
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
605 605
 						}
606 606
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -615,9 +615,9 @@  discard block
 block discarded – undo
615 615
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
616 616
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617 617
 						    end($this->stats[$current_date][$source]['hist']);
618
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
618
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
619 619
 						} else $mini = 0;
620
-						for ($i=$mini;$i<=$distance;$i+=10) {
620
+						for ($i = $mini; $i <= $distance; $i += 10) {
621 621
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
622 622
 						}
623 623
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 
630 630
 				$this->all_tracked[$id]['lastupdate'] = time();
631 631
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
632
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
632
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
633 633
 			//$this->del();
634 634
 			
635 635
 			
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
     
657 657
     public function race_add($data) {
658 658
         $Marine = new Marine();
659
-        $Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']);
659
+        $Marine->addRace($data['id'], $data['name'], $data['creator'], $data['desc'], $data['startdate'], $data['markers']);
660 660
         $Marine->db = null;
661 661
     }
662 662
 }
Please login to merge, or discard this patch.
Braces   +225 added lines, -78 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@  discard block
 block discarded – undo
61 61
     public function checkAll() {
62 62
 	global $globalDebug, $globalNoDB, $globalVM;
63 63
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
64
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
64
+	    if ($globalDebug) {
65
+	    	echo "Update last seen tracked data...\n";
66
+	    }
65 67
 	    foreach ($this->all_tracked as $key => $flight) {
66 68
 		if (isset($this->all_tracked[$key]['id'])) {
67 69
 		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -71,8 +73,11 @@  discard block
 block discarded – undo
71 73
     			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72 74
     			} else {
73 75
     			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
-    			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
+    			    if ($timerace > time()) {
77
+    			    	$finaldatetime = NULL;
78
+    			    } else {
79
+    			    	$finaldatetime = date('Y-m-d H:i:s',$timerace);
80
+    			    }
76 81
     			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77 82
     			}
78 83
     		    } else {
@@ -86,13 +91,17 @@  discard block
 block discarded – undo
86 91
     public function del() {
87 92
 	global $globalDebug, $globalNoDB, $globalNoImport;
88 93
 	// Delete old infos
89
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
94
+	if ($globalDebug) {
95
+		echo 'Delete old values and update latest data...'."\n";
96
+	}
90 97
 	foreach ($this->all_tracked as $key => $flight) {
91 98
     	    if (isset($flight['lastupdate'])) {
92 99
         	if ($flight['lastupdate'] < (time()-3000)) {
93 100
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94 101
             		if (isset($this->all_tracked[$key]['id'])) {
95
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
102
+            		    if ($globalDebug) {
103
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
104
+            		    }
96 105
 			    /*
97 106
 			    $MarineLive = new MarineLive();
98 107
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -106,14 +115,19 @@  discard block
 block discarded – undo
106 115
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
107 116
 				    } else {
108 117
 					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
109
-	        			if ($timerace > time()) $finaldatetime = NULL;
110
-					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
118
+	        			if ($timerace > time()) {
119
+	        				$finaldatetime = NULL;
120
+	        			} else {
121
+						$finaldatetime = date('Y-m-d H:i:s',$timerace);
122
+					}
111 123
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
112 124
 				    }
113 125
 				} else {
114 126
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
115 127
 				}
116
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
128
+				if ($globalDebug && $result != 'success') {
129
+					echo '!!! ERROR : '.$result."\n";
130
+				}
117 131
 			    }
118 132
 			    // Put in archive
119 133
 //				$Marine->db = null;
@@ -127,7 +141,9 @@  discard block
 block discarded – undo
127 141
 
128 142
     public function add($line) {
129 143
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM;
130
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
144
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
145
+		$globalCoordMinChange = '0.02';
146
+	}
131 147
 	date_default_timezone_set('UTC');
132 148
 	$dataFound = false;
133 149
 	$send = false;
@@ -141,20 +157,30 @@  discard block
 block discarded – undo
141 157
 		// Increment message number
142 158
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
143 159
 		    $current_date = date('Y-m-d');
144
-		    if (isset($line['source_name'])) $source = $line['source_name'];
145
-		    else $source = '';
146
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
160
+		    if (isset($line['source_name'])) {
161
+		    	$source = $line['source_name'];
162
+		    } else {
163
+		    	$source = '';
164
+		    }
165
+		    if ($source == '' || $line['format_source'] == 'aprs') {
166
+		    	$source = $line['format_source'];
167
+		    }
147 168
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
148 169
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
149 170
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
171
+		    } else {
172
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
173
+		    }
151 174
 		}
152 175
 		
153 176
 		
154 177
 		$Common = new Common();
155 178
 		$AIS = new AIS();
156
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
157
-	        else $id = trim($line['id']);
179
+	        if (!isset($line['id'])) {
180
+	        	$id = trim($line['mmsi']);
181
+	        } else {
182
+	        	$id = trim($line['id']);
183
+	        }
158 184
 		
159 185
 		if (!isset($this->all_tracked[$id])) {
160 186
 		    $this->all_tracked[$id] = array();
@@ -162,10 +188,16 @@  discard block
 block discarded – undo
162 188
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163 189
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164 190
 		    if (!isset($line['id'])) {
165
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
191
+			if (!isset($globalDaemon)) {
192
+				$globalDaemon = TRUE;
193
+			}
166 194
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
195
+		     } else {
196
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
197
+		     }
198
+		    if ($globalAllTracked !== FALSE) {
199
+		    	$dataFound = true;
200
+		    }
169 201
 		}
170 202
 		
171 203
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -222,7 +254,9 @@  discard block
 block discarded – undo
222 254
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223 255
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
224 256
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
225
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
257
+			if ($globalDebug) {
258
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
259
+			}
226 260
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227 261
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 262
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -235,7 +269,9 @@  discard block
 block discarded – undo
235 269
 			}
236 270
 		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
237 271
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
238
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
272
+			if ($globalDebug) {
273
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
274
+			}
239 275
 			if (!isset($line['id'])) {
240 276
 				$this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi');
241 277
 				$this->all_tracked[$id]['forcenew'] = 1;
@@ -244,7 +280,9 @@  discard block
 block discarded – undo
244 280
 		    }
245 281
 		}
246 282
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
283
+		    if (strtotime($line['arrival_date']) > time()) {
284
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
285
+		    }
248 286
 		}
249 287
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250 288
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
@@ -289,34 +327,49 @@  discard block
 block discarded – undo
289 327
 				$Marine = new Marine($this->db);
290 328
 				$fromsource = NULL;
291 329
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
292
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
330
+				if ($globalDebug && $result != 'success') {
331
+					echo '!!! ERROR : '.$result."\n";
332
+				}
293 333
 				$Marine->db = null;
294
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
334
+				if ($globalDebugTimeElapsed) {
335
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
336
+				}
295 337
 			    }
296 338
 			}
297 339
 		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
340
+		    if (!isset($this->all_tracked[$id]['id'])) {
341
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
342
+		    }
299 343
 		}
300 344
 
301 345
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
302 346
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303 347
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
304 348
 		    } else {
305
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
306
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
349
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
350
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
351
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
352
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
353
+				}
307 354
 				return '';
308 355
 		    }
309 356
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
310
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
357
+			if ($globalDebug) {
358
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
359
+			}
311 360
 			return '';
312 361
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
313
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
362
+			if ($globalDebug) {
363
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
364
+			}
314 365
 			return '';
315 366
 		} elseif (!isset($line['datetime'])) {
316 367
 			date_default_timezone_set('UTC');
317 368
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
318 369
 		} else {
319
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
370
+			if ($globalDebug) {
371
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
372
+			}
320 373
 			return '';
321 374
 		}
322 375
 
@@ -329,14 +382,21 @@  discard block
 block discarded – undo
329 382
 		    if ($distance > 1000 && $distance < 10000) {
330 383
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 384
 			$speed = $speed*3.6;
332
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
333
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
385
+			if ($speed < 1000) {
386
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
387
+			}
388
+  			if ($globalDebug) {
389
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
390
+  			}
334 391
 		    }
335 392
 		}
336 393
 
337 394
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
-	    	    else unset($timediff);
395
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
396
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
397
+	    	    } else {
398
+	    	    	unset($timediff);
399
+	    	    }
340 400
 	    	    if ($this->tmd > 5 ||
341 401
 	    		!isset($timediff) ||
342 402
 	    		$timediff > $globalLiveInterval ||
@@ -353,22 +413,32 @@  discard block
 block discarded – undo
353 413
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 414
 				$this->all_tracked[$id]['putinarchive'] = true;
355 415
 				
356
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
416
+				if ($globalDebug) {
417
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
418
+				}
357 419
 				$timeelapsed = microtime(true);
358 420
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359 421
 				    $Marine = new Marine($this->db);
360 422
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
423
+				    if (!empty($all_country)) {
424
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
425
+				    }
362 426
 				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
427
+				    if ($globalDebugTimeElapsed) {
428
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
429
+				    }
364 430
 				}
365 431
 				$this->tmd = 0;
366
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
432
+				if ($globalDebug) {
433
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
434
+				}
367 435
 			    }
368 436
 			}
369 437
 
370 438
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
439
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
440
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
441
+				}
372 442
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
373 443
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374 444
 				    $dataFound = true;
@@ -377,8 +447,12 @@  discard block
 block discarded – undo
377 447
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
378 448
 			}
379 449
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
450
+			    if ($line['longitude'] > 180) {
451
+			    	$line['longitude'] = $line['longitude'] - 360;
452
+			    }
453
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
454
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
455
+				}
382 456
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
383 457
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384 458
 				    $dataFound = true;
@@ -396,7 +470,9 @@  discard block
 block discarded – undo
396 470
 		    }
397 471
 		}
398 472
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
473
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
474
+		    	$dataFound = true;
475
+		    }
400 476
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
401 477
 		}
402 478
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -410,15 +486,21 @@  discard block
 block discarded – undo
410 486
 		}
411 487
 		
412 488
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
489
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
490
+		    	$this->all_tracked[$id]['putinarchive'] = true;
491
+		    }
414 492
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415 493
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416 494
 		    //$dataFound = true;
417 495
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
418 496
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
419 497
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
498
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
499
+		    	$this->all_tracked[$id]['putinarchive'] = true;
500
+		    }
501
+  		    if ($globalDebug) {
502
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
503
+  		    }
422 504
   		}
423 505
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
424 506
 
@@ -430,28 +512,45 @@  discard block
 block discarded – undo
430 512
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
431 513
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 514
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
515
+				    if ($globalDebug) {
516
+				    	echo "Check if vessel is already in DB...";
517
+				    }
434 518
 				    $timeelapsed = microtime(true);
435 519
 				    $MarineLive = new MarineLive($this->db);
436 520
 				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 521
 					$Marine = new Marine($this->db);
438 522
 					$recent_ident = $Marine->checkId($line['id']);
439
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
523
+					if ($globalDebugTimeElapsed) {
524
+						echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
525
+					}
440 526
 					$Marine->db=null;
441 527
 				    } elseif (isset($line['id'])) {
442 528
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
529
+					if ($globalDebugTimeElapsed) {
530
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
531
+					}
444 532
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 533
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
534
+					if ($globalDebugTimeElapsed) {
535
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
536
+					}
447 537
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 538
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
450
-				    } else $recent_ident = '';
539
+					if ($globalDebugTimeElapsed) {
540
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
541
+					}
542
+				    } else {
543
+				    	$recent_ident = '';
544
+				    }
451 545
 				    $MarineLive->db=null;
452
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454
-				} else $recent_ident = '';
546
+				    if ($globalDebug && $recent_ident == '') {
547
+				    	echo " Not in DB.\n";
548
+				    } elseif ($globalDebug && $recent_ident != '') {
549
+				    	echo " Already in DB.\n";
550
+				    }
551
+				} else {
552
+					$recent_ident = '';
553
+				}
455 554
 			    } else {
456 555
 				$recent_ident = '';
457 556
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -460,12 +559,17 @@  discard block
 block discarded – undo
460 559
 			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461 560
 			    {
462 561
 				if ($globalDebug) {
463
-					if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
464
-					else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
562
+					if ($this->all_tracked[$id]['mmsi'] == '') {
563
+						echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
564
+					} else {
565
+						echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
566
+					}
465 567
 				}
466 568
 				//adds the spotter data for the archive
467 569
 				    $highlight = '';
468
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
570
+				    if (!isset($this->all_tracked[$id]['id'])) {
571
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
572
+				    }
469 573
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 574
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471 575
 					    $timeelapsed = microtime(true);
@@ -476,20 +580,30 @@  discard block
 block discarded – undo
476 580
 						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
477 581
 					    }
478 582
 					    $Marine->db = null;
479
-					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
583
+					    if ($globalDebug && isset($result)) {
584
+					    	echo $result."\n";
585
+					    }
586
+					    if ($globalDebugTimeElapsed) {
587
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
588
+					    }
481 589
 					}
482 590
 				    }
483 591
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
484 592
 					// Add source stat in DB
485 593
 					$Stats = new Stats($this->db);
486 594
 					if (!empty($this->stats)) {
487
-					    if ($globalDebug) echo 'Add source stats : ';
595
+					    if ($globalDebug) {
596
+					    	echo 'Add source stats : ';
597
+					    }
488 598
 				    	    foreach($this->stats as $date => $data) {
489 599
 						foreach($data as $source => $sourced) {
490 600
 					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
601
+				    	    	    if (isset($sourced['polar'])) {
602
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
603
+				    	    	    }
604
+				    	    	    if (isset($sourced['hist'])) {
605
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
606
+				    	    	    }
493 607
 				    		    if (isset($sourced['msg'])) {
494 608
 				    			if (time() - $sourced['msg']['date'] > 10) {
495 609
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -502,7 +616,9 @@  discard block
 block discarded – undo
502 616
 			    			    unset($this->stats[$date]);
503 617
 			    			}
504 618
 				    	    }
505
-				    	    if ($globalDebug) echo 'Done'."\n";
619
+				    	    if ($globalDebug) {
620
+				    	    	echo 'Done'."\n";
621
+				    	    }
506 622
 					}
507 623
 					$Stats->db = null;
508 624
 				    }
@@ -512,13 +628,17 @@  discard block
 block discarded – undo
512 628
 				$this->all_tracked[$id]['addedMarine'] = 1;
513 629
 				//print_r($this->all_tracked[$id]);
514 630
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
515
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
631
+				    if ($globalDebug) {
632
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
633
+				    }
516 634
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
517 635
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 636
 					$MarineLive = new MarineLive($this->db);
519 637
 					$MarineLive->deleteLiveMarineData();
520 638
 					$MarineLive->db=null;
521
-					if ($globalDebug) echo " Done\n";
639
+					if ($globalDebug) {
640
+						echo " Done\n";
641
+					}
522 642
 				    }
523 643
 				    $this->last_delete = time();
524 644
 				}
@@ -534,8 +654,11 @@  discard block
 block discarded – undo
534 654
 					    } else {
535 655
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536 656
 						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
537
-						if ($timerace > time()) $finaldatetime = NULL;
538
-						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
657
+						if ($timerace > time()) {
658
+							$finaldatetime = NULL;
659
+						} else {
660
+							$finaldatetime = date('Y-m-d H:i:s',$timerace);
661
+						}
539 662
 
540 663
 						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
541 664
 					    }
@@ -554,18 +677,26 @@  discard block
 block discarded – undo
554 677
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
555 678
 		    }
556 679
 		    $ignoreImport = false;
557
-		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
680
+		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') {
681
+		    	$ignoreImport = true;
682
+		    }
558 683
 		    if (!$ignoreImport) {
559 684
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
560
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
685
+				if ($globalDebug) {
686
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
687
+				}
561 688
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562 689
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 690
 					$timeelapsed = microtime(true);
564 691
 					$MarineLive = new MarineLive($this->db);
565 692
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
566 693
 					$MarineLive->db = null;
567
-					if ($globalDebug) echo $result."\n";
568
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
694
+					if ($globalDebug) {
695
+						echo $result."\n";
696
+					}
697
+					if ($globalDebugTimeElapsed) {
698
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
699
+					}
569 700
 				    }
570 701
 				}
571 702
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -577,7 +708,9 @@  discard block
 block discarded – undo
577 708
 				
578 709
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
579 710
 					$source = $this->all_tracked[$id]['source_name'];
580
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
711
+					if ($source == '') {
712
+						$source = $this->all_tracked[$id]['format_source'];
713
+					}
581 714
 					if (!isset($this->source_location[$source])) {
582 715
 						$Location = new Source($this->db);
583 716
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -598,7 +731,9 @@  discard block
 block discarded – undo
598 731
 					$stats_heading = round($stats_heading/22.5);
599 732
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
600 733
 					$current_date = date('Y-m-d');
601
-					if ($stats_heading == 16) $stats_heading = 0;
734
+					if ($stats_heading == 16) {
735
+						$stats_heading = 0;
736
+					}
602 737
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603 738
 						for ($i=0;$i<=15;$i++) {
604 739
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -616,7 +751,9 @@  discard block
 block discarded – undo
616 751
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617 752
 						    end($this->stats[$current_date][$source]['hist']);
618 753
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
619
-						} else $mini = 0;
754
+						} else {
755
+							$mini = 0;
756
+						}
620 757
 						for ($i=$mini;$i<=$distance;$i+=10) {
621 758
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
622 759
 						}
@@ -628,19 +765,27 @@  discard block
 block discarded – undo
628 765
 				
629 766
 
630 767
 				$this->all_tracked[$id]['lastupdate'] = time();
631
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
632
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
768
+				if ($this->all_tracked[$id]['putinarchive']) {
769
+					$send = true;
770
+				}
771
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
772
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
773
+			}
633 774
 			//$this->del();
634 775
 			
635 776
 			
636 777
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
637 778
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
638
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
779
+				if ($globalDebug) {
780
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
781
+				}
639 782
 				$MarineLive = new MarineLive($this->db);
640 783
 				$MarineLive->deleteLiveMarineDataNotUpdated();
641 784
 				$MarineLive->db = null;
642 785
 				//MarineLive->deleteLiveMarineData();
643
-				if ($globalDebug) echo " Done\n";
786
+				if ($globalDebug) {
787
+					echo " Done\n";
788
+				}
644 789
 			    }
645 790
 			    $this->last_delete_hourly = time();
646 791
 			}
@@ -649,7 +794,9 @@  discard block
 block discarded – undo
649 794
 		    //$ignoreImport = false;
650 795
 		}
651 796
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
652
-		if ($send) return $this->all_tracked[$id];
797
+		if ($send) {
798
+			return $this->all_tracked[$id];
799
+		}
653 800
 	    }
654 801
 	}
655 802
     }
Please login to merge, or discard this patch.
require/class.Marine.php 3 patches
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
 	}
20 20
 
21 21
 	/**
22
-	* Get SQL query part for filter used
23
-	* @param Array $filter the filter
24
-	* @return Array the SQL part
25
-	*/
22
+	 * Get SQL query part for filter used
23
+	 * @param Array $filter the filter
24
+	 * @return Array the SQL part
25
+	 */
26 26
 	
27 27
 	public function getFilter($filter = array(),$where = false,$and = false) {
28 28
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	/**
98
-	* Executes the SQL statements to get the spotter information
99
-	*
100
-	* @param String $query the SQL query
101
-	* @param Array $params parameter of the query
102
-	* @param String $limitQuery the limit query
103
-	* @return Array the spotter information
104
-	*
105
-	*/
98
+	 * Executes the SQL statements to get the spotter information
99
+	 *
100
+	 * @param String $query the SQL query
101
+	 * @param Array $params parameter of the query
102
+	 * @param String $limitQuery the limit query
103
+	 * @return Array the spotter information
104
+	 *
105
+	 */
106 106
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
107 107
 	{
108 108
 		global $globalVM;
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 	
254 254
 	
255 255
 	/**
256
-	* Gets all the spotter information based on the latest data entry
257
-	*
258
-	* @return Array the spotter information
259
-	*
260
-	*/
256
+	 * Gets all the spotter information based on the latest data entry
257
+	 *
258
+	 * @return Array the spotter information
259
+	 *
260
+	 */
261 261
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
262 262
 	{
263 263
 		global $global_marine_query;
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 	}
307 307
 
308 308
 	/**
309
-	* Gets all the spotter information based on the callsign
310
-	*
311
-	* @return Array the spotter information
312
-	*
313
-	*/
309
+	 * Gets all the spotter information based on the callsign
310
+	 *
311
+	 * @return Array the spotter information
312
+	 *
313
+	 */
314 314
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
315 315
 	{
316 316
 		global $global_marine_query;
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
 	}
363 363
 
364 364
 	/**
365
-	* Gets all the marine information based on the type
366
-	*
367
-	* @return Array the marine information
368
-	*
369
-	*/
365
+	 * Gets all the marine information based on the type
366
+	 *
367
+	 * @return Array the marine information
368
+	 *
369
+	 */
370 370
 	public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array())
371 371
 	{
372 372
 		global $global_marine_query;
@@ -472,11 +472,11 @@  discard block
 block discarded – undo
472 472
 	}
473 473
 
474 474
 	/**
475
-	* Gets all the marine information based on the captain
476
-	*
477
-	* @return Array the marine information
478
-	*
479
-	*/
475
+	 * Gets all the marine information based on the captain
476
+	 *
477
+	 * @return Array the marine information
478
+	 *
479
+	 */
480 480
 	public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array())
481 481
 	{
482 482
 		global $global_marine_query;
@@ -515,11 +515,11 @@  discard block
 block discarded – undo
515 515
 	}
516 516
 
517 517
 	/**
518
-	* Gets all the marine information based on the race
519
-	*
520
-	* @return Array the marine information
521
-	*
522
-	*/
518
+	 * Gets all the marine information based on the race
519
+	 *
520
+	 * @return Array the marine information
521
+	 *
522
+	 */
523 523
 	public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array())
524 524
 	{
525 525
 		global $global_marine_query,$globalDBdriver;
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
 	}
563 563
 
564 564
 	/**
565
-	* Count races by captain
566
-	*
567
-	* @return Integer number of race for a captain
568
-	*
569
-	*/
565
+	 * Count races by captain
566
+	 *
567
+	 * @return Integer number of race for a captain
568
+	 *
569
+	 */
570 570
 	public function countRacesByCaptain($captain,$filters = array())
571 571
 	{
572 572
 		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
@@ -582,11 +582,11 @@  discard block
 block discarded – undo
582 582
 	}
583 583
 
584 584
 	/**
585
-	* Count captains by race
586
-	*
587
-	* @return String Duration of all races
588
-	*
589
-	*/
585
+	 * Count captains by race
586
+	 *
587
+	 * @return String Duration of all races
588
+	 *
589
+	 */
590 590
 	public function countCaptainsByRace($race,$filters = array())
591 591
 	{
592 592
 		$race = filter_var($race,FILTER_SANITIZE_STRING);
@@ -602,11 +602,11 @@  discard block
 block discarded – undo
602 602
 	}
603 603
 
604 604
 	/**
605
-	* Gets all boat types that have been used by a captain
606
-	*
607
-	* @return Array the boat list
608
-	*
609
-	*/
605
+	 * Gets all boat types that have been used by a captain
606
+	 *
607
+	 * @return Array the boat list
608
+	 *
609
+	 */
610 610
 	public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
611 611
 	{
612 612
 		global $globalDBdriver;
@@ -651,11 +651,11 @@  discard block
 block discarded – undo
651 651
 	}
652 652
 
653 653
 	/**
654
-	* Gets all boat types that have been used on a race
655
-	*
656
-	* @return Array the boat list
657
-	*
658
-	*/
654
+	 * Gets all boat types that have been used on a race
655
+	 *
656
+	 * @return Array the boat list
657
+	 *
658
+	 */
659 659
 	public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '')
660 660
 	{
661 661
 		global $globalDBdriver;
@@ -700,11 +700,11 @@  discard block
 block discarded – undo
700 700
 	}
701 701
 
702 702
 	/**
703
-	* Gets race duration by captain
704
-	*
705
-	* @return String Duration of all race
706
-	*
707
-	*/
703
+	 * Gets race duration by captain
704
+	 *
705
+	 * @return String Duration of all race
706
+	 *
707
+	 */
708 708
 	public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
709 709
 	{
710 710
 		global $globalDBdriver;
@@ -750,11 +750,11 @@  discard block
 block discarded – undo
750 750
 	}
751 751
 
752 752
 	/**
753
-	* Gets race duration by captains
754
-	*
755
-	* @return String Duration of all race
756
-	*
757
-	*/
753
+	 * Gets race duration by captains
754
+	 *
755
+	 * @return String Duration of all race
756
+	 *
757
+	 */
758 758
 	public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '')
759 759
 	{
760 760
 		global $globalDBdriver;
@@ -813,11 +813,11 @@  discard block
 block discarded – undo
813 813
 	}
814 814
 
815 815
 	/**
816
-	* Gets a list of all captain names and captain ids
817
-	*
818
-	* @return Array list of captain names and captain ids
819
-	*
820
-	*/
816
+	 * Gets a list of all captain names and captain ids
817
+	 *
818
+	 * @return Array list of captain names and captain ids
819
+	 *
820
+	 */
821 821
 	public function getAllCaptainNames($filters = array())
822 822
 	{
823 823
 		$filter_query = $this->getFilter($filters,true,true);
@@ -831,11 +831,11 @@  discard block
 block discarded – undo
831 831
 	} 
832 832
 
833 833
 	/**
834
-	* Gets a list of all race names and race ids
835
-	*
836
-	* @return Array list of race names and race ids
837
-	*
838
-	*/
834
+	 * Gets a list of all race names and race ids
835
+	 *
836
+	 * @return Array list of race names and race ids
837
+	 *
838
+	 */
839 839
 	public function getAllRaceNames($filters = array())
840 840
 	{
841 841
 		$filter_query = $this->getFilter($filters,true,true);
@@ -850,12 +850,12 @@  discard block
 block discarded – undo
850 850
 
851 851
 
852 852
 	/**
853
-	* Gets all source name
854
-	*
855
-	* @param String type format of source
856
-	* @return Array list of source name
857
-	*
858
-	*/
853
+	 * Gets all source name
854
+	 *
855
+	 * @param String type format of source
856
+	 * @return Array list of source name
857
+	 *
858
+	 */
859 859
 	public function getAllSourceName($type = '',$filters = array())
860 860
 	{
861 861
 		$filter_query = $this->getFilter($filters,true,true);
@@ -885,11 +885,11 @@  discard block
 block discarded – undo
885 885
 
886 886
 
887 887
 	/**
888
-	* Gets a list of all idents/callsigns
889
-	*
890
-	* @return Array list of ident/callsign names
891
-	*
892
-	*/
888
+	 * Gets a list of all idents/callsigns
889
+	 *
890
+	 * @return Array list of ident/callsign names
891
+	 *
892
+	 */
893 893
 	public function getAllIdents($filters = array())
894 894
 	{
895 895
 		$filter_query = $this->getFilter($filters,true,true);
@@ -913,11 +913,11 @@  discard block
 block discarded – undo
913 913
 	}
914 914
 
915 915
 	/**
916
-	* Gets all info from a mmsi
917
-	*
918
-	* @return Array ident
919
-	*
920
-	*/
916
+	 * Gets all info from a mmsi
917
+	 *
918
+	 * @return Array ident
919
+	 *
920
+	 */
921 921
 	public function getIdentity($mmsi)
922 922
 	{
923 923
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -930,9 +930,9 @@  discard block
 block discarded – undo
930 930
 	}
931 931
 
932 932
 	/**
933
-	* Add identity
934
-	*
935
-	*/
933
+	 * Add identity
934
+	 *
935
+	 */
936 936
 	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
937 937
 	{
938 938
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -998,13 +998,13 @@  discard block
 block discarded – undo
998 998
 	}
999 999
 
1000 1000
 	/**
1001
-	* Update ident tracker data
1002
-	*
1003
-	* @param String $fammarine_id the ID
1004
-	* @param String $ident the marine ident
1005
-	* @return String success or false
1006
-	*
1007
-	*/
1001
+	 * Update ident tracker data
1002
+	 *
1003
+	 * @param String $fammarine_id the ID
1004
+	 * @param String $ident the marine ident
1005
+	 * @return String success or false
1006
+	 *
1007
+	 */
1008 1008
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
1009 1009
 	{
1010 1010
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
@@ -1019,13 +1019,13 @@  discard block
 block discarded – undo
1019 1019
 	}
1020 1020
 
1021 1021
 	/**
1022
-	* Update arrival marine data
1023
-	*
1024
-	* @param String $fammarine_id the ID
1025
-	* @param String $arrival_code the marine ident
1026
-	* @return String success or false
1027
-	*
1028
-	*/
1022
+	 * Update arrival marine data
1023
+	 *
1024
+	 * @param String $fammarine_id the ID
1025
+	 * @param String $arrival_code the marine ident
1026
+	 * @return String success or false
1027
+	 *
1028
+	 */
1029 1029
 	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
1030 1030
 	{
1031 1031
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
@@ -1040,19 +1040,19 @@  discard block
 block discarded – undo
1040 1040
 	}
1041 1041
 
1042 1042
 	/**
1043
-	* Update Status data
1044
-	*
1045
-	* @param String $fammarine_id the ID
1046
-	* @param String $status_id the marine status id
1047
-	* @param String $status the marine status
1048
-	* @return String success or false
1049
-	*
1050
-	*/
1043
+	 * Update Status data
1044
+	 *
1045
+	 * @param String $fammarine_id the ID
1046
+	 * @param String $status_id the marine status id
1047
+	 * @param String $status the marine status
1048
+	 * @return String success or false
1049
+	 *
1050
+	 */
1051 1051
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
1052 1052
 	{
1053 1053
 
1054 1054
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
1055
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1055
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1056 1056
 
1057 1057
 		try {
1058 1058
 			$sth = $this->db->prepare($query);
@@ -1065,13 +1065,13 @@  discard block
 block discarded – undo
1065 1065
 
1066 1066
 	}
1067 1067
 	/**
1068
-	* Update latest marine data
1069
-	*
1070
-	* @param String $fammarine_id the ID
1071
-	* @param String $ident the marine ident
1072
-	* @return String success or false
1073
-	*
1074
-	*/	
1068
+	 * Update latest marine data
1069
+	 *
1070
+	 * @param String $fammarine_id the ID
1071
+	 * @param String $ident the marine ident
1072
+	 * @return String success or false
1073
+	 *
1074
+	 */	
1075 1075
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1076 1076
 	{
1077 1077
 		if ($latitude == '') $latitude = NULL;
@@ -1097,30 +1097,30 @@  discard block
 block discarded – undo
1097 1097
 	}
1098 1098
 
1099 1099
 	/**
1100
-	* Adds a new marine data
1101
-	*
1102
-	* @param String $fammarine_id the ID
1103
-	* @param String $ident the marine ident
1104
-	* @param String $departure_airport_icao the departure airport
1105
-	* @param String $arrival_airport_icao the arrival airport
1106
-	* @param String $latitude latitude of flight
1107
-	* @param String $longitude latitude of flight
1108
-	* @param String $waypoints waypoints of flight
1109
-	* @param String $heading heading of flight
1110
-	* @param String $groundspeed speed of flight
1111
-	* @param String $date date of flight
1112
-	* @param String $departure_airport_time departure time of flight
1113
-	* @param String $arrival_airport_time arrival time of flight
1114
-	* @param String $squawk squawk code of flight
1115
-	* @param String $route_stop route stop of flight
1116
-	* @param String $highlight highlight or not
1117
-	* @param String $ModeS ModesS code of flight
1118
-	* @param String $registration registration code of flight
1119
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
1120
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
1121
-	* @param String $verticalrate vertival rate of flight
1122
-	* @return String success or false
1123
-	*/
1100
+	 * Adds a new marine data
1101
+	 *
1102
+	 * @param String $fammarine_id the ID
1103
+	 * @param String $ident the marine ident
1104
+	 * @param String $departure_airport_icao the departure airport
1105
+	 * @param String $arrival_airport_icao the arrival airport
1106
+	 * @param String $latitude latitude of flight
1107
+	 * @param String $longitude latitude of flight
1108
+	 * @param String $waypoints waypoints of flight
1109
+	 * @param String $heading heading of flight
1110
+	 * @param String $groundspeed speed of flight
1111
+	 * @param String $date date of flight
1112
+	 * @param String $departure_airport_time departure time of flight
1113
+	 * @param String $arrival_airport_time arrival time of flight
1114
+	 * @param String $squawk squawk code of flight
1115
+	 * @param String $route_stop route stop of flight
1116
+	 * @param String $highlight highlight or not
1117
+	 * @param String $ModeS ModesS code of flight
1118
+	 * @param String $registration registration code of flight
1119
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
1120
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
1121
+	 * @param String $verticalrate vertival rate of flight
1122
+	 * @return String success or false
1123
+	 */
1124 1124
 	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 = '')
1125 1125
 	{
1126 1126
 		global $globalURL, $globalMarineImageFetch;
@@ -1254,11 +1254,11 @@  discard block
 block discarded – undo
1254 1254
 	
1255 1255
   
1256 1256
 	/**
1257
-	* Gets the aircraft ident within the last hour
1258
-	*
1259
-	* @return String the ident
1260
-	*
1261
-	*/
1257
+	 * Gets the aircraft ident within the last hour
1258
+	 *
1259
+	 * @return String the ident
1260
+	 *
1261
+	 */
1262 1262
 	public function getIdentFromLastHour($ident)
1263 1263
 	{
1264 1264
 		global $globalDBdriver, $globalTimezone;
@@ -1274,11 +1274,11 @@  discard block
 block discarded – undo
1274 1274
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
1275 1275
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
1276 1276
 			$query_data = array(':ident' => $ident);
1277
-    		}
1277
+			}
1278 1278
 		
1279 1279
 		$sth = $this->db->prepare($query);
1280 1280
 		$sth->execute($query_data);
1281
-    		$ident_result='';
1281
+			$ident_result='';
1282 1282
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1283 1283
 		{
1284 1284
 			$ident_result = $row['ident'];
@@ -1289,11 +1289,11 @@  discard block
 block discarded – undo
1289 1289
 	
1290 1290
 	
1291 1291
 	/**
1292
-	* Gets the aircraft data from the last 20 seconds
1293
-	*
1294
-	* @return Array the marine data
1295
-	*
1296
-	*/
1292
+	 * Gets the aircraft data from the last 20 seconds
1293
+	 *
1294
+	 * @return Array the marine data
1295
+	 *
1296
+	 */
1297 1297
 	public function getRealTimeData($q = '')
1298 1298
 	{
1299 1299
 		global $globalDBdriver;
@@ -1331,11 +1331,11 @@  discard block
 block discarded – undo
1331 1331
 	
1332 1332
 
1333 1333
 	/**
1334
-	* Gets all number of flight over countries
1335
-	*
1336
-	* @return Array the airline country list
1337
-	*
1338
-	*/
1334
+	 * Gets all number of flight over countries
1335
+	 *
1336
+	 * @return Array the airline country list
1337
+	 *
1338
+	 */
1339 1339
 
1340 1340
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1341 1341
 	{
@@ -1408,11 +1408,11 @@  discard block
 block discarded – undo
1408 1408
 	
1409 1409
 	
1410 1410
 	/**
1411
-	* Gets all callsigns that have flown over
1412
-	*
1413
-	* @return Array the callsign list
1414
-	*
1415
-	*/
1411
+	 * Gets all callsigns that have flown over
1412
+	 *
1413
+	 * @return Array the callsign list
1414
+	 *
1415
+	 */
1416 1416
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1417 1417
 	{
1418 1418
 		global $globalDBdriver;
@@ -1479,11 +1479,11 @@  discard block
 block discarded – undo
1479 1479
 
1480 1480
 
1481 1481
 	/**
1482
-	* Counts all dates
1483
-	*
1484
-	* @return Array the date list
1485
-	*
1486
-	*/
1482
+	 * Counts all dates
1483
+	 *
1484
+	 * @return Array the date list
1485
+	 *
1486
+	 */
1487 1487
 	public function countAllDates($filters = array())
1488 1488
 	{
1489 1489
 		global $globalTimezone, $globalDBdriver;
@@ -1529,11 +1529,11 @@  discard block
 block discarded – undo
1529 1529
 	
1530 1530
 	
1531 1531
 	/**
1532
-	* Counts all dates during the last 7 days
1533
-	*
1534
-	* @return Array the date list
1535
-	*
1536
-	*/
1532
+	 * Counts all dates during the last 7 days
1533
+	 *
1534
+	 * @return Array the date list
1535
+	 *
1536
+	 */
1537 1537
 	public function countAllDatesLast7Days($filters = array())
1538 1538
 	{
1539 1539
 		global $globalTimezone, $globalDBdriver;
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 			$query .= " GROUP BY date_name 
1556 1556
 								ORDER BY date_name ASC";
1557 1557
 			$query_data = array(':offset' => $offset);
1558
-    		}
1558
+			}
1559 1559
 		
1560 1560
 		$sth = $this->db->prepare($query);
1561 1561
 		$sth->execute($query_data);
@@ -1575,11 +1575,11 @@  discard block
 block discarded – undo
1575 1575
 	}
1576 1576
 
1577 1577
 	/**
1578
-	* Counts all dates during the last month
1579
-	*
1580
-	* @return Array the date list
1581
-	*
1582
-	*/
1578
+	 * Counts all dates during the last month
1579
+	 *
1580
+	 * @return Array the date list
1581
+	 *
1582
+	 */
1583 1583
 	public function countAllDatesLastMonth($filters = array())
1584 1584
 	{
1585 1585
 		global $globalTimezone, $globalDBdriver;
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
 			$query .= " GROUP BY date_name 
1602 1602
 								ORDER BY date_name ASC";
1603 1603
 			$query_data = array(':offset' => $offset);
1604
-    		}
1604
+			}
1605 1605
 		
1606 1606
 		$sth = $this->db->prepare($query);
1607 1607
 		$sth->execute($query_data);
@@ -1623,11 +1623,11 @@  discard block
 block discarded – undo
1623 1623
 
1624 1624
 
1625 1625
 	/**
1626
-	* Counts all month
1627
-	*
1628
-	* @return Array the month list
1629
-	*
1630
-	*/
1626
+	 * Counts all month
1627
+	 *
1628
+	 * @return Array the month list
1629
+	 *
1630
+	 */
1631 1631
 	public function countAllMonths($filters = array())
1632 1632
 	{
1633 1633
 		global $globalTimezone, $globalDBdriver;
@@ -1672,11 +1672,11 @@  discard block
 block discarded – undo
1672 1672
 	
1673 1673
 
1674 1674
 	/**
1675
-	* Counts all dates during the last year
1676
-	*
1677
-	* @return Array the date list
1678
-	*
1679
-	*/
1675
+	 * Counts all dates during the last year
1676
+	 *
1677
+	 * @return Array the date list
1678
+	 *
1679
+	 */
1680 1680
 	public function countAllMonthsLastYear($filters)
1681 1681
 	{
1682 1682
 		global $globalTimezone, $globalDBdriver;
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 			$query .= " GROUP BY year_name, month_name
1699 1699
 								ORDER BY year_name, month_name ASC";
1700 1700
 			$query_data = array(':offset' => $offset);
1701
-    		}
1701
+			}
1702 1702
 		
1703 1703
 		$sth = $this->db->prepare($query);
1704 1704
 		$sth->execute($query_data);
@@ -1721,11 +1721,11 @@  discard block
 block discarded – undo
1721 1721
 	
1722 1722
 	
1723 1723
 	/**
1724
-	* Counts all hours
1725
-	*
1726
-	* @return Array the hour list
1727
-	*
1728
-	*/
1724
+	 * Counts all hours
1725
+	 *
1726
+	 * @return Array the hour list
1727
+	 *
1728
+	 */
1729 1729
 	public function countAllHours($orderby,$filters = array())
1730 1730
 	{
1731 1731
 		global $globalTimezone, $globalDBdriver;
@@ -1788,11 +1788,11 @@  discard block
 block discarded – undo
1788 1788
 	
1789 1789
 	
1790 1790
 	/**
1791
-	* Counts all hours by date
1792
-	*
1793
-	* @return Array the hour list
1794
-	*
1795
-	*/
1791
+	 * Counts all hours by date
1792
+	 *
1793
+	 * @return Array the hour list
1794
+	 *
1795
+	 */
1796 1796
 	public function countAllHoursByDate($date, $filters = array())
1797 1797
 	{
1798 1798
 		global $globalTimezone, $globalDBdriver;
@@ -1836,11 +1836,11 @@  discard block
 block discarded – undo
1836 1836
 	
1837 1837
 	
1838 1838
 	/**
1839
-	* Counts all hours by a ident/callsign
1840
-	*
1841
-	* @return Array the hour list
1842
-	*
1843
-	*/
1839
+	 * Counts all hours by a ident/callsign
1840
+	 *
1841
+	 * @return Array the hour list
1842
+	 *
1843
+	 */
1844 1844
 	public function countAllHoursByIdent($ident, $filters = array())
1845 1845
 	{
1846 1846
 		global $globalTimezone, $globalDBdriver;
@@ -1883,11 +1883,11 @@  discard block
 block discarded – undo
1883 1883
 	}
1884 1884
 	
1885 1885
 	/**
1886
-	* Gets all aircraft registrations that have flown over
1887
-	*
1888
-	* @return Array the aircraft list
1889
-	*
1890
-	*/
1886
+	 * Gets all aircraft registrations that have flown over
1887
+	 *
1888
+	 * @return Array the aircraft list
1889
+	 *
1890
+	 */
1891 1891
 	public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1892 1892
 	{
1893 1893
 		global $globalDBdriver;
@@ -1926,11 +1926,11 @@  discard block
 block discarded – undo
1926 1926
 	}
1927 1927
 	
1928 1928
 	/**
1929
-	* Counts all vessels
1930
-	*
1931
-	* @return Integer the number of vessels
1932
-	*
1933
-	*/
1929
+	 * Counts all vessels
1930
+	 *
1931
+	 * @return Integer the number of vessels
1932
+	 *
1933
+	 */
1934 1934
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1935 1935
 	{
1936 1936
 		global $globalDBdriver;
@@ -1965,11 +1965,11 @@  discard block
 block discarded – undo
1965 1965
 	}
1966 1966
 	
1967 1967
 	/**
1968
-	* Counts all vessel type
1969
-	*
1970
-	* @return Integer the number of vessels
1971
-	*
1972
-	*/
1968
+	 * Counts all vessel type
1969
+	 *
1970
+	 * @return Integer the number of vessels
1971
+	 *
1972
+	 */
1973 1973
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1974 1974
 	{
1975 1975
 		global $globalDBdriver;
@@ -2003,11 +2003,11 @@  discard block
 block discarded – undo
2003 2003
 	}
2004 2004
 	
2005 2005
 	/**
2006
-	* Gets a number of all race
2007
-	*
2008
-	* @return Integer number of races
2009
-	*
2010
-	*/
2006
+	 * Gets a number of all race
2007
+	 *
2008
+	 * @return Integer number of races
2009
+	 *
2010
+	 */
2011 2011
 	public function countOverallMarineRaces($filters = array(),$year = '',$month = '')
2012 2012
 	{
2013 2013
 		global $globalDBdriver;
@@ -2041,11 +2041,11 @@  discard block
 block discarded – undo
2041 2041
 	}
2042 2042
   
2043 2043
 	/**
2044
-	* Gets a number of all captain
2045
-	*
2046
-	* @return Integer number of captain
2047
-	*
2048
-	*/
2044
+	 * Gets a number of all captain
2045
+	 *
2046
+	 * @return Integer number of captain
2047
+	 *
2048
+	 */
2049 2049
 	public function countOverallMarineCaptains($filters = array(),$year = '',$month = '')
2050 2050
 	{
2051 2051
 		global $globalDBdriver;
@@ -2079,11 +2079,11 @@  discard block
 block discarded – undo
2079 2079
 	}
2080 2080
   
2081 2081
 	/**
2082
-	* Counts all hours of today
2083
-	*
2084
-	* @return Array the hour list
2085
-	*
2086
-	*/
2082
+	 * Counts all hours of today
2083
+	 *
2084
+	 * @return Array the hour list
2085
+	 *
2086
+	 */
2087 2087
 	public function countAllHoursFromToday($filters = array())
2088 2088
 	{
2089 2089
 		global $globalTimezone, $globalDBdriver;
@@ -2123,12 +2123,12 @@  discard block
 block discarded – undo
2123 2123
 	}
2124 2124
     
2125 2125
     
2126
-     /**
2127
-	* Gets the Barrie Spotter ID based on the FlightAware ID
2128
-	*
2129
-	* @return Integer the Barrie Spotter ID
2126
+	 /**
2127
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
2128
+	  *
2129
+	  * @return Integer the Barrie Spotter ID
2130 2130
 q	*
2131
-	*/
2131
+	  */
2132 2132
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
2133 2133
 	{
2134 2134
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -2149,13 +2149,13 @@  discard block
 block discarded – undo
2149 2149
   
2150 2150
  
2151 2151
 	/**
2152
-	* Parses a date string
2153
-	*
2154
-	* @param String $dateString the date string
2155
-	* @param String $timezone the timezone of a user
2156
-	* @return Array the time information
2157
-	*
2158
-	*/
2152
+	 * Parses a date string
2153
+	 *
2154
+	 * @param String $dateString the date string
2155
+	 * @param String $timezone the timezone of a user
2156
+	 * @return Array the time information
2157
+	 *
2158
+	 */
2159 2159
 	public function parseDateString($dateString, $timezone = '')
2160 2160
 	{
2161 2161
 		$time_array = array();
@@ -2188,12 +2188,12 @@  discard block
 block discarded – undo
2188 2188
 	}
2189 2189
 	
2190 2190
 	/**
2191
-	* Parses the direction degrees to working
2192
-	*
2193
-	* @param Float $direction the direction in degrees
2194
-	* @return Array the direction information
2195
-	*
2196
-	*/
2191
+	 * Parses the direction degrees to working
2192
+	 *
2193
+	 * @param Float $direction the direction in degrees
2194
+	 * @return Array the direction information
2195
+	 *
2196
+	 */
2197 2197
 	public function parseDirection($direction = 0)
2198 2198
 	{
2199 2199
 		if ($direction == '') $direction = 0;
@@ -2272,12 +2272,12 @@  discard block
 block discarded – undo
2272 2272
 	
2273 2273
 	
2274 2274
 	/**
2275
-	* Gets Country from latitude/longitude
2276
-	*
2277
-	* @param Float $latitude latitute of the flight
2278
-	* @param Float $longitude longitute of the flight
2279
-	* @return String the countrie
2280
-	*/
2275
+	 * Gets Country from latitude/longitude
2276
+	 *
2277
+	 * @param Float $latitude latitute of the flight
2278
+	 * @param Float $longitude longitute of the flight
2279
+	 * @return String the countrie
2280
+	 */
2281 2281
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
2282 2282
 	{
2283 2283
 		global $globalDBdriver, $globalDebug;
@@ -2314,11 +2314,11 @@  discard block
 block discarded – undo
2314 2314
 	}
2315 2315
 
2316 2316
 	/**
2317
-	* Gets Country from iso2
2318
-	*
2319
-	* @param String $iso2 ISO2 country code
2320
-	* @return String the countrie
2321
-	*/
2317
+	 * Gets Country from iso2
2318
+	 *
2319
+	 * @param String $iso2 ISO2 country code
2320
+	 * @return String the countrie
2321
+	 */
2322 2322
 	public function getCountryFromISO2($iso2)
2323 2323
 	{
2324 2324
 		global $globalDBdriver, $globalDebug;
@@ -2347,12 +2347,12 @@  discard block
 block discarded – undo
2347 2347
 
2348 2348
 	
2349 2349
 	/**
2350
-	* Gets the short url from bit.ly
2351
-	*
2352
-	* @param String $url the full url
2353
-	* @return String the bit.ly url
2354
-	*
2355
-	*/
2350
+	 * Gets the short url from bit.ly
2351
+	 *
2352
+	 * @param String $url the full url
2353
+	 * @return String the bit.ly url
2354
+	 *
2355
+	 */
2356 2356
 	public function getBitlyURL($url)
2357 2357
 	{
2358 2358
 		global $globalBitlyAccessToken;
@@ -2379,11 +2379,11 @@  discard block
 block discarded – undo
2379 2379
 
2380 2380
 	
2381 2381
 	/**
2382
-	* Gets all vessels types that have flown over
2383
-	*
2384
-	* @return Array the vessel type list
2385
-	*
2386
-	*/
2382
+	 * Gets all vessels types that have flown over
2383
+	 *
2384
+	 * @return Array the vessel type list
2385
+	 *
2386
+	 */
2387 2387
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
2388 2388
 	{
2389 2389
 		global $globalDBdriver;
@@ -2449,11 +2449,11 @@  discard block
 block discarded – undo
2449 2449
 	}
2450 2450
 
2451 2451
 	/**
2452
-	* Gets all the tracker information
2453
-	*
2454
-	* @return Array the tracker information
2455
-	*
2456
-	*/
2452
+	 * Gets all the tracker information
2453
+	 *
2454
+	 * @return Array the tracker information
2455
+	 *
2456
+	 */
2457 2457
 	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())
2458 2458
 	{
2459 2459
 		global $globalTimezone, $globalDBdriver;
@@ -2630,11 +2630,11 @@  discard block
 block discarded – undo
2630 2630
 	}
2631 2631
 
2632 2632
 	/**
2633
-	* Check marine by id
2634
-	*
2635
-	* @return String the ident
2636
-	*
2637
-	*/
2633
+	 * Check marine by id
2634
+	 *
2635
+	 * @return String the ident
2636
+	 *
2637
+	 */
2638 2638
 	public function checkId($id)
2639 2639
 	{
2640 2640
 		global $globalDBdriver, $globalTimezone;
@@ -2651,11 +2651,11 @@  discard block
 block discarded – undo
2651 2651
 	}
2652 2652
 
2653 2653
 	/**
2654
-	* Gets all info from a race
2655
-	*
2656
-	* @return Array race
2657
-	*
2658
-	*/
2654
+	 * Gets all info from a race
2655
+	 *
2656
+	 * @return Array race
2657
+	 *
2658
+	 */
2659 2659
 	public function getRaceByName($race_name)
2660 2660
 	{
2661 2661
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
@@ -2668,11 +2668,11 @@  discard block
 block discarded – undo
2668 2668
 	}
2669 2669
 
2670 2670
 	/**
2671
-	* Gets all info from a race
2672
-	*
2673
-	* @return Array race
2674
-	*
2675
-	*/
2671
+	 * Gets all info from a race
2672
+	 *
2673
+	 * @return Array race
2674
+	 *
2675
+	 */
2676 2676
 	public function getRace($race_id)
2677 2677
 	{
2678 2678
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
@@ -2685,9 +2685,9 @@  discard block
 block discarded – undo
2685 2685
 	}
2686 2686
 
2687 2687
 	/**
2688
-	* Add race
2689
-	*
2690
-	*/
2688
+	 * Add race
2689
+	 *
2690
+	 */
2691 2691
 	public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers)
2692 2692
 	{
2693 2693
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
Spacing   +327 added lines, -327 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) {
@@ -24,33 +24,33 @@  discard block
 block discarded – undo
24 24
 	* @return Array the SQL part
25 25
 	*/
26 26
 	
27
-	public function getFilter($filter = array(),$where = false,$and = false) {
27
+	public function getFilter($filter = array(), $where = false, $and = false) {
28 28
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
29 29
 		$filters = array();
30 30
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
31 31
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
32 32
 				$filters = $globalStatsFilters[$globalFilterName];
33 33
 			} else {
34
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
34
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
35 35
 			}
36 36
 		}
37 37
 		if (isset($filter[0]['source'])) {
38
-			$filters = array_merge($filters,$filter);
38
+			$filters = array_merge($filters, $filter);
39 39
 		}
40
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
40
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
41 41
 		$filter_query_join = '';
42 42
 		$filter_query_where = '';
43
-		foreach($filters as $flt) {
43
+		foreach ($filters as $flt) {
44 44
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
45 45
 				if (isset($flt['source'])) {
46
-					$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";
46
+					$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 47
 				} else {
48
-					$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";
48
+					$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 49
 				}
50 50
 			}
51 51
 		}
52 52
 		if (isset($filter['source']) && !empty($filter['source'])) {
53
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
53
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
54 54
 		}
55 55
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
56 56
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
89 89
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
90 90
 		if ($filter_query_where != '') {
91
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
91
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
92 92
 		}
93 93
 		$filter_query = $filter_query_join.$filter_query_where;
94 94
 		return $filter_query;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	* @return Array the spotter information
104 104
 	*
105 105
 	*/
106
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
106
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
107 107
 	{
108 108
 		global $globalVM;
109 109
 		date_default_timezone_set('UTC');
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 			$sth = $this->db->prepare($query.$limitQuery);
125 125
 			$sth->execute($params);
126 126
 		} catch (PDOException $e) {
127
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
127
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
128 128
 			exit();
129 129
 		}
130 130
 		
131 131
 		$num_rows = 0;
132 132
 		$spotter_array = array();
133
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
133
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
134 134
 		{
135 135
 			$num_rows++;
136 136
 			$temp_array = array();
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 			}
150 150
 			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
151 151
 			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
152
-			if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES);
152
+			if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'], ENT_QUOTES);
153 153
 			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
154 154
 			if (isset($row['status'])) $temp_array['status'] = $row['status'];
155 155
 			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 			}
173 173
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
174 174
 
175
-			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
175
+			if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
176 176
 			{
177 177
 				$Image = new Image($this->db);
178
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
178
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
179 179
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
180 180
 				unset($Image);
181 181
 				if (count($image_array) > 0) {
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 					$temp_array['image_source_website'] = $image_array[0]['image_source_website'];
186 186
 					$temp_array['image_copyright'] = $image_array[0]['image_copyright'];
187 187
 				}
188
-			} elseif(isset($temp_array['type']) && $temp_array['type'] != "")
188
+			} elseif (isset($temp_array['type']) && $temp_array['type'] != "")
189 189
 			{
190 190
 				$Image = new Image($this->db);
191
-				$image_array = $Image->getMarineImage('','','',$temp_array['type']);
191
+				$image_array = $Image->getMarineImage('', '', '', $temp_array['type']);
192 192
 				unset($Image);
193 193
 				if (count($image_array) > 0) {
194 194
 					$temp_array['image'] = $image_array[0]['image'];
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
 				{
224 224
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
225 225
 				} else {
226
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
226
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
227 227
 				}
228 228
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
229
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
230
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
229
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
230
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
231 231
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
232 232
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
233 233
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
234 234
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
235
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
236
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
235
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
236
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
237 237
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
238 238
 					}
239 239
 				}
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 		if ($limit != "")
267 267
 		{
268 268
 			$limit_array = explode(",", $limit);
269
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
270
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
269
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
270
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
271 271
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
272 272
 			{
273 273
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 		} else {
282 282
 			$orderby_query = " ORDER BY marine_output.date DESC";
283 283
 		}
284
-		$query  = $global_marine_query.$filter_query." ".$orderby_query;
285
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
284
+		$query = $global_marine_query.$filter_query." ".$orderby_query;
285
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
286 286
 		return $spotter_array;
287 287
 	}
288 288
     
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 		if ($id == '') return array();
301 301
 		$additional_query = "marine_output.fammarine_id = :id";
302 302
 		$query_values = array(':id' => $id);
303
-		$query  = $global_marine_query." WHERE ".$additional_query." ";
304
-		$spotter_array = $this->getDataFromDB($query,$query_values);
303
+		$query = $global_marine_query." WHERE ".$additional_query." ";
304
+		$spotter_array = $this->getDataFromDB($query, $query_values);
305 305
 		return $spotter_array;
306 306
 	}
307 307
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 		$query_values = array();
321 321
 		$limit_query = '';
322 322
 		$additional_query = '';
323
-		$filter_query = $this->getFilter($filter,true,true);
323
+		$filter_query = $this->getFilter($filter, true, true);
324 324
 		if ($ident != "")
325 325
 		{
326 326
 			if (!is_string($ident))
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 		{
337 337
 			$limit_array = explode(",", $limit);
338 338
 			
339
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
340
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
339
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
340
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
341 341
 			
342 342
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
343 343
 			{
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 		$query_values = array();
377 377
 		$limit_query = '';
378 378
 		$additional_query = '';
379
-		$filter_query = $this->getFilter($filter,true,true);
379
+		$filter_query = $this->getFilter($filter, true, true);
380 380
 		if (!is_string($type))
381 381
 		{
382 382
 			return false;
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 		{
390 390
 			$limit_array = explode(",", $limit);
391 391
 			
392
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
393
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
392
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
393
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
394 394
 			
395 395
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
396 396
 			{
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 		return $spotter_array;
415 415
 	}
416 416
 	
417
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
417
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
418 418
 	{
419 419
 		global $global_marine_query, $globalTimezone, $globalDBdriver;
420 420
 		
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 		$limit_query = '';
423 423
 		$additional_query = '';
424 424
 
425
-		$filter_query = $this->getFilter($filter,true,true);
425
+		$filter_query = $this->getFilter($filter, true, true);
426 426
 		
427 427
 		if ($date != "")
428 428
 		{
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
 		{
449 449
 			$limit_array = explode(",", $limit);
450 450
 			
451
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
452
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
451
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
452
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
453 453
 			
454 454
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
455 455
 			{
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 		$query_values = array();
485 485
 		$limit_query = '';
486 486
 		$additional_query = '';
487
-		$filter_query = $this->getFilter($filter,true,true);
488
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
487
+		$filter_query = $this->getFilter($filter, true, true);
488
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
489 489
 		if ($captain != "")
490 490
 		{
491 491
 			$additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)";
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
 		if ($limit != "")
495 495
 		{
496 496
 			$limit_array = explode(",", $limit);
497
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
498
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
497
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
498
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
499 499
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
500 500
 			{
501 501
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -522,13 +522,13 @@  discard block
 block discarded – undo
522 522
 	*/
523 523
 	public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array())
524 524
 	{
525
-		global $global_marine_query,$globalDBdriver;
525
+		global $global_marine_query, $globalDBdriver;
526 526
 		date_default_timezone_set('UTC');
527 527
 		$query_values = array();
528 528
 		$limit_query = '';
529 529
 		$additional_query = '';
530
-		$filter_query = $this->getFilter($filter,true,true);
531
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
530
+		$filter_query = $this->getFilter($filter, true, true);
531
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
532 532
 		if ($race != "")
533 533
 		{
534 534
 			$additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)";
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 		if ($limit != "")
538 538
 		{
539 539
 			$limit_array = explode(",", $limit);
540
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
541
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
540
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
541
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
542 542
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
543 543
 			{
544 544
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -567,14 +567,14 @@  discard block
 block discarded – undo
567 567
 	* @return Integer number of race for a captain
568 568
 	*
569 569
 	*/
570
-	public function countRacesByCaptain($captain,$filters = array())
570
+	public function countRacesByCaptain($captain, $filters = array())
571 571
 	{
572
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
573
-		$filter_query = $this->getFilter($filters,true,true);
574
-		$query  = "SELECT COUNT(*) AS nb 
572
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
573
+		$filter_query = $this->getFilter($filters, true, true);
574
+		$query = "SELECT COUNT(*) AS nb 
575 575
 			FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)";
576 576
 		$query_values = array();
577
-		$query_values = array_merge($query_values,array(':captain' => $captain));
577
+		$query_values = array_merge($query_values, array(':captain' => $captain));
578 578
 		$sth = $this->db->prepare($query);
579 579
 		$sth->execute($query_values);
580 580
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -587,14 +587,14 @@  discard block
 block discarded – undo
587 587
 	* @return String Duration of all races
588 588
 	*
589 589
 	*/
590
-	public function countCaptainsByRace($race,$filters = array())
590
+	public function countCaptainsByRace($race, $filters = array())
591 591
 	{
592
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
593
-		$filter_query = $this->getFilter($filters,true,true);
594
-		$query  = "SELECT COUNT(*) AS nb 
592
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
593
+		$filter_query = $this->getFilter($filters, true, true);
594
+		$query = "SELECT COUNT(*) AS nb 
595 595
 			FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)";
596 596
 		$query_values = array();
597
-		$query_values = array_merge($query_values,array(':race' => $race));
597
+		$query_values = array_merge($query_values, array(':race' => $race));
598 598
 		$sth = $this->db->prepare($query);
599 599
 		$sth->execute($query_values);
600 600
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -607,44 +607,44 @@  discard block
 block discarded – undo
607 607
 	* @return Array the boat list
608 608
 	*
609 609
 	*/
610
-	public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
610
+	public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '')
611 611
 	{
612 612
 		global $globalDBdriver;
613
-		$filter_query = $this->getFilter($filters,true,true);
614
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
615
-		$query  = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
613
+		$filter_query = $this->getFilter($filters, true, true);
614
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
615
+		$query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
616 616
 			FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)";
617 617
 		$query_values = array();
618 618
 		if ($year != '') {
619 619
 			if ($globalDBdriver == 'mysql') {
620 620
 				$query .= " AND YEAR(marine_output.date) = :year";
621
-				$query_values = array_merge($query_values,array(':year' => $year));
621
+				$query_values = array_merge($query_values, array(':year' => $year));
622 622
 			} else {
623 623
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
624
-				$query_values = array_merge($query_values,array(':year' => $year));
624
+				$query_values = array_merge($query_values, array(':year' => $year));
625 625
 			}
626 626
 		}
627 627
 		if ($month != '') {
628 628
 			if ($globalDBdriver == 'mysql') {
629 629
 				$query .= " AND MONTH(marine_output.date) = :month";
630
-				$query_values = array_merge($query_values,array(':month' => $month));
630
+				$query_values = array_merge($query_values, array(':month' => $month));
631 631
 			} else {
632 632
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
633
-				$query_values = array_merge($query_values,array(':month' => $month));
633
+				$query_values = array_merge($query_values, array(':month' => $month));
634 634
 			}
635 635
 		}
636 636
 		if ($day != '') {
637 637
 			if ($globalDBdriver == 'mysql') {
638 638
 				$query .= " AND DAY(marine_output.date) = :day";
639
-				$query_values = array_merge($query_values,array(':day' => $day));
639
+				$query_values = array_merge($query_values, array(':day' => $day));
640 640
 			} else {
641 641
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
642
-				$query_values = array_merge($query_values,array(':day' => $day));
642
+				$query_values = array_merge($query_values, array(':day' => $day));
643 643
 			}
644 644
 		}
645 645
 		$query .= " GROUP BY marine_output.type
646 646
 			ORDER BY type_count DESC";
647
-		$query_values = array_merge($query_values,array(':captain' => $captain));
647
+		$query_values = array_merge($query_values, array(':captain' => $captain));
648 648
 		$sth = $this->db->prepare($query);
649 649
 		$sth->execute($query_values);
650 650
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -656,44 +656,44 @@  discard block
 block discarded – undo
656 656
 	* @return Array the boat list
657 657
 	*
658 658
 	*/
659
-	public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '')
659
+	public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '')
660 660
 	{
661 661
 		global $globalDBdriver;
662
-		$filter_query = $this->getFilter($filters,true,true);
663
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
664
-		$query  = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
662
+		$filter_query = $this->getFilter($filters, true, true);
663
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
664
+		$query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
665 665
 			FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)";
666 666
 		$query_values = array();
667 667
 		if ($year != '') {
668 668
 			if ($globalDBdriver == 'mysql') {
669 669
 				$query .= " AND YEAR(marine_output.date) = :year";
670
-				$query_values = array_merge($query_values,array(':year' => $year));
670
+				$query_values = array_merge($query_values, array(':year' => $year));
671 671
 			} else {
672 672
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
673
-				$query_values = array_merge($query_values,array(':year' => $year));
673
+				$query_values = array_merge($query_values, array(':year' => $year));
674 674
 			}
675 675
 		}
676 676
 		if ($month != '') {
677 677
 			if ($globalDBdriver == 'mysql') {
678 678
 				$query .= " AND MONTH(marine_output.date) = :month";
679
-				$query_values = array_merge($query_values,array(':month' => $month));
679
+				$query_values = array_merge($query_values, array(':month' => $month));
680 680
 			} else {
681 681
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
682
-				$query_values = array_merge($query_values,array(':month' => $month));
682
+				$query_values = array_merge($query_values, array(':month' => $month));
683 683
 			}
684 684
 		}
685 685
 		if ($day != '') {
686 686
 			if ($globalDBdriver == 'mysql') {
687 687
 				$query .= " AND DAY(marine_output.date) = :day";
688
-				$query_values = array_merge($query_values,array(':day' => $day));
688
+				$query_values = array_merge($query_values, array(':day' => $day));
689 689
 			} else {
690 690
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
691
-				$query_values = array_merge($query_values,array(':day' => $day));
691
+				$query_values = array_merge($query_values, array(':day' => $day));
692 692
 			}
693 693
 		}
694 694
 		$query .= " GROUP BY marine_output.type
695 695
 			ORDER BY type_count DESC";
696
-		$query_values = array_merge($query_values,array(':race' => $race));
696
+		$query_values = array_merge($query_values, array(':race' => $race));
697 697
 		$sth = $this->db->prepare($query);
698 698
 		$sth->execute($query_values);
699 699
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -705,47 +705,47 @@  discard block
 block discarded – undo
705 705
 	* @return String Duration of all race
706 706
 	*
707 707
 	*/
708
-	public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
708
+	public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '')
709 709
 	{
710 710
 		global $globalDBdriver;
711
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
712
-		$filter_query = $this->getFilter($filters,true,true);
713
-		$query  = "SELECT SUM(last_seen - date) AS duration 
711
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
712
+		$filter_query = $this->getFilter($filters, true, true);
713
+		$query = "SELECT SUM(last_seen - date) AS duration 
714 714
 		    FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) 
715 715
 		    AND last_seen > date";
716 716
 		$query_values = array();
717 717
 		if ($year != '') {
718 718
 			if ($globalDBdriver == 'mysql') {
719 719
 				$query .= " AND YEAR(marine_output.date) = :year";
720
-				$query_values = array_merge($query_values,array(':year' => $year));
720
+				$query_values = array_merge($query_values, array(':year' => $year));
721 721
 			} else {
722 722
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
723
-				$query_values = array_merge($query_values,array(':year' => $year));
723
+				$query_values = array_merge($query_values, array(':year' => $year));
724 724
 			}
725 725
 		}
726 726
 		if ($month != '') {
727 727
 			if ($globalDBdriver == 'mysql') {
728 728
 				$query .= " AND MONTH(marine_output.date) = :month";
729
-				$query_values = array_merge($query_values,array(':month' => $month));
729
+				$query_values = array_merge($query_values, array(':month' => $month));
730 730
 			} else {
731 731
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
732
-				$query_values = array_merge($query_values,array(':month' => $month));
732
+				$query_values = array_merge($query_values, array(':month' => $month));
733 733
 			}
734 734
 		}
735 735
 		if ($day != '') {
736 736
 			if ($globalDBdriver == 'mysql') {
737 737
 				$query .= " AND DAY(marine_output.date) = :day";
738
-				$query_values = array_merge($query_values,array(':day' => $day));
738
+				$query_values = array_merge($query_values, array(':day' => $day));
739 739
 			} else {
740 740
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
741
-				$query_values = array_merge($query_values,array(':day' => $day));
741
+				$query_values = array_merge($query_values, array(':day' => $day));
742 742
 			}
743 743
 		}
744
-		$query_values = array_merge($query_values,array(':captain' => $captain));
744
+		$query_values = array_merge($query_values, array(':captain' => $captain));
745 745
 		$sth = $this->db->prepare($query);
746 746
 		$sth->execute($query_values);
747 747
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
748
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
748
+		if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
749 749
 		else return $result[0]['duration'];
750 750
 	}
751 751
 
@@ -755,38 +755,38 @@  discard block
 block discarded – undo
755 755
 	* @return String Duration of all race
756 756
 	*
757 757
 	*/
758
-	public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '')
758
+	public function getRaceDurationByCaptains($limit = true, $filters = array(), $year = '', $month = '', $day = '')
759 759
 	{
760 760
 		global $globalDBdriver;
761
-		$filter_query = $this->getFilter($filters,true,true);
762
-		$query  = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name 
761
+		$filter_query = $this->getFilter($filters, true, true);
762
+		$query = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name 
763 763
 		    FROM marine_output".$filter_query." last_seen > date";
764 764
 		$query_values = array();
765 765
 		if ($year != '') {
766 766
 			if ($globalDBdriver == 'mysql') {
767 767
 				$query .= " AND YEAR(marine_output.date) = :year";
768
-				$query_values = array_merge($query_values,array(':year' => $year));
768
+				$query_values = array_merge($query_values, array(':year' => $year));
769 769
 			} else {
770 770
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
771
-				$query_values = array_merge($query_values,array(':year' => $year));
771
+				$query_values = array_merge($query_values, array(':year' => $year));
772 772
 			}
773 773
 		}
774 774
 		if ($month != '') {
775 775
 			if ($globalDBdriver == 'mysql') {
776 776
 				$query .= " AND MONTH(marine_output.date) = :month";
777
-				$query_values = array_merge($query_values,array(':month' => $month));
777
+				$query_values = array_merge($query_values, array(':month' => $month));
778 778
 			} else {
779 779
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
780
-				$query_values = array_merge($query_values,array(':month' => $month));
780
+				$query_values = array_merge($query_values, array(':month' => $month));
781 781
 			}
782 782
 		}
783 783
 		if ($day != '') {
784 784
 			if ($globalDBdriver == 'mysql') {
785 785
 				$query .= " AND DAY(marine_output.date) = :day";
786
-				$query_values = array_merge($query_values,array(':day' => $day));
786
+				$query_values = array_merge($query_values, array(':day' => $day));
787 787
 			} else {
788 788
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
789
-				$query_values = array_merge($query_values,array(':day' => $day));
789
+				$query_values = array_merge($query_values, array(':day' => $day));
790 790
 			}
791 791
 		}
792 792
 		$query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC";
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		$duration_array = array();
799 799
 		$temp_array = array();
800 800
         
801
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
801
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
802 802
 		{
803 803
 			if ($row['duration'] != '') {
804 804
 				$temp_array['marine_duration_days'] = $row['duration'];
@@ -820,8 +820,8 @@  discard block
 block discarded – undo
820 820
 	*/
821 821
 	public function getAllCaptainNames($filters = array())
822 822
 	{
823
-		$filter_query = $this->getFilter($filters,true,true);
824
-		$query  = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id
823
+		$filter_query = $this->getFilter($filters, true, true);
824
+		$query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id
825 825
 			FROM marine_output".$filter_query." marine_output.captain_name <> '' 
826 826
 			ORDER BY marine_output.captain_name ASC";
827 827
 	
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
 	*/
839 839
 	public function getAllRaceNames($filters = array())
840 840
 	{
841
-		$filter_query = $this->getFilter($filters,true,true);
842
-		$query  = "SELECT DISTINCT marine_output.race_name, marine_output.race_id
841
+		$filter_query = $this->getFilter($filters, true, true);
842
+		$query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id
843 843
 			FROM marine_output".$filter_query." marine_output.race_name <> '' 
844 844
 			ORDER BY marine_output.race_name ASC";
845 845
 	
@@ -856,11 +856,11 @@  discard block
 block discarded – undo
856 856
 	* @return Array list of source name
857 857
 	*
858 858
 	*/
859
-	public function getAllSourceName($type = '',$filters = array())
859
+	public function getAllSourceName($type = '', $filters = array())
860 860
 	{
861
-		$filter_query = $this->getFilter($filters,true,true);
861
+		$filter_query = $this->getFilter($filters, true, true);
862 862
 		$query_values = array();
863
-		$query  = "SELECT DISTINCT marine_output.source_name 
863
+		$query = "SELECT DISTINCT marine_output.source_name 
864 864
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
865 865
 		if ($type != '') {
866 866
 			$query_values = array(':type' => $type);
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 		$source_array = array();
876 876
 		$temp_array = array();
877 877
 		
878
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
878
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
879 879
 		{
880 880
 			$temp_array['source_name'] = $row['source_name'];
881 881
 			$source_array[] = $temp_array;
@@ -892,8 +892,8 @@  discard block
 block discarded – undo
892 892
 	*/
893 893
 	public function getAllIdents($filters = array())
894 894
 	{
895
-		$filter_query = $this->getFilter($filters,true,true);
896
-		$query  = "SELECT DISTINCT marine_output.ident
895
+		$filter_query = $this->getFilter($filters, true, true);
896
+		$query = "SELECT DISTINCT marine_output.ident
897 897
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
898 898
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
899 899
 
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
 		$ident_array = array();
904 904
 		$temp_array = array();
905 905
 		
906
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
906
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
907 907
 		{
908 908
 			$temp_array['ident'] = $row['ident'];
909 909
 			$ident_array[] = $temp_array;
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 	*/
921 921
 	public function getIdentity($mmsi)
922 922
 	{
923
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
923
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
924 924
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
925 925
 		$sth = $this->db->prepare($query);
926 926
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -933,23 +933,23 @@  discard block
 block discarded – undo
933 933
 	* Add identity
934 934
 	*
935 935
 	*/
936
-	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
936
+	public function addIdentity($mmsi, $imo, $ident, $callsign, $type)
937 937
 	{
938
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
938
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
939 939
 		if ($mmsi != '') {
940
-			$imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT);
941
-			$ident = filter_var($ident,FILTER_SANITIZE_STRING);
942
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
943
-			$type = filter_var($type,FILTER_SANITIZE_STRING);
940
+			$imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT);
941
+			$ident = filter_var($ident, FILTER_SANITIZE_STRING);
942
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
943
+			$type = filter_var($type, FILTER_SANITIZE_STRING);
944 944
 			$identinfo = $this->getIdentity($mmsi);
945 945
 			if (empty($identinfo)) {
946
-				$query  = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
946
+				$query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
947 947
 				$sth = $this->db->prepare($query);
948
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type));
948
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type));
949 949
 			} elseif ($ident != '' && $identinfo['ship_name'] != $ident) {
950
-				$query  = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
950
+				$query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
951 951
 				$sth = $this->db->prepare($query);
952
-				$sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type));
952
+				$sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type));
953 953
 			}
954 954
 		}
955 955
 	}
@@ -970,12 +970,12 @@  discard block
 block discarded – undo
970 970
 		} else $offset = '+00:00';
971 971
 
972 972
 		if ($globalDBdriver == 'mysql') {
973
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
973
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
974 974
 								FROM marine_output
975 975
 								WHERE marine_output.date <> '' 
976 976
 								ORDER BY marine_output.date ASC LIMIT 0,100";
977 977
 		} else {
978
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
978
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
979 979
 								FROM marine_output
980 980
 								WHERE marine_output.date <> '' 
981 981
 								ORDER BY marine_output.date ASC LIMIT 0,100";
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 		$date_array = array();
988 988
 		$temp_array = array();
989 989
 		
990
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
990
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
991 991
 		{
992 992
 			$temp_array['date'] = $row['date'];
993 993
 
@@ -1005,10 +1005,10 @@  discard block
 block discarded – undo
1005 1005
 	* @return String success or false
1006 1006
 	*
1007 1007
 	*/
1008
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
1008
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
1009 1009
 	{
1010 1010
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
1011
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
1011
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
1012 1012
 		try {
1013 1013
 			$sth = $this->db->prepare($query);
1014 1014
 			$sth->execute($query_values);
@@ -1026,10 +1026,10 @@  discard block
 block discarded – undo
1026 1026
 	* @return String success or false
1027 1027
 	*
1028 1028
 	*/
1029
-	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
1029
+	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL)
1030 1030
 	{
1031 1031
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
1032
-		$query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code);
1032
+		$query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code);
1033 1033
 		try {
1034 1034
 			$sth = $this->db->prepare($query);
1035 1035
 			$sth->execute($query_values);
@@ -1048,11 +1048,11 @@  discard block
 block discarded – undo
1048 1048
 	* @return String success or false
1049 1049
 	*
1050 1050
 	*/
1051
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
1051
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
1052 1052
 	{
1053 1053
 
1054 1054
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
1055
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1055
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
1056 1056
 
1057 1057
 		try {
1058 1058
 			$sth = $this->db->prepare($query);
@@ -1072,17 +1072,17 @@  discard block
 block discarded – undo
1072 1072
 	* @return String success or false
1073 1073
 	*
1074 1074
 	*/	
1075
-	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1075
+	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1076 1076
 	{
1077 1077
 		if ($latitude == '') $latitude = NULL;
1078 1078
 		if ($longitude == '') $longitude = NULL;
1079 1079
 		$groundspeed = round($groundspeed);
1080 1080
 		if ($race_begin != '') {
1081 1081
 			$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';
1082
-			$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);
1082
+			$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);
1083 1083
 		} else {
1084 1084
 			$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';
1085
-			$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);
1085
+			$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);
1086 1086
 		}
1087 1087
 		try {
1088 1088
 			$sth = $this->db->prepare($query);
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 	* @param String $verticalrate vertival rate of flight
1122 1122
 	* @return String success or false
1123 1123
 	*/
1124
-	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 = '')
1124
+	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 = '')
1125 1125
 	{
1126 1126
 		global $globalURL, $globalMarineImageFetch;
1127 1127
 		
@@ -1193,34 +1193,34 @@  discard block
 block discarded – undo
1193 1193
 			$date = date("Y-m-d H:i:s", time());
1194 1194
 		}
1195 1195
 
1196
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1197
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1198
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1199
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1200
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1201
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1202
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1203
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
1204
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
1205
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
1206
-		$type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
1207
-		$status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
1208
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1209
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1210
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
1211
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
1212
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
1213
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
1214
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1215
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1216
-		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1217
-		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1218
-		$distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1196
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1197
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1198
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1199
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1200
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1201
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1202
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1203
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
1204
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
1205
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
1206
+		$type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
1207
+		$status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
1208
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1209
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1210
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
1211
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
1212
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
1213
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
1214
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
1215
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
1216
+		$race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT);
1217
+		$race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1218
+		$distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1219 1219
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
1220 1220
 			$Image = new Image($this->db);
1221
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
1221
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
1222 1222
 			if (!isset($image_array[0]['mmsi'])) {
1223
-				$Image->addMarineImage($mmsi,$imo,$ident);
1223
+				$Image->addMarineImage($mmsi, $imo, $ident);
1224 1224
 			}
1225 1225
 			unset($Image);
1226 1226
 		}
@@ -1236,10 +1236,10 @@  discard block
 block discarded – undo
1236 1236
 		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1237 1237
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1238 1238
 		if ($arrival_date == '') $arrival_date = NULL;
1239
-		$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) 
1239
+		$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) 
1240 1240
 		    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)";
1241 1241
 
1242
-		$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);
1242
+		$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);
1243 1243
 		try {
1244 1244
 			$sth = $this->db->prepare($query);
1245 1245
 			$sth->execute($query_values);
@@ -1263,13 +1263,13 @@  discard block
 block discarded – undo
1263 1263
 	{
1264 1264
 		global $globalDBdriver, $globalTimezone;
1265 1265
 		if ($globalDBdriver == 'mysql') {
1266
-			$query  = "SELECT marine_output.ident FROM marine_output 
1266
+			$query = "SELECT marine_output.ident FROM marine_output 
1267 1267
 								WHERE marine_output.ident = :ident 
1268 1268
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
1269 1269
 								AND marine_output.date < UTC_TIMESTAMP()";
1270 1270
 			$query_data = array(':ident' => $ident);
1271 1271
 		} else {
1272
-			$query  = "SELECT marine_output.ident FROM marine_output 
1272
+			$query = "SELECT marine_output.ident FROM marine_output 
1273 1273
 								WHERE marine_output.ident = :ident 
1274 1274
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
1275 1275
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -1278,8 +1278,8 @@  discard block
 block discarded – undo
1278 1278
 		
1279 1279
 		$sth = $this->db->prepare($query);
1280 1280
 		$sth->execute($query_data);
1281
-    		$ident_result='';
1282
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1281
+    		$ident_result = '';
1282
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1283 1283
 		{
1284 1284
 			$ident_result = $row['ident'];
1285 1285
 		}
@@ -1305,8 +1305,8 @@  discard block
 block discarded – undo
1305 1305
 				return false;
1306 1306
 			} else {
1307 1307
 				$q_array = explode(" ", $q);
1308
-				foreach ($q_array as $q_item){
1309
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1308
+				foreach ($q_array as $q_item) {
1309
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1310 1310
 					$additional_query .= " AND (";
1311 1311
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
1312 1312
 					$additional_query .= ")";
@@ -1314,11 +1314,11 @@  discard block
 block discarded – undo
1314 1314
 			}
1315 1315
 		}
1316 1316
 		if ($globalDBdriver == 'mysql') {
1317
-			$query  = "SELECT marine_output.* FROM marine_output 
1317
+			$query = "SELECT marine_output.* FROM marine_output 
1318 1318
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
1319 1319
 				AND marine_output.date < UTC_TIMESTAMP()";
1320 1320
 		} else {
1321
-			$query  = "SELECT marine_output.* FROM marine_output 
1321
+			$query = "SELECT marine_output.* FROM marine_output 
1322 1322
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1323 1323
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1324 1324
 		}
@@ -1337,16 +1337,16 @@  discard block
 block discarded – undo
1337 1337
 	*
1338 1338
 	*/
1339 1339
 
1340
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1340
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
1341 1341
 	{
1342 1342
 		global $globalDBdriver, $globalArchive;
1343 1343
 		//$filter_query = $this->getFilter($filters,true,true);
1344
-		$Connection= new Connection($this->db);
1344
+		$Connection = new Connection($this->db);
1345 1345
 		if (!$Connection->tableExists('countries')) return array();
1346 1346
 		require_once('class.SpotterLive.php');
1347 1347
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
1348 1348
 			$MarineLive = new MarineLive($this->db);
1349
-			$filter_query = $MarineLive->getFilter($filters,true,true);
1349
+			$filter_query = $MarineLive->getFilter($filters, true, true);
1350 1350
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
1351 1351
 			if ($olderthanmonths > 0) {
1352 1352
 				if ($globalDBdriver == 'mysql') {
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 		} else {
1367 1367
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
1368 1368
 			$MarineArchive = new MarineArchive($this->db);
1369
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
1369
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
1370 1370
 			$filter_query .= " over_country <> ''";
1371 1371
 			if ($olderthanmonths > 0) {
1372 1372
 				if ($globalDBdriver == 'mysql') {
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
 		$flight_array = array();
1395 1395
 		$temp_array = array();
1396 1396
         
1397
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1397
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1398 1398
 		{
1399 1399
 			$temp_array['marine_count'] = $row['nb'];
1400 1400
 			$temp_array['marine_country'] = $row['name'];
@@ -1413,11 +1413,11 @@  discard block
 block discarded – undo
1413 1413
 	* @return Array the callsign list
1414 1414
 	*
1415 1415
 	*/
1416
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1416
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1417 1417
 	{
1418 1418
 		global $globalDBdriver;
1419
-		$filter_query = $this->getFilter($filters,true,true);
1420
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1419
+		$filter_query = $this->getFilter($filters, true, true);
1420
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1421 1421
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1422 1422
 		 if ($olderthanmonths > 0) {
1423 1423
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -1431,28 +1431,28 @@  discard block
 block discarded – undo
1431 1431
 		if ($year != '') {
1432 1432
 			if ($globalDBdriver == 'mysql') {
1433 1433
 				$query .= " AND YEAR(marine_output.date) = :year";
1434
-				$query_values = array_merge($query_values,array(':year' => $year));
1434
+				$query_values = array_merge($query_values, array(':year' => $year));
1435 1435
 			} else {
1436 1436
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1437
-				$query_values = array_merge($query_values,array(':year' => $year));
1437
+				$query_values = array_merge($query_values, array(':year' => $year));
1438 1438
 			}
1439 1439
 		}
1440 1440
 		if ($month != '') {
1441 1441
 			if ($globalDBdriver == 'mysql') {
1442 1442
 				$query .= " AND MONTH(marine_output.date) = :month";
1443
-				$query_values = array_merge($query_values,array(':month' => $month));
1443
+				$query_values = array_merge($query_values, array(':month' => $month));
1444 1444
 			} else {
1445 1445
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1446
-				$query_values = array_merge($query_values,array(':month' => $month));
1446
+				$query_values = array_merge($query_values, array(':month' => $month));
1447 1447
 			}
1448 1448
 		}
1449 1449
 		if ($day != '') {
1450 1450
 			if ($globalDBdriver == 'mysql') {
1451 1451
 				$query .= " AND DAY(marine_output.date) = :day";
1452
-				$query_values = array_merge($query_values,array(':day' => $day));
1452
+				$query_values = array_merge($query_values, array(':day' => $day));
1453 1453
 			} else {
1454 1454
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1455
-				$query_values = array_merge($query_values,array(':day' => $day));
1455
+				$query_values = array_merge($query_values, array(':day' => $day));
1456 1456
 			}
1457 1457
 		}
1458 1458
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
 		$callsign_array = array();
1465 1465
 		$temp_array = array();
1466 1466
         
1467
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1467
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1468 1468
 		{
1469 1469
 			$temp_array['callsign_icao'] = $row['ident'];
1470 1470
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 		$date_array = array();
1517 1517
 		$temp_array = array();
1518 1518
         
1519
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1519
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1520 1520
 		{
1521 1521
 			$temp_array['date_name'] = $row['date_name'];
1522 1522
 			$temp_array['date_count'] = $row['date_count'];
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
 			$datetime = new DateTime();
1543 1543
 			$offset = $datetime->format('P');
1544 1544
 		} else $offset = '+00:00';
1545
-		$filter_query = $this->getFilter($filters,true,true);
1545
+		$filter_query = $this->getFilter($filters, true, true);
1546 1546
 		if ($globalDBdriver == 'mysql') {
1547 1547
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1548 1548
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 		$date_array = array();
1564 1564
 		$temp_array = array();
1565 1565
         
1566
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1566
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1567 1567
 		{
1568 1568
 			$temp_array['date_name'] = $row['date_name'];
1569 1569
 			$temp_array['date_count'] = $row['date_count'];
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 			$datetime = new DateTime();
1589 1589
 			$offset = $datetime->format('P');
1590 1590
 		} else $offset = '+00:00';
1591
-		$filter_query = $this->getFilter($filters,true,true);
1591
+		$filter_query = $this->getFilter($filters, true, true);
1592 1592
 		if ($globalDBdriver == 'mysql') {
1593 1593
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1594 1594
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1609,7 +1609,7 @@  discard block
 block discarded – undo
1609 1609
 		$date_array = array();
1610 1610
 		$temp_array = array();
1611 1611
         
1612
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1612
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1613 1613
 		{
1614 1614
 			$temp_array['date_name'] = $row['date_name'];
1615 1615
 			$temp_array['date_count'] = $row['date_count'];
@@ -1656,7 +1656,7 @@  discard block
 block discarded – undo
1656 1656
 		$date_array = array();
1657 1657
 		$temp_array = array();
1658 1658
         
1659
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1659
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1660 1660
 		{
1661 1661
 			$temp_array['month_name'] = $row['month_name'];
1662 1662
 			$temp_array['year_name'] = $row['year_name'];
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
 			$datetime = new DateTime();
1686 1686
 			$offset = $datetime->format('P');
1687 1687
 		} else $offset = '+00:00';
1688
-		$filter_query = $this->getFilter($filters,true,true);
1688
+		$filter_query = $this->getFilter($filters, true, true);
1689 1689
 		if ($globalDBdriver == 'mysql') {
1690 1690
 			$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
1691 1691
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
 		$date_array = array();
1707 1707
 		$temp_array = array();
1708 1708
         
1709
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1709
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1710 1710
 		{
1711 1711
 			$temp_array['year_name'] = $row['year_name'];
1712 1712
 			$temp_array['month_name'] = $row['month_name'];
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
 	* @return Array the hour list
1727 1727
 	*
1728 1728
 	*/
1729
-	public function countAllHours($orderby,$filters = array())
1729
+	public function countAllHours($orderby, $filters = array())
1730 1730
 	{
1731 1731
 		global $globalTimezone, $globalDBdriver;
1732 1732
 		if ($globalTimezone != '') {
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 		$hour_array = array();
1775 1775
 		$temp_array = array();
1776 1776
         
1777
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1777
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1778 1778
 		{
1779 1779
 			$temp_array['hour_name'] = $row['hour_name'];
1780 1780
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1796,8 +1796,8 @@  discard block
 block discarded – undo
1796 1796
 	public function countAllHoursByDate($date, $filters = array())
1797 1797
 	{
1798 1798
 		global $globalTimezone, $globalDBdriver;
1799
-		$filter_query = $this->getFilter($filters,true,true);
1800
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1799
+		$filter_query = $this->getFilter($filters, true, true);
1800
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1801 1801
 		if ($globalTimezone != '') {
1802 1802
 			date_default_timezone_set($globalTimezone);
1803 1803
 			$datetime = new DateTime($date);
@@ -1805,12 +1805,12 @@  discard block
 block discarded – undo
1805 1805
 		} else $offset = '+00:00';
1806 1806
 
1807 1807
 		if ($globalDBdriver == 'mysql') {
1808
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1808
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1809 1809
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1810 1810
 								GROUP BY hour_name 
1811 1811
 								ORDER BY hour_name ASC";
1812 1812
 		} else {
1813
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1813
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1814 1814
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1815 1815
 								GROUP BY hour_name 
1816 1816
 								ORDER BY hour_name ASC";
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
 		$hour_array = array();
1823 1823
 		$temp_array = array();
1824 1824
         
1825
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1825
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1826 1826
 		{
1827 1827
 			$temp_array['hour_name'] = $row['hour_name'];
1828 1828
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1844,8 +1844,8 @@  discard block
 block discarded – undo
1844 1844
 	public function countAllHoursByIdent($ident, $filters = array())
1845 1845
 	{
1846 1846
 		global $globalTimezone, $globalDBdriver;
1847
-		$filter_query = $this->getFilter($filters,true,true);
1848
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1847
+		$filter_query = $this->getFilter($filters, true, true);
1848
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1849 1849
 		if ($globalTimezone != '') {
1850 1850
 			date_default_timezone_set($globalTimezone);
1851 1851
 			$datetime = new DateTime();
@@ -1853,12 +1853,12 @@  discard block
 block discarded – undo
1853 1853
 		} else $offset = '+00:00';
1854 1854
 
1855 1855
 		if ($globalDBdriver == 'mysql') {
1856
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1856
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1857 1857
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1858 1858
 								GROUP BY hour_name 
1859 1859
 								ORDER BY hour_name ASC";
1860 1860
 		} else {
1861
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1861
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1862 1862
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1863 1863
 								GROUP BY hour_name 
1864 1864
 								ORDER BY hour_name ASC";
@@ -1866,12 +1866,12 @@  discard block
 block discarded – undo
1866 1866
       
1867 1867
 		
1868 1868
 		$sth = $this->db->prepare($query);
1869
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1869
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1870 1870
       
1871 1871
 		$hour_array = array();
1872 1872
 		$temp_array = array();
1873 1873
         
1874
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1874
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1875 1875
 		{
1876 1876
 			$temp_array['hour_name'] = $row['hour_name'];
1877 1877
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1888,11 +1888,11 @@  discard block
 block discarded – undo
1888 1888
 	* @return Array the aircraft list
1889 1889
 	*
1890 1890
 	*/
1891
-	public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1891
+	public function countAllCaptainsByRaces($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
1892 1892
 	{
1893 1893
 		global $globalDBdriver;
1894
-		$filter_query = $this->getFilter($filters,true,true);
1895
-		$query  = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count 
1894
+		$filter_query = $this->getFilter($filters, true, true);
1895
+		$query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count 
1896 1896
 			FROM marine_output".$filter_query." race_id IS NOT NULL";
1897 1897
 		if ($olderthanmonths > 0) {
1898 1898
 			if ($globalDBdriver == 'mysql') {
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 		$marine_array = array();
1916 1916
 		$temp_array = array();
1917 1917
         
1918
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1918
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1919 1919
 		{
1920 1920
 			$temp_array['marine_race_id'] = $row['race_id'];
1921 1921
 			$temp_array['marine_race_name'] = $row['race_name'];
@@ -1931,33 +1931,33 @@  discard block
 block discarded – undo
1931 1931
 	* @return Integer the number of vessels
1932 1932
 	*
1933 1933
 	*/
1934
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1934
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1935 1935
 	{
1936 1936
 		global $globalDBdriver;
1937 1937
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1938
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1938
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1939 1939
 		$query_values = array();
1940 1940
 		$query = '';
1941 1941
 		if ($year != '') {
1942 1942
 			if ($globalDBdriver == 'mysql') {
1943 1943
 				$query .= " AND YEAR(marine_output.date) = :year";
1944
-				$query_values = array_merge($query_values,array(':year' => $year));
1944
+				$query_values = array_merge($query_values, array(':year' => $year));
1945 1945
 			} else {
1946 1946
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1947
-				$query_values = array_merge($query_values,array(':year' => $year));
1947
+				$query_values = array_merge($query_values, array(':year' => $year));
1948 1948
 			}
1949 1949
 		}
1950 1950
 		if ($month != '') {
1951 1951
 			if ($globalDBdriver == 'mysql') {
1952 1952
 				$query .= " AND MONTH(marine_output.date) = :month";
1953
-				$query_values = array_merge($query_values,array(':month' => $month));
1953
+				$query_values = array_merge($query_values, array(':month' => $month));
1954 1954
 			} else {
1955 1955
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1956
-				$query_values = array_merge($query_values,array(':month' => $month));
1956
+				$query_values = array_merge($query_values, array(':month' => $month));
1957 1957
 			}
1958 1958
 		}
1959 1959
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1960
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1960
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1961 1961
 		
1962 1962
 		$sth = $this->db->prepare($queryi);
1963 1963
 		$sth->execute($query_values);
@@ -1970,32 +1970,32 @@  discard block
 block discarded – undo
1970 1970
 	* @return Integer the number of vessels
1971 1971
 	*
1972 1972
 	*/
1973
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1973
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
1974 1974
 	{
1975 1975
 		global $globalDBdriver;
1976
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1976
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1977 1977
 		$query_values = array();
1978 1978
 		$query = '';
1979 1979
 		if ($year != '') {
1980 1980
 			if ($globalDBdriver == 'mysql') {
1981 1981
 				$query .= " AND YEAR(marine_output.date) = :year";
1982
-				$query_values = array_merge($query_values,array(':year' => $year));
1982
+				$query_values = array_merge($query_values, array(':year' => $year));
1983 1983
 			} else {
1984 1984
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1985
-				$query_values = array_merge($query_values,array(':year' => $year));
1985
+				$query_values = array_merge($query_values, array(':year' => $year));
1986 1986
 			}
1987 1987
 		}
1988 1988
 		if ($month != '') {
1989 1989
 			if ($globalDBdriver == 'mysql') {
1990 1990
 				$query .= " AND MONTH(marine_output.date) = :month";
1991
-				$query_values = array_merge($query_values,array(':month' => $month));
1991
+				$query_values = array_merge($query_values, array(':month' => $month));
1992 1992
 			} else {
1993 1993
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1994
-				$query_values = array_merge($query_values,array(':month' => $month));
1994
+				$query_values = array_merge($query_values, array(':month' => $month));
1995 1995
 			}
1996 1996
 		}
1997 1997
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1998
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1998
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1999 1999
 		
2000 2000
 		$sth = $this->db->prepare($queryi);
2001 2001
 		$sth->execute($query_values);
@@ -2008,32 +2008,32 @@  discard block
 block discarded – undo
2008 2008
 	* @return Integer number of races
2009 2009
 	*
2010 2010
 	*/
2011
-	public function countOverallMarineRaces($filters = array(),$year = '',$month = '')
2011
+	public function countOverallMarineRaces($filters = array(), $year = '', $month = '')
2012 2012
 	{
2013 2013
 		global $globalDBdriver;
2014
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output";
2014
+		$queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output";
2015 2015
 		$query_values = array();
2016 2016
 		$query = '';
2017 2017
 		if ($year != '') {
2018 2018
 			if ($globalDBdriver == 'mysql') {
2019 2019
 				$query .= " AND YEAR(marine_output.date) = :year";
2020
-				$query_values = array_merge($query_values,array(':year' => $year));
2020
+				$query_values = array_merge($query_values, array(':year' => $year));
2021 2021
 			} else {
2022 2022
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2023
-				$query_values = array_merge($query_values,array(':year' => $year));
2023
+				$query_values = array_merge($query_values, array(':year' => $year));
2024 2024
 			}
2025 2025
 		}
2026 2026
 		if ($month != '') {
2027 2027
 			if ($globalDBdriver == 'mysql') {
2028 2028
 				$query .= " AND MONTH(marine_output.date) = :month";
2029
-				$query_values = array_merge($query_values,array(':month' => $month));
2029
+				$query_values = array_merge($query_values, array(':month' => $month));
2030 2030
 			} else {
2031 2031
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2032
-				$query_values = array_merge($query_values,array(':month' => $month));
2032
+				$query_values = array_merge($query_values, array(':month' => $month));
2033 2033
 			}
2034 2034
 		}
2035 2035
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2036
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2036
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2037 2037
 		
2038 2038
 		$sth = $this->db->prepare($queryi);
2039 2039
 		$sth->execute($query_values);
@@ -2046,32 +2046,32 @@  discard block
 block discarded – undo
2046 2046
 	* @return Integer number of captain
2047 2047
 	*
2048 2048
 	*/
2049
-	public function countOverallMarineCaptains($filters = array(),$year = '',$month = '')
2049
+	public function countOverallMarineCaptains($filters = array(), $year = '', $month = '')
2050 2050
 	{
2051 2051
 		global $globalDBdriver;
2052
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output";
2052
+		$queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output";
2053 2053
 		$query_values = array();
2054 2054
 		$query = '';
2055 2055
 		if ($year != '') {
2056 2056
 			if ($globalDBdriver == 'mysql') {
2057 2057
 				$query .= " AND YEAR(marine_output.date) = :year";
2058
-				$query_values = array_merge($query_values,array(':year' => $year));
2058
+				$query_values = array_merge($query_values, array(':year' => $year));
2059 2059
 			} else {
2060 2060
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2061
-				$query_values = array_merge($query_values,array(':year' => $year));
2061
+				$query_values = array_merge($query_values, array(':year' => $year));
2062 2062
 			}
2063 2063
 		}
2064 2064
 		if ($month != '') {
2065 2065
 			if ($globalDBdriver == 'mysql') {
2066 2066
 				$query .= " AND MONTH(marine_output.date) = :month";
2067
-				$query_values = array_merge($query_values,array(':month' => $month));
2067
+				$query_values = array_merge($query_values, array(':month' => $month));
2068 2068
 			} else {
2069 2069
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2070
-				$query_values = array_merge($query_values,array(':month' => $month));
2070
+				$query_values = array_merge($query_values, array(':month' => $month));
2071 2071
 			}
2072 2072
 		}
2073 2073
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2074
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2074
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2075 2075
 		
2076 2076
 		$sth = $this->db->prepare($queryi);
2077 2077
 		$sth->execute($query_values);
@@ -2087,7 +2087,7 @@  discard block
 block discarded – undo
2087 2087
 	public function countAllHoursFromToday($filters = array())
2088 2088
 	{
2089 2089
 		global $globalTimezone, $globalDBdriver;
2090
-		$filter_query = $this->getFilter($filters,true,true);
2090
+		$filter_query = $this->getFilter($filters, true, true);
2091 2091
 		if ($globalTimezone != '') {
2092 2092
 			date_default_timezone_set($globalTimezone);
2093 2093
 			$datetime = new DateTime();
@@ -2095,12 +2095,12 @@  discard block
 block discarded – undo
2095 2095
 		} else $offset = '+00:00';
2096 2096
 
2097 2097
 		if ($globalDBdriver == 'mysql') {
2098
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
2098
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
2099 2099
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
2100 2100
 								GROUP BY hour_name 
2101 2101
 								ORDER BY hour_name ASC";
2102 2102
 		} else {
2103
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
2103
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
2104 2104
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
2105 2105
 								GROUP BY hour_name 
2106 2106
 								ORDER BY hour_name ASC";
@@ -2112,7 +2112,7 @@  discard block
 block discarded – undo
2112 2112
 		$hour_array = array();
2113 2113
 		$temp_array = array();
2114 2114
         
2115
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2115
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2116 2116
 		{
2117 2117
 			$temp_array['hour_name'] = $row['hour_name'];
2118 2118
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -2131,9 +2131,9 @@  discard block
 block discarded – undo
2131 2131
 	*/
2132 2132
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
2133 2133
 	{
2134
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
2134
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
2135 2135
 
2136
-		$query  = "SELECT marine_output.marine_id
2136
+		$query = "SELECT marine_output.marine_id
2137 2137
 				FROM marine_output 
2138 2138
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
2139 2139
         
@@ -2141,7 +2141,7 @@  discard block
 block discarded – undo
2141 2141
 		$sth = $this->db->prepare($query);
2142 2142
 		$sth->execute();
2143 2143
 
2144
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2144
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2145 2145
 		{
2146 2146
 			return $row['marine_id'];
2147 2147
 		}
@@ -2166,23 +2166,23 @@  discard block
 block discarded – undo
2166 2166
 		}
2167 2167
 		
2168 2168
 		$current_date = date("Y-m-d H:i:s");
2169
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
2169
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
2170 2170
 		
2171 2171
 		$diff = abs(strtotime($current_date) - strtotime($date));
2172 2172
 
2173
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
2173
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
2174 2174
 		$years = $time_array['years'];
2175 2175
 		
2176
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
2176
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
2177 2177
 		$months = $time_array['months'];
2178 2178
 		
2179
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
2179
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
2180 2180
 		$days = $time_array['days'];
2181
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
2181
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
2182 2182
 		$hours = $time_array['hours'];
2183
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
2183
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
2184 2184
 		$minutes = $time_array['minutes'];
2185
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
2185
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
2186 2186
 		
2187 2187
 		return $time_array;
2188 2188
 	}
@@ -2205,63 +2205,63 @@  discard block
 block discarded – undo
2205 2205
 			$temp_array['direction_degree'] = $direction;
2206 2206
 			$temp_array['direction_shortname'] = "N";
2207 2207
 			$temp_array['direction_fullname'] = "North";
2208
-		} elseif ($direction >= 22.5 && $direction < 45){
2208
+		} elseif ($direction >= 22.5 && $direction < 45) {
2209 2209
 			$temp_array['direction_degree'] = $direction;
2210 2210
 			$temp_array['direction_shortname'] = "NNE";
2211 2211
 			$temp_array['direction_fullname'] = "North-Northeast";
2212
-		} elseif ($direction >= 45 && $direction < 67.5){
2212
+		} elseif ($direction >= 45 && $direction < 67.5) {
2213 2213
 			$temp_array['direction_degree'] = $direction;
2214 2214
 			$temp_array['direction_shortname'] = "NE";
2215 2215
 			$temp_array['direction_fullname'] = "Northeast";
2216
-		} elseif ($direction >= 67.5 && $direction < 90){
2216
+		} elseif ($direction >= 67.5 && $direction < 90) {
2217 2217
 			$temp_array['direction_degree'] = $direction;
2218 2218
 			$temp_array['direction_shortname'] = "ENE";
2219 2219
 			$temp_array['direction_fullname'] = "East-Northeast";
2220
-		} elseif ($direction >= 90 && $direction < 112.5){
2220
+		} elseif ($direction >= 90 && $direction < 112.5) {
2221 2221
 			$temp_array['direction_degree'] = $direction;
2222 2222
 			$temp_array['direction_shortname'] = "E";
2223 2223
 			$temp_array['direction_fullname'] = "East";
2224
-		} elseif ($direction >= 112.5 && $direction < 135){
2224
+		} elseif ($direction >= 112.5 && $direction < 135) {
2225 2225
 			$temp_array['direction_degree'] = $direction;
2226 2226
 			$temp_array['direction_shortname'] = "ESE";
2227 2227
 			$temp_array['direction_fullname'] = "East-Southeast";
2228
-		} elseif ($direction >= 135 && $direction < 157.5){
2228
+		} elseif ($direction >= 135 && $direction < 157.5) {
2229 2229
 			$temp_array['direction_degree'] = $direction;
2230 2230
 			$temp_array['direction_shortname'] = "SE";
2231 2231
 			$temp_array['direction_fullname'] = "Southeast";
2232
-		} elseif ($direction >= 157.5 && $direction < 180){
2232
+		} elseif ($direction >= 157.5 && $direction < 180) {
2233 2233
 			$temp_array['direction_degree'] = $direction;
2234 2234
 			$temp_array['direction_shortname'] = "SSE";
2235 2235
 			$temp_array['direction_fullname'] = "South-Southeast";
2236
-		} elseif ($direction >= 180 && $direction < 202.5){
2236
+		} elseif ($direction >= 180 && $direction < 202.5) {
2237 2237
 			$temp_array['direction_degree'] = $direction;
2238 2238
 			$temp_array['direction_shortname'] = "S";
2239 2239
 			$temp_array['direction_fullname'] = "South";
2240
-		} elseif ($direction >= 202.5 && $direction < 225){
2240
+		} elseif ($direction >= 202.5 && $direction < 225) {
2241 2241
 			$temp_array['direction_degree'] = $direction;
2242 2242
 			$temp_array['direction_shortname'] = "SSW";
2243 2243
 			$temp_array['direction_fullname'] = "South-Southwest";
2244
-		} elseif ($direction >= 225 && $direction < 247.5){
2244
+		} elseif ($direction >= 225 && $direction < 247.5) {
2245 2245
 			$temp_array['direction_degree'] = $direction;
2246 2246
 			$temp_array['direction_shortname'] = "SW";
2247 2247
 			$temp_array['direction_fullname'] = "Southwest";
2248
-		} elseif ($direction >= 247.5 && $direction < 270){
2248
+		} elseif ($direction >= 247.5 && $direction < 270) {
2249 2249
 			$temp_array['direction_degree'] = $direction;
2250 2250
 			$temp_array['direction_shortname'] = "WSW";
2251 2251
 			$temp_array['direction_fullname'] = "West-Southwest";
2252
-		} elseif ($direction >= 270 && $direction < 292.5){
2252
+		} elseif ($direction >= 270 && $direction < 292.5) {
2253 2253
 			$temp_array['direction_degree'] = $direction;
2254 2254
 			$temp_array['direction_shortname'] = "W";
2255 2255
 			$temp_array['direction_fullname'] = "West";
2256
-		} elseif ($direction >= 292.5 && $direction < 315){
2256
+		} elseif ($direction >= 292.5 && $direction < 315) {
2257 2257
 			$temp_array['direction_degree'] = $direction;
2258 2258
 			$temp_array['direction_shortname'] = "WNW";
2259 2259
 			$temp_array['direction_fullname'] = "West-Northwest";
2260
-		} elseif ($direction >= 315 && $direction < 337.5){
2260
+		} elseif ($direction >= 315 && $direction < 337.5) {
2261 2261
 			$temp_array['direction_degree'] = $direction;
2262 2262
 			$temp_array['direction_shortname'] = "NW";
2263 2263
 			$temp_array['direction_fullname'] = "Northwest";
2264
-		} elseif ($direction >= 337.5 && $direction < 360){
2264
+		} elseif ($direction >= 337.5 && $direction < 360) {
2265 2265
 			$temp_array['direction_degree'] = $direction;
2266 2266
 			$temp_array['direction_shortname'] = "NNW";
2267 2267
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -2278,11 +2278,11 @@  discard block
 block discarded – undo
2278 2278
 	* @param Float $longitude longitute of the flight
2279 2279
 	* @return String the countrie
2280 2280
 	*/
2281
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
2281
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
2282 2282
 	{
2283 2283
 		global $globalDBdriver, $globalDebug;
2284
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2285
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2284
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2285
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2286 2286
 	
2287 2287
 		$Connection = new Connection($this->db);
2288 2288
 		if (!$Connection->tableExists('countries')) return '';
@@ -2322,7 +2322,7 @@  discard block
 block discarded – undo
2322 2322
 	public function getCountryFromISO2($iso2)
2323 2323
 	{
2324 2324
 		global $globalDBdriver, $globalDebug;
2325
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
2325
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
2326 2326
 	
2327 2327
 		$Connection = new Connection($this->db);
2328 2328
 		if (!$Connection->tableExists('countries')) return '';
@@ -2370,7 +2370,7 @@  discard block
 block discarded – undo
2370 2370
 		
2371 2371
 		$bitly_data = json_decode($bitly_data);
2372 2372
 		$bitly_url = '';
2373
-		if ($bitly_data->status_txt = "OK"){
2373
+		if ($bitly_data->status_txt = "OK") {
2374 2374
 			$bitly_url = $bitly_data->data->url;
2375 2375
 		}
2376 2376
 
@@ -2384,11 +2384,11 @@  discard block
 block discarded – undo
2384 2384
 	* @return Array the vessel type list
2385 2385
 	*
2386 2386
 	*/
2387
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
2387
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
2388 2388
 	{
2389 2389
 		global $globalDBdriver;
2390
-		$filter_query = $this->getFilter($filters,true,true);
2391
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
2390
+		$filter_query = $this->getFilter($filters, true, true);
2391
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
2392 2392
 		    FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL";
2393 2393
 		if ($olderthanmonths > 0) {
2394 2394
 			if ($globalDBdriver == 'mysql') {
@@ -2408,28 +2408,28 @@  discard block
 block discarded – undo
2408 2408
 		if ($year != '') {
2409 2409
 			if ($globalDBdriver == 'mysql') {
2410 2410
 				$query .= " AND YEAR(marine_output.date) = :year";
2411
-				$query_values = array_merge($query_values,array(':year' => $year));
2411
+				$query_values = array_merge($query_values, array(':year' => $year));
2412 2412
 			} else {
2413 2413
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2414
-				$query_values = array_merge($query_values,array(':year' => $year));
2414
+				$query_values = array_merge($query_values, array(':year' => $year));
2415 2415
 			}
2416 2416
 		}
2417 2417
 		if ($month != '') {
2418 2418
 			if ($globalDBdriver == 'mysql') {
2419 2419
 				$query .= " AND MONTH(marine_output.date) = :month";
2420
-				$query_values = array_merge($query_values,array(':month' => $month));
2420
+				$query_values = array_merge($query_values, array(':month' => $month));
2421 2421
 			} else {
2422 2422
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2423
-				$query_values = array_merge($query_values,array(':month' => $month));
2423
+				$query_values = array_merge($query_values, array(':month' => $month));
2424 2424
 			}
2425 2425
 		}
2426 2426
 		if ($day != '') {
2427 2427
 			if ($globalDBdriver == 'mysql') {
2428 2428
 				$query .= " AND DAY(marine_output.date) = :day";
2429
-				$query_values = array_merge($query_values,array(':day' => $day));
2429
+				$query_values = array_merge($query_values, array(':day' => $day));
2430 2430
 			} else {
2431 2431
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
2432
-				$query_values = array_merge($query_values,array(':day' => $day));
2432
+				$query_values = array_merge($query_values, array(':day' => $day));
2433 2433
 			}
2434 2434
 		}
2435 2435
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
@@ -2438,9 +2438,9 @@  discard block
 block discarded – undo
2438 2438
 		$sth->execute($query_values);
2439 2439
 		$marine_array = array();
2440 2440
 		$temp_array = array();
2441
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2441
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2442 2442
 		{
2443
-			$temp_array['marine_type'] = html_entity_decode($row['marine_type'],ENT_QUOTES);
2443
+			$temp_array['marine_type'] = html_entity_decode($row['marine_type'], ENT_QUOTES);
2444 2444
 			$temp_array['marine_type_id'] = $row['marine_type_id'];
2445 2445
 			$temp_array['marine_type_count'] = $row['marine_type_count'];
2446 2446
 			$marine_array[] = $temp_array;
@@ -2454,13 +2454,13 @@  discard block
 block discarded – undo
2454 2454
 	* @return Array the tracker information
2455 2455
 	*
2456 2456
 	*/
2457
-	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())
2457
+	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())
2458 2458
 	{
2459 2459
 		global $globalTimezone, $globalDBdriver;
2460 2460
 		date_default_timezone_set('UTC');
2461 2461
 		$query_values = array();
2462 2462
 		$additional_query = '';
2463
-		$filter_query = $this->getFilter($filters,true,true);
2463
+		$filter_query = $this->getFilter($filters, true, true);
2464 2464
 		if ($q != "")
2465 2465
 		{
2466 2466
 			if (!is_string($q))
@@ -2468,8 +2468,8 @@  discard block
 block discarded – undo
2468 2468
 				return false;
2469 2469
 			} else {
2470 2470
 				$q_array = explode(" ", $q);
2471
-				foreach ($q_array as $q_item){
2472
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
2471
+				foreach ($q_array as $q_item) {
2472
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
2473 2473
 					$additional_query .= " AND (";
2474 2474
 					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2475 2475
 					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
@@ -2485,86 +2485,86 @@  discard block
 block discarded – undo
2485 2485
 		}
2486 2486
 		if ($callsign != "")
2487 2487
 		{
2488
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2488
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2489 2489
 			if (!is_string($callsign))
2490 2490
 			{
2491 2491
 				return false;
2492 2492
 			} else {
2493 2493
 				$additional_query .= " AND marine_output.ident = :callsign";
2494
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
2494
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
2495 2495
 			}
2496 2496
 		}
2497 2497
 		if ($mmsi != "")
2498 2498
 		{
2499
-			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
2499
+			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
2500 2500
 			if (!is_numeric($mmsi))
2501 2501
 			{
2502 2502
 				return false;
2503 2503
 			} else {
2504 2504
 				$additional_query .= " AND marine_output.mmsi = :mmsi";
2505
-				$query_values = array_merge($query_values,array(':mmsi' => $mmsi));
2505
+				$query_values = array_merge($query_values, array(':mmsi' => $mmsi));
2506 2506
 			}
2507 2507
 		}
2508 2508
 		if ($imo != "")
2509 2509
 		{
2510
-			$imo = filter_var($imo,FILTER_SANITIZE_STRING);
2510
+			$imo = filter_var($imo, FILTER_SANITIZE_STRING);
2511 2511
 			if (!is_numeric($imo))
2512 2512
 			{
2513 2513
 				return false;
2514 2514
 			} else {
2515 2515
 				$additional_query .= " AND marine_output.imo = :imo";
2516
-				$query_values = array_merge($query_values,array(':imo' => $imo));
2516
+				$query_values = array_merge($query_values, array(':imo' => $imo));
2517 2517
 			}
2518 2518
 		}
2519 2519
 		if ($captain_id != "")
2520 2520
 		{
2521
-			$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
2521
+			$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
2522 2522
 			if (!is_numeric($captain_id))
2523 2523
 			{
2524 2524
 				return false;
2525 2525
 			} else {
2526 2526
 				$additional_query .= " AND marine_output.captain_id = :captain_id";
2527
-				$query_values = array_merge($query_values,array(':captain_id' => $captain_id));
2527
+				$query_values = array_merge($query_values, array(':captain_id' => $captain_id));
2528 2528
 			}
2529 2529
 		}
2530 2530
 		if ($race_id != "")
2531 2531
 		{
2532
-			$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
2532
+			$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
2533 2533
 			if (!is_numeric($race_id))
2534 2534
 			{
2535 2535
 				return false;
2536 2536
 			} else {
2537 2537
 				$additional_query .= " AND marine_output.race_id = :race_id";
2538
-				$query_values = array_merge($query_values,array(':race_id' => $race_id));
2538
+				$query_values = array_merge($query_values, array(':race_id' => $race_id));
2539 2539
 			}
2540 2540
 		}
2541 2541
 		if ($captain_name != "")
2542 2542
 		{
2543
-			$captain_id = filter_var($captain_name,FILTER_SANITIZE_STRING);
2543
+			$captain_id = filter_var($captain_name, FILTER_SANITIZE_STRING);
2544 2544
 			if (!is_string($captain_name))
2545 2545
 			{
2546 2546
 				return false;
2547 2547
 			} else {
2548 2548
 				$additional_query .= " AND marine_output.captain_name = :captain_name";
2549
-				$query_values = array_merge($query_values,array(':captain_name' => $captain_name));
2549
+				$query_values = array_merge($query_values, array(':captain_name' => $captain_name));
2550 2550
 			}
2551 2551
 		}
2552 2552
 		if ($race_name != "")
2553 2553
 		{
2554
-			$race_id = filter_var($race_name,FILTER_SANITIZE_STRING);
2554
+			$race_id = filter_var($race_name, FILTER_SANITIZE_STRING);
2555 2555
 			if (!is_numeric($race_name))
2556 2556
 			{
2557 2557
 				return false;
2558 2558
 			} else {
2559 2559
 				$additional_query .= " AND marine_output.race_name = :race_name";
2560
-				$query_values = array_merge($query_values,array(':race_name' => $race_name));
2560
+				$query_values = array_merge($query_values, array(':race_name' => $race_name));
2561 2561
 			}
2562 2562
 		}
2563 2563
 		if ($date_posted != "")
2564 2564
 		{
2565 2565
 			$date_array = explode(",", $date_posted);
2566
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
2567
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
2566
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
2567
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
2568 2568
 			if ($globalTimezone != '') {
2569 2569
 				date_default_timezone_set($globalTimezone);
2570 2570
 				$datetime = new DateTime();
@@ -2591,8 +2591,8 @@  discard block
 block discarded – undo
2591 2591
 		if ($limit != "")
2592 2592
 		{
2593 2593
 			$limit_array = explode(",", $limit);
2594
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
2595
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
2594
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
2595
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
2596 2596
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2597 2597
 			{
2598 2598
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -2610,22 +2610,22 @@  discard block
 block discarded – undo
2610 2610
 			}
2611 2611
 		}
2612 2612
 		if ($origLat != "" && $origLon != "" && $dist != "") {
2613
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
2613
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
2614 2614
 			if ($globalDBdriver == 'mysql') {
2615
-				$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 
2615
+				$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 
2616 2616
 				    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)) 
2617 2617
 				    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;
2618 2618
 			} else {
2619
-				$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 
2619
+				$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 
2620 2620
 				    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)) 
2621 2621
 				    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;
2622 2622
 			}
2623 2623
 		} else {
2624
-			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2624
+			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2625 2625
 			    ".$additional_query."
2626 2626
 			    ".$orderby_query;
2627 2627
 		}
2628
-		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query);
2628
+		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query);
2629 2629
 		return $marine_array;
2630 2630
 	}
2631 2631
 
@@ -2638,12 +2638,12 @@  discard block
 block discarded – undo
2638 2638
 	public function checkId($id)
2639 2639
 	{
2640 2640
 		global $globalDBdriver, $globalTimezone;
2641
-		$query  = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
2641
+		$query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
2642 2642
 		$query_data = array(':id' => $id);
2643 2643
 		$sth = $this->db->prepare($query);
2644 2644
 		$sth->execute($query_data);
2645
-		$ident_result='';
2646
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2645
+		$ident_result = '';
2646
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2647 2647
 		{
2648 2648
 			$ident_result = $row['fammarine_id'];
2649 2649
 		}
@@ -2658,7 +2658,7 @@  discard block
 block discarded – undo
2658 2658
 	*/
2659 2659
 	public function getRaceByName($race_name)
2660 2660
 	{
2661
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2661
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2662 2662
 		$query  = "SELECT * FROM marine_race WHERE race_name = :race_name LIMIT 1";
2663 2663
 		$sth = $this->db->prepare($query);
2664 2664
 		$sth->execute(array(':race_name' => $race_name));
@@ -2675,7 +2675,7 @@  discard block
 block discarded – undo
2675 2675
 	*/
2676 2676
 	public function getRace($race_id)
2677 2677
 	{
2678
-		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
2678
+		$race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT);
2679 2679
 		$query  = "SELECT * FROM marine_race WHERE race_id = :race_id LIMIT 1";
2680 2680
 		$sth = $this->db->prepare($query);
2681 2681
 		$sth->execute(array(':race_id' => $race_id));
@@ -2688,24 +2688,24 @@  discard block
 block discarded – undo
2688 2688
 	* Add race
2689 2689
 	*
2690 2690
 	*/
2691
-	public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers)
2691
+	public function addRace($race_id, $race_name, $race_creator, $race_desc, $race_startdate, $race_markers)
2692 2692
 	{
2693
-		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
2693
+		$race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT);
2694 2694
 		if ($race_id != '') {
2695
-			$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2696
-			$race_creator = filter_var($race_creator,FILTER_SANITIZE_STRING);
2697
-			$race_desc = filter_var($race_desc,FILTER_SANITIZE_STRING);
2698
-			$race_startdate = filter_var($race_startdate,FILTER_SANITIZE_STRING);
2695
+			$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2696
+			$race_creator = filter_var($race_creator, FILTER_SANITIZE_STRING);
2697
+			$race_desc = filter_var($race_desc, FILTER_SANITIZE_STRING);
2698
+			$race_startdate = filter_var($race_startdate, FILTER_SANITIZE_STRING);
2699 2699
 			//$race_markers = filter_var($race_markers,FILTER_SANITIZE_STRING);
2700 2700
 			$allrace = $this->getRace($race_id);
2701 2701
 			if (empty($allrace)) {
2702 2702
 				$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)";
2703 2703
 				$sth = $this->db->prepare($query);
2704
-				$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));
2704
+				$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));
2705 2705
 			} elseif ($race_id != '') {
2706
-				$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";
2706
+				$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";
2707 2707
 				$sth = $this->db->prepare($query);
2708
-				$sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers));
2708
+				$sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers));
2709 2709
 			}
2710 2710
 		}
2711 2711
 	}
@@ -2714,7 +2714,7 @@  discard block
 block discarded – undo
2714 2714
 
2715 2715
 	public function getOrderBy()
2716 2716
 	{
2717
-		$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"));
2717
+		$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"));
2718 2718
 		
2719 2719
 		return $orderby;
2720 2720
 		
Please login to merge, or discard this patch.
Braces   +282 added lines, -100 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@  discard block
 block discarded – undo
15 15
 	public function __construct($dbc = null) {
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-		if ($this->db === null) die('Error: No DB connection. (Marine)');
18
+		if ($this->db === null) {
19
+			die('Error: No DB connection. (Marine)');
20
+		}
19 21
 	}
20 22
 
21 23
 	/**
@@ -37,7 +39,9 @@  discard block
 block discarded – undo
37 39
 		if (isset($filter[0]['source'])) {
38 40
 			$filters = array_merge($filters,$filter);
39 41
 		}
40
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
42
+		if (is_array($globalFilter)) {
43
+			$filter = array_merge($filter,$globalFilter);
44
+		}
41 45
 		$filter_query_join = '';
42 46
 		$filter_query_where = '';
43 47
 		foreach($filters as $flt) {
@@ -85,8 +89,11 @@  discard block
 block discarded – undo
85 89
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
86 90
 			}
87 91
 		}
88
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
89
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
92
+		if ($filter_query_where == '' && $where) {
93
+			$filter_query_where = ' WHERE';
94
+		} elseif ($filter_query_where != '' && $and) {
95
+			$filter_query_where .= ' AND';
96
+		}
90 97
 		if ($filter_query_where != '') {
91 98
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
92 99
 		}
@@ -141,42 +148,84 @@  discard block
 block discarded – undo
141 148
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
142 149
 			} elseif (isset($row['spotter_archive_output_id'])) {
143 150
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
144
-			*/} 
145
-			elseif (isset($row['marineid'])) {
151
+			*/} elseif (isset($row['marineid'])) {
146 152
 				$temp_array['marine_id'] = $row['marineid'];
147 153
 			} else {
148 154
 				$temp_array['marine_id'] = '';
149 155
 			}
150
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
151
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
152
-			if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES);
153
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
154
-			if (isset($row['status'])) $temp_array['status'] = $row['status'];
155
-			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
156
-			if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id'];
157
-			if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name'];
158
-			if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id'];
159
-			if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name'];
160
-			if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) $temp_array['race_time'] = $row['race_time'];
161
-			if (isset($row['race_rank'])) $temp_array['race_rank'] = $row['race_rank'];
162
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
163
-			if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name'];
164
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
165
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
166
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
167
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
156
+			if (isset($row['fammarine_id'])) {
157
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
158
+			}
159
+			if (isset($row['mmsi'])) {
160
+				$temp_array['mmsi'] = $row['mmsi'];
161
+			}
162
+			if (isset($row['type'])) {
163
+				$temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES);
164
+			}
165
+			if (isset($row['type_id'])) {
166
+				$temp_array['type_id'] = $row['type_id'];
167
+			}
168
+			if (isset($row['status'])) {
169
+				$temp_array['status'] = $row['status'];
170
+			}
171
+			if (isset($row['status_id'])) {
172
+				$temp_array['status_id'] = $row['status_id'];
173
+			}
174
+			if (isset($row['captain_id'])) {
175
+				$temp_array['captain_id'] = $row['captain_id'];
176
+			}
177
+			if (isset($row['captain_name'])) {
178
+				$temp_array['captain_name'] = $row['captain_name'];
179
+			}
180
+			if (isset($row['race_id'])) {
181
+				$temp_array['race_id'] = $row['race_id'];
182
+			}
183
+			if (isset($row['race_name'])) {
184
+				$temp_array['race_name'] = $row['race_name'];
185
+			}
186
+			if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) {
187
+				$temp_array['race_time'] = $row['race_time'];
188
+			}
189
+			if (isset($row['race_rank'])) {
190
+				$temp_array['race_rank'] = $row['race_rank'];
191
+			}
192
+			if (isset($row['ident'])) {
193
+				$temp_array['ident'] = $row['ident'];
194
+			}
195
+			if (isset($row['arrival_port_name'])) {
196
+				$temp_array['arrival_port_name'] = $row['arrival_port_name'];
197
+			}
198
+			if (isset($row['latitude'])) {
199
+				$temp_array['latitude'] = $row['latitude'];
200
+			}
201
+			if (isset($row['longitude'])) {
202
+				$temp_array['longitude'] = $row['longitude'];
203
+			}
204
+			if (isset($row['distance']) && $row['distance'] != '') {
205
+				$temp_array['distance'] = $row['distance'];
206
+			}
207
+			if (isset($row['format_source'])) {
208
+				$temp_array['format_source'] = $row['format_source'];
209
+			}
168 210
 			if (isset($row['heading'])) {
169 211
 				$temp_array['heading'] = $row['heading'];
170 212
 				$heading_direction = $this->parseDirection($row['heading']);
171
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
213
+				if (isset($heading_direction[0]['direction_fullname'])) {
214
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
215
+				}
216
+			}
217
+			if (isset($row['ground_speed'])) {
218
+				$temp_array['ground_speed'] = $row['ground_speed'];
172 219
 			}
173
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
174 220
 
175 221
 			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
176 222
 			{
177 223
 				$Image = new Image($this->db);
178
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
179
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
224
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
225
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
226
+				} else {
227
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
228
+				}
180 229
 				unset($Image);
181 230
 				if (count($image_array) > 0) {
182 231
 					$temp_array['image'] = $image_array[0]['image'];
@@ -240,13 +289,21 @@  discard block
 block discarded – undo
240 289
 			}
241 290
 			
242 291
 			$fromsource = NULL;
243
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
244
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
245
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
292
+			if (isset($row['source_name']) && $row['source_name'] != '') {
293
+				$temp_array['source_name'] = $row['source_name'];
294
+			}
295
+			if (isset($row['over_country']) && $row['over_country'] != '') {
296
+				$temp_array['over_country'] = $row['over_country'];
297
+			}
298
+			if (isset($row['distance']) && $row['distance'] != '') {
299
+				$temp_array['distance'] = $row['distance'];
300
+			}
246 301
 			$temp_array['query_number_rows'] = $num_rows;
247 302
 			$spotter_array[] = $temp_array;
248 303
 		}
249
-		if ($num_rows == 0) return array();
304
+		if ($num_rows == 0) {
305
+			return array();
306
+		}
250 307
 		$spotter_array[0]['query_number_rows'] = $num_rows;
251 308
 		return $spotter_array;
252 309
 	}	
@@ -272,8 +329,12 @@  discard block
 block discarded – undo
272 329
 			{
273 330
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
274 331
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
275
-			} else $limit_query = "";
276
-		} else $limit_query = "";
332
+			} else {
333
+				$limit_query = "";
334
+			}
335
+		} else {
336
+			$limit_query = "";
337
+		}
277 338
 		if ($sort != "")
278 339
 		{
279 340
 			$search_orderby_array = $this->getOrderBy();
@@ -297,7 +358,9 @@  discard block
 block discarded – undo
297 358
 		global $global_marine_query;
298 359
 		
299 360
 		date_default_timezone_set('UTC');
300
-		if ($id == '') return array();
361
+		if ($id == '') {
362
+			return array();
363
+		}
301 364
 		$additional_query = "marine_output.fammarine_id = :id";
302 365
 		$query_values = array(':id' => $id);
303 366
 		$query  = $global_marine_query." WHERE ".$additional_query." ";
@@ -745,8 +808,11 @@  discard block
 block discarded – undo
745 808
 		$sth = $this->db->prepare($query);
746 809
 		$sth->execute($query_values);
747 810
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
748
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
749
-		else return $result[0]['duration'];
811
+		if (is_int($result[0]['duration'])) {
812
+			return gmdate('H:i:s',$result[0]['duration']);
813
+		} else {
814
+			return $result[0]['duration'];
815
+		}
750 816
 	}
751 817
 
752 818
 	/**
@@ -790,7 +856,9 @@  discard block
 block discarded – undo
790 856
 			}
791 857
 		}
792 858
 		$query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC";
793
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
859
+		if ($limit) {
860
+			$query .= " LIMIT 10 OFFSET 0";
861
+		}
794 862
 		$sth = $this->db->prepare($query);
795 863
 		$sth->execute($query_values);
796 864
 		//if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
@@ -869,8 +937,11 @@  discard block
 block discarded – undo
869 937
 		$query .= " ORDER BY marine_output.source_name ASC";
870 938
 
871 939
 		$sth = $this->db->prepare($query);
872
-		if (!empty($query_values)) $sth->execute($query_values);
873
-		else $sth->execute();
940
+		if (!empty($query_values)) {
941
+			$sth->execute($query_values);
942
+		} else {
943
+			$sth->execute();
944
+		}
874 945
 
875 946
 		$source_array = array();
876 947
 		$temp_array = array();
@@ -925,8 +996,11 @@  discard block
 block discarded – undo
925 996
 		$sth = $this->db->prepare($query);
926 997
 		$sth->execute(array(':mmsi' => $mmsi));
927 998
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
928
-		if (isset($result[0])) return $result[0];
929
-		else return array();
999
+		if (isset($result[0])) {
1000
+			return $result[0];
1001
+		} else {
1002
+			return array();
1003
+		}
930 1004
 	}
931 1005
 
932 1006
 	/**
@@ -967,7 +1041,9 @@  discard block
 block discarded – undo
967 1041
 			date_default_timezone_set($globalTimezone);
968 1042
 			$datetime = new DateTime();
969 1043
 			$offset = $datetime->format('P');
970
-		} else $offset = '+00:00';
1044
+		} else {
1045
+			$offset = '+00:00';
1046
+		}
971 1047
 
972 1048
 		if ($globalDBdriver == 'mysql') {
973 1049
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -1074,8 +1150,12 @@  discard block
 block discarded – undo
1074 1150
 	*/	
1075 1151
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1076 1152
 	{
1077
-		if ($latitude == '') $latitude = NULL;
1078
-		if ($longitude == '') $longitude = NULL;
1153
+		if ($latitude == '') {
1154
+			$latitude = NULL;
1155
+		}
1156
+		if ($longitude == '') {
1157
+			$longitude = NULL;
1158
+		}
1079 1159
 		$groundspeed = round($groundspeed);
1080 1160
 		if ($race_begin != '') {
1081 1161
 			$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';
@@ -1228,14 +1308,28 @@  discard block
 block discarded – undo
1228 1308
 			$latitude = 0;
1229 1309
 			$longitude = 0;
1230 1310
 		}
1231
-		if ($type_id == '') $type_id = NULL;
1232
-		if ($status_id == '') $status_id = NULL;
1233
-		if ($distance == '') $distance = NULL;
1234
-		if ($race_rank == '') $race_rank = NULL;
1235
-		if ($race_time == '') $race_time = NULL;
1236
-		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1311
+		if ($type_id == '') {
1312
+			$type_id = NULL;
1313
+		}
1314
+		if ($status_id == '') {
1315
+			$status_id = NULL;
1316
+		}
1317
+		if ($distance == '') {
1318
+			$distance = NULL;
1319
+		}
1320
+		if ($race_rank == '') {
1321
+			$race_rank = NULL;
1322
+		}
1323
+		if ($race_time == '') {
1324
+			$race_time = NULL;
1325
+		}
1326
+		if ($heading == '' || $Common->isInteger($heading) === false) {
1327
+			$heading = 0;
1328
+		}
1237 1329
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1238
-		if ($arrival_date == '') $arrival_date = NULL;
1330
+		if ($arrival_date == '') {
1331
+			$arrival_date = NULL;
1332
+		}
1239 1333
 		$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) 
1240 1334
 		    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)";
1241 1335
 
@@ -1342,7 +1436,9 @@  discard block
 block discarded – undo
1342 1436
 		global $globalDBdriver, $globalArchive;
1343 1437
 		//$filter_query = $this->getFilter($filters,true,true);
1344 1438
 		$Connection= new Connection($this->db);
1345
-		if (!$Connection->tableExists('countries')) return array();
1439
+		if (!$Connection->tableExists('countries')) {
1440
+			return array();
1441
+		}
1346 1442
 		require_once('class.SpotterLive.php');
1347 1443
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
1348 1444
 			$MarineLive = new MarineLive($this->db);
@@ -1386,7 +1482,9 @@  discard block
 block discarded – undo
1386 1482
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
1387 1483
 		}
1388 1484
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
1389
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1485
+		if ($limit) {
1486
+			$query .= " LIMIT 10 OFFSET 0";
1487
+		}
1390 1488
 
1391 1489
 		$sth = $this->db->prepare($query);
1392 1490
 		$sth->execute();
@@ -1420,12 +1518,18 @@  discard block
 block discarded – undo
1420 1518
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1421 1519
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1422 1520
 		 if ($olderthanmonths > 0) {
1423
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1424
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1521
+			if ($globalDBdriver == 'mysql') {
1522
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1523
+			} else {
1524
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1525
+			}
1425 1526
 		}
1426 1527
 		if ($sincedate != '') {
1427
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
1428
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1528
+			if ($globalDBdriver == 'mysql') {
1529
+				$query .= " AND marine_output.date > '".$sincedate."'";
1530
+			} else {
1531
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1532
+			}
1429 1533
 		}
1430 1534
 		$query_values = array();
1431 1535
 		if ($year != '') {
@@ -1456,7 +1560,9 @@  discard block
 block discarded – undo
1456 1560
 			}
1457 1561
 		}
1458 1562
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
1459
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1563
+		if ($limit) {
1564
+			$query .= " LIMIT 10 OFFSET 0";
1565
+		}
1460 1566
       		
1461 1567
 		$sth = $this->db->prepare($query);
1462 1568
 		$sth->execute($query_values);
@@ -1491,7 +1597,9 @@  discard block
 block discarded – undo
1491 1597
 			date_default_timezone_set($globalTimezone);
1492 1598
 			$datetime = new DateTime();
1493 1599
 			$offset = $datetime->format('P');
1494
-		} else $offset = '+00:00';
1600
+		} else {
1601
+			$offset = '+00:00';
1602
+		}
1495 1603
 
1496 1604
 		if ($globalDBdriver == 'mysql') {
1497 1605
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1541,7 +1649,9 @@  discard block
 block discarded – undo
1541 1649
 			date_default_timezone_set($globalTimezone);
1542 1650
 			$datetime = new DateTime();
1543 1651
 			$offset = $datetime->format('P');
1544
-		} else $offset = '+00:00';
1652
+		} else {
1653
+			$offset = '+00:00';
1654
+		}
1545 1655
 		$filter_query = $this->getFilter($filters,true,true);
1546 1656
 		if ($globalDBdriver == 'mysql') {
1547 1657
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1587,7 +1697,9 @@  discard block
 block discarded – undo
1587 1697
 			date_default_timezone_set($globalTimezone);
1588 1698
 			$datetime = new DateTime();
1589 1699
 			$offset = $datetime->format('P');
1590
-		} else $offset = '+00:00';
1700
+		} else {
1701
+			$offset = '+00:00';
1702
+		}
1591 1703
 		$filter_query = $this->getFilter($filters,true,true);
1592 1704
 		if ($globalDBdriver == 'mysql') {
1593 1705
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1635,7 +1747,9 @@  discard block
 block discarded – undo
1635 1747
 			date_default_timezone_set($globalTimezone);
1636 1748
 			$datetime = new DateTime();
1637 1749
 			$offset = $datetime->format('P');
1638
-		} else $offset = '+00:00';
1750
+		} else {
1751
+			$offset = '+00:00';
1752
+		}
1639 1753
 
1640 1754
 		if ($globalDBdriver == 'mysql') {
1641 1755
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1684,7 +1798,9 @@  discard block
 block discarded – undo
1684 1798
 			date_default_timezone_set($globalTimezone);
1685 1799
 			$datetime = new DateTime();
1686 1800
 			$offset = $datetime->format('P');
1687
-		} else $offset = '+00:00';
1801
+		} else {
1802
+			$offset = '+00:00';
1803
+		}
1688 1804
 		$filter_query = $this->getFilter($filters,true,true);
1689 1805
 		if ($globalDBdriver == 'mysql') {
1690 1806
 			$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
@@ -1733,7 +1849,9 @@  discard block
 block discarded – undo
1733 1849
 			date_default_timezone_set($globalTimezone);
1734 1850
 			$datetime = new DateTime();
1735 1851
 			$offset = $datetime->format('P');
1736
-		} else $offset = '+00:00';
1852
+		} else {
1853
+			$offset = '+00:00';
1854
+		}
1737 1855
 
1738 1856
 		$orderby_sql = '';
1739 1857
 		if ($orderby == "hour")
@@ -1802,7 +1920,9 @@  discard block
 block discarded – undo
1802 1920
 			date_default_timezone_set($globalTimezone);
1803 1921
 			$datetime = new DateTime($date);
1804 1922
 			$offset = $datetime->format('P');
1805
-		} else $offset = '+00:00';
1923
+		} else {
1924
+			$offset = '+00:00';
1925
+		}
1806 1926
 
1807 1927
 		if ($globalDBdriver == 'mysql') {
1808 1928
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1850,7 +1970,9 @@  discard block
 block discarded – undo
1850 1970
 			date_default_timezone_set($globalTimezone);
1851 1971
 			$datetime = new DateTime();
1852 1972
 			$offset = $datetime->format('P');
1853
-		} else $offset = '+00:00';
1973
+		} else {
1974
+			$offset = '+00:00';
1975
+		}
1854 1976
 
1855 1977
 		if ($globalDBdriver == 'mysql') {
1856 1978
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1909,7 +2031,9 @@  discard block
 block discarded – undo
1909 2031
 			}
1910 2032
 		}
1911 2033
 		$query .= " GROUP BY marine_output.race_id,marine_output.race_name ORDER BY captain_count DESC";
1912
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2034
+		if ($limit) {
2035
+			$query .= " LIMIT 10 OFFSET 0";
2036
+		}
1913 2037
 		$sth = $this->db->prepare($query);
1914 2038
 		$sth->execute();
1915 2039
 		$marine_array = array();
@@ -1956,8 +2080,11 @@  discard block
 block discarded – undo
1956 2080
 				$query_values = array_merge($query_values,array(':month' => $month));
1957 2081
 			}
1958 2082
 		}
1959
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1960
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2083
+		if (empty($query_values)) {
2084
+			$queryi .= $this->getFilter($filters);
2085
+		} else {
2086
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2087
+		}
1961 2088
 		
1962 2089
 		$sth = $this->db->prepare($queryi);
1963 2090
 		$sth->execute($query_values);
@@ -1994,8 +2121,11 @@  discard block
 block discarded – undo
1994 2121
 				$query_values = array_merge($query_values,array(':month' => $month));
1995 2122
 			}
1996 2123
 		}
1997
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1998
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2124
+		if (empty($query_values)) {
2125
+			$queryi .= $this->getFilter($filters);
2126
+		} else {
2127
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2128
+		}
1999 2129
 		
2000 2130
 		$sth = $this->db->prepare($queryi);
2001 2131
 		$sth->execute($query_values);
@@ -2032,8 +2162,11 @@  discard block
 block discarded – undo
2032 2162
 				$query_values = array_merge($query_values,array(':month' => $month));
2033 2163
 			}
2034 2164
 		}
2035
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2036
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2165
+		if (empty($query_values)) {
2166
+			$queryi .= $this->getFilter($filters);
2167
+		} else {
2168
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2169
+		}
2037 2170
 		
2038 2171
 		$sth = $this->db->prepare($queryi);
2039 2172
 		$sth->execute($query_values);
@@ -2070,8 +2203,11 @@  discard block
 block discarded – undo
2070 2203
 				$query_values = array_merge($query_values,array(':month' => $month));
2071 2204
 			}
2072 2205
 		}
2073
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2074
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2206
+		if (empty($query_values)) {
2207
+			$queryi .= $this->getFilter($filters);
2208
+		} else {
2209
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2210
+		}
2075 2211
 		
2076 2212
 		$sth = $this->db->prepare($queryi);
2077 2213
 		$sth->execute($query_values);
@@ -2092,7 +2228,9 @@  discard block
 block discarded – undo
2092 2228
 			date_default_timezone_set($globalTimezone);
2093 2229
 			$datetime = new DateTime();
2094 2230
 			$offset = $datetime->format('P');
2095
-		} else $offset = '+00:00';
2231
+		} else {
2232
+			$offset = '+00:00';
2233
+		}
2096 2234
 
2097 2235
 		if ($globalDBdriver == 'mysql') {
2098 2236
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -2196,7 +2334,9 @@  discard block
 block discarded – undo
2196 2334
 	*/
2197 2335
 	public function parseDirection($direction = 0)
2198 2336
 	{
2199
-		if ($direction == '') $direction = 0;
2337
+		if ($direction == '') {
2338
+			$direction = 0;
2339
+		}
2200 2340
 		$direction_array = array();
2201 2341
 		$temp_array = array();
2202 2342
 
@@ -2285,7 +2425,9 @@  discard block
 block discarded – undo
2285 2425
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2286 2426
 	
2287 2427
 		$Connection = new Connection($this->db);
2288
-		if (!$Connection->tableExists('countries')) return '';
2428
+		if (!$Connection->tableExists('countries')) {
2429
+			return '';
2430
+		}
2289 2431
 	
2290 2432
 		try {
2291 2433
 			/*
@@ -2305,9 +2447,13 @@  discard block
 block discarded – undo
2305 2447
 			$sth->closeCursor();
2306 2448
 			if (count($row) > 0) {
2307 2449
 				return $row;
2308
-			} else return '';
2450
+			} else {
2451
+				return '';
2452
+			}
2309 2453
 		} catch (PDOException $e) {
2310
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2454
+			if (isset($globalDebug) && $globalDebug) {
2455
+				echo 'Error : '.$e->getMessage()."\n";
2456
+			}
2311 2457
 			return '';
2312 2458
 		}
2313 2459
 	
@@ -2325,7 +2471,9 @@  discard block
 block discarded – undo
2325 2471
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
2326 2472
 	
2327 2473
 		$Connection = new Connection($this->db);
2328
-		if (!$Connection->tableExists('countries')) return '';
2474
+		if (!$Connection->tableExists('countries')) {
2475
+			return '';
2476
+		}
2329 2477
 	
2330 2478
 		try {
2331 2479
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -2337,9 +2485,13 @@  discard block
 block discarded – undo
2337 2485
 			$sth->closeCursor();
2338 2486
 			if (count($row) > 0) {
2339 2487
 				return $row;
2340
-			} else return '';
2488
+			} else {
2489
+				return '';
2490
+			}
2341 2491
 		} catch (PDOException $e) {
2342
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2492
+			if (isset($globalDebug) && $globalDebug) {
2493
+				echo 'Error : '.$e->getMessage()."\n";
2494
+			}
2343 2495
 			return '';
2344 2496
 		}
2345 2497
 	
@@ -2357,7 +2509,9 @@  discard block
 block discarded – undo
2357 2509
 	{
2358 2510
 		global $globalBitlyAccessToken;
2359 2511
 		
2360
-		if ($globalBitlyAccessToken == '') return $url;
2512
+		if ($globalBitlyAccessToken == '') {
2513
+			return $url;
2514
+		}
2361 2515
         
2362 2516
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
2363 2517
 		
@@ -2433,7 +2587,9 @@  discard block
 block discarded – undo
2433 2587
 			}
2434 2588
 		}
2435 2589
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
2436
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2590
+		if ($limit) {
2591
+			$query .= " LIMIT 10 OFFSET 0";
2592
+		}
2437 2593
 		$sth = $this->db->prepare($query);
2438 2594
 		$sth->execute($query_values);
2439 2595
 		$marine_array = array();
@@ -2471,13 +2627,27 @@  discard block
 block discarded – undo
2471 2627
 				foreach ($q_array as $q_item){
2472 2628
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
2473 2629
 					$additional_query .= " AND (";
2474
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2475
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2476
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2477
-					if (is_int($q_item)) $additional_query .= "(marine_output.captain_id = '".$q_item."') OR ";
2478
-					if (is_int($q_item)) $additional_query .= "(marine_output.race_id = '".$q_item."') OR ";
2479
-					if (!is_int($q_item)) $additional_query .= "(marine_output.captain_name = '".$q_item."') OR ";
2480
-					if (!is_int($q_item)) $additional_query .= "(marine_output.race_name = '".$q_item."') OR ";
2630
+					if (is_int($q_item)) {
2631
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2632
+					}
2633
+					if (is_int($q_item)) {
2634
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2635
+					}
2636
+					if (is_int($q_item)) {
2637
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2638
+					}
2639
+					if (is_int($q_item)) {
2640
+						$additional_query .= "(marine_output.captain_id = '".$q_item."') OR ";
2641
+					}
2642
+					if (is_int($q_item)) {
2643
+						$additional_query .= "(marine_output.race_id = '".$q_item."') OR ";
2644
+					}
2645
+					if (!is_int($q_item)) {
2646
+						$additional_query .= "(marine_output.captain_name = '".$q_item."') OR ";
2647
+					}
2648
+					if (!is_int($q_item)) {
2649
+						$additional_query .= "(marine_output.race_name = '".$q_item."') OR ";
2650
+					}
2481 2651
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
2482 2652
 					$additional_query .= ")";
2483 2653
 				}
@@ -2569,7 +2739,9 @@  discard block
 block discarded – undo
2569 2739
 				date_default_timezone_set($globalTimezone);
2570 2740
 				$datetime = new DateTime();
2571 2741
 				$offset = $datetime->format('P');
2572
-			} else $offset = '+00:00';
2742
+			} else {
2743
+				$offset = '+00:00';
2744
+			}
2573 2745
 			if ($date_array[1] != "")
2574 2746
 			{
2575 2747
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -2596,8 +2768,12 @@  discard block
 block discarded – undo
2596 2768
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2597 2769
 			{
2598 2770
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
2599
-			} else $limit_query = "";
2600
-		} else $limit_query = "";
2771
+			} else {
2772
+				$limit_query = "";
2773
+			}
2774
+		} else {
2775
+			$limit_query = "";
2776
+		}
2601 2777
 		if ($sort != "")
2602 2778
 		{
2603 2779
 			$search_orderby_array = $this->getOrderBy();
@@ -2663,8 +2839,11 @@  discard block
 block discarded – undo
2663 2839
 		$sth = $this->db->prepare($query);
2664 2840
 		$sth->execute(array(':race_name' => $race_name));
2665 2841
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2666
-		if (isset($result[0])) return $result[0];
2667
-		else return array();
2842
+		if (isset($result[0])) {
2843
+			return $result[0];
2844
+		} else {
2845
+			return array();
2846
+		}
2668 2847
 	}
2669 2848
 
2670 2849
 	/**
@@ -2680,8 +2859,11 @@  discard block
 block discarded – undo
2680 2859
 		$sth = $this->db->prepare($query);
2681 2860
 		$sth->execute(array(':race_id' => $race_id));
2682 2861
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2683
-		if (isset($result[0])) return $result[0];
2684
-		else return array();
2862
+		if (isset($result[0])) {
2863
+			return $result[0];
2864
+		} else {
2865
+			return array();
2866
+		}
2685 2867
 	}
2686 2868
 
2687 2869
 	/**
Please login to merge, or discard this patch.
search.php 3 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -91,32 +91,32 @@
 block discarded – undo
91 91
 $limit_previous_2 = $limit_end - $absolute_difference;
92 92
 
93 93
 if (
94
-    (isset($_GET['q']) && $_GET['q'] != '') || 
95
-    (isset($_GET['registration']) && $_GET['registration'] != '') || 
96
-    (isset($_GET['aircraft']) && $_GET['aircraft'] != '') ||
97
-    (isset($_GET['manufacturer']) && $_GET['manufacturer'] != '') ||
98
-    (isset($_GET['highlights']) && $_GET['highlights'] != '') ||
99
-    (isset($_GET['airline']) && $_GET['airline'] != '') ||
100
-    (isset($_GET['airline_country']) && $_GET['airline_country'] != '') ||
101
-    (isset($_GET['airline_type']) && $_GET['airline_type'] != '') ||
102
-    (isset($_GET['airport']) && $_GET['airport'] != '') ||
103
-    (isset($_GET['airport_country']) && $_GET['airport_country'] != '') ||
104
-    (isset($_GET['callsign']) && $_GET['callsign'] != '') ||
105
-    (isset($_GET['captain_id']) && $_GET['captain_id'] != '') ||
106
-    (isset($_GET['race_id']) && $_GET['race_id'] != '') ||
107
-    (isset($_GET['captain_name']) && $_GET['captain_name'] != '') ||
108
-    (isset($_GET['race_name']) && $_GET['race_name'] != '') ||
109
-    (isset($_GET['owner']) && $_GET['owner'] != '') ||
110
-    (isset($_GET['pilot_name']) && $_GET['pilot_name'] != '') ||
111
-    (isset($_GET['pilot_id']) && $_GET['pilot_id'] != '') ||
112
-    (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != '') ||
113
-    (isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != '') ||
114
-    (isset($_GET['mmsi']) && $_GET['mmsi'] != '') ||
115
-    (isset($_GET['imo']) && $_GET['imo'] != '') ||
116
-    ((isset($_GET['origlat']) && $_GET['origlat'] != '') &&
117
-    (isset($_GET['origlon']) && $_GET['origlon'] != '') &&
118
-    (isset($_GET['dist']) && $_GET['dist'] != ''))
119
-    ){  
94
+	(isset($_GET['q']) && $_GET['q'] != '') || 
95
+	(isset($_GET['registration']) && $_GET['registration'] != '') || 
96
+	(isset($_GET['aircraft']) && $_GET['aircraft'] != '') ||
97
+	(isset($_GET['manufacturer']) && $_GET['manufacturer'] != '') ||
98
+	(isset($_GET['highlights']) && $_GET['highlights'] != '') ||
99
+	(isset($_GET['airline']) && $_GET['airline'] != '') ||
100
+	(isset($_GET['airline_country']) && $_GET['airline_country'] != '') ||
101
+	(isset($_GET['airline_type']) && $_GET['airline_type'] != '') ||
102
+	(isset($_GET['airport']) && $_GET['airport'] != '') ||
103
+	(isset($_GET['airport_country']) && $_GET['airport_country'] != '') ||
104
+	(isset($_GET['callsign']) && $_GET['callsign'] != '') ||
105
+	(isset($_GET['captain_id']) && $_GET['captain_id'] != '') ||
106
+	(isset($_GET['race_id']) && $_GET['race_id'] != '') ||
107
+	(isset($_GET['captain_name']) && $_GET['captain_name'] != '') ||
108
+	(isset($_GET['race_name']) && $_GET['race_name'] != '') ||
109
+	(isset($_GET['owner']) && $_GET['owner'] != '') ||
110
+	(isset($_GET['pilot_name']) && $_GET['pilot_name'] != '') ||
111
+	(isset($_GET['pilot_id']) && $_GET['pilot_id'] != '') ||
112
+	(isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != '') ||
113
+	(isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != '') ||
114
+	(isset($_GET['mmsi']) && $_GET['mmsi'] != '') ||
115
+	(isset($_GET['imo']) && $_GET['imo'] != '') ||
116
+	((isset($_GET['origlat']) && $_GET['origlat'] != '') &&
117
+	(isset($_GET['origlon']) && $_GET['origlon'] != '') &&
118
+	(isset($_GET['dist']) && $_GET['dist'] != ''))
119
+	){  
120 120
 	$q = filter_input(INPUT_GET, 'q',FILTER_SANITIZE_STRING);
121 121
 	$registration = filter_input(INPUT_GET, 'registration',FILTER_SANITIZE_STRING);
122 122
 	$aircraft = filter_input(INPUT_GET, 'aircraft',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -26,24 +26,24 @@  discard block
 block discarded – undo
26 26
 $sql_date = '';
27 27
 if (isset($_GET['start_date'])) {
28 28
 	//for the date manipulation into the query
29
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
29
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
30 30
 		if (strtotime($_GET['start_date']) !== false && strtotime($_GET['end_date']) !== false) {
31 31
 			//$start_date = $_GET['start_date']." 00:00:00";
32
-			$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
32
+			$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
33 33
 			//$end_date = $_GET['end_date']." 00:00:00";
34
-			$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
34
+			$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
35 35
 			$sql_date = $start_date.",".$end_date;
36 36
 		}
37
-	} else if($_GET['start_date'] != ""){
37
+	} else if ($_GET['start_date'] != "") {
38 38
 		if (strtotime($_GET['start_date']) !== false) {
39 39
 			//$start_date = $_GET['start_date']." 00:00:00";
40
-			$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
40
+			$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
41 41
 			$sql_date = $start_date;
42 42
 		}
43
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
43
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
44 44
 		if (strtotime($_GET['end_date']) !== false) {
45 45
 			//$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date']." 00:00:00";
46
-			$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
46
+			$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
47 47
 			$sql_date = $end_date;
48 48
 		}
49 49
 	} else $sql_date = '';
@@ -51,21 +51,21 @@  discard block
 block discarded – undo
51 51
 
52 52
 if (isset($_GET['highest_altitude'])) {
53 53
 	//for altitude manipulation
54
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
55
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
56
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
54
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
55
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
56
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
57 57
 		$sql_altitude = $start_altitude.",".$end_altitude;
58
-	} else if($_GET['highest_altitude'] != ""){
59
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
58
+	} else if ($_GET['highest_altitude'] != "") {
59
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
60 60
 		$sql_altitude = $end_altitude;
61
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
62
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
61
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
62
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
63 63
 		$sql_altitude = $start_altitude;
64 64
 	} else $sql_altitude = '';
65 65
 } else $sql_altitude = '';
66 66
 
67 67
 //calculuation for the pagination
68
-if(!isset($_GET['limit']))
68
+if (!isset($_GET['limit']))
69 69
 {
70 70
 	if (!isset($_GET['number_results']))
71 71
 	{
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 		$limit_end = 25;
74 74
 		$absolute_difference = 25;
75 75
 	} else {
76
-		if ($_GET['number_results'] > 1000){
76
+		if ($_GET['number_results'] > 1000) {
77 77
 			$_GET['number_results'] = 1000;
78 78
 		}
79 79
 		$limit_start = 0;
80
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
81
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
80
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
81
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
82 82
 	}
83
-}  else {
83
+} else {
84 84
 	$limit_explode = explode(",", $_GET['limit']);
85
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
86
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
85
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
86
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
87 87
 }
88 88
 $absolute_difference = abs($limit_start - $limit_end);
89 89
 $limit_next = $limit_end + $absolute_difference;
@@ -116,35 +116,35 @@  discard block
 block discarded – undo
116 116
     ((isset($_GET['origlat']) && $_GET['origlat'] != '') &&
117 117
     (isset($_GET['origlon']) && $_GET['origlon'] != '') &&
118 118
     (isset($_GET['dist']) && $_GET['dist'] != ''))
119
-    ){  
120
-	$q = filter_input(INPUT_GET, 'q',FILTER_SANITIZE_STRING);
121
-	$registration = filter_input(INPUT_GET, 'registration',FILTER_SANITIZE_STRING);
122
-	$aircraft = filter_input(INPUT_GET, 'aircraft',FILTER_SANITIZE_STRING);
123
-	$manufacturer = filter_input(INPUT_GET, 'manufacturer',FILTER_SANITIZE_STRING);
124
-	$highlights = filter_input(INPUT_GET, 'highlights',FILTER_SANITIZE_STRING);
125
-	$airline = filter_input(INPUT_GET, 'airline',FILTER_SANITIZE_STRING);
126
-	$airline_country = filter_input(INPUT_GET, 'airline_country',FILTER_SANITIZE_STRING);
127
-	$airline_type = filter_input(INPUT_GET, 'airline_type',FILTER_SANITIZE_STRING);
128
-	$airport = filter_input(INPUT_GET, 'airport',FILTER_SANITIZE_STRING);
129
-	$airport_country = filter_input(INPUT_GET, 'airport_country',FILTER_SANITIZE_STRING);
130
-	$callsign = filter_input(INPUT_GET, 'callsign',FILTER_SANITIZE_STRING);
131
-	$owner = filter_input(INPUT_GET, 'owner',FILTER_SANITIZE_STRING);
132
-	$pilot_name = filter_input(INPUT_GET, 'pilot_name',FILTER_SANITIZE_STRING);
133
-	$pilot_id = filter_input(INPUT_GET, 'pilot_id',FILTER_SANITIZE_STRING);
134
-	$mmsi = filter_input(INPUT_GET, 'mmsi',FILTER_SANITIZE_NUMBER_INT);
135
-	$imo = filter_input(INPUT_GET, 'imo',FILTER_SANITIZE_NUMBER_INT);
136
-	$captain_id  = filter_input(INPUT_GET, 'captain_id',FILTER_SANITIZE_NUMBER_INT);
137
-	$race_id  = filter_input(INPUT_GET, 'race_id',FILTER_SANITIZE_NUMBER_INT);
138
-	$captain_name  = filter_input(INPUT_GET, 'captain_name',FILTER_SANITIZE_STRING);
139
-	$race_name  = filter_input(INPUT_GET, 'race_name',FILTER_SANITIZE_STRING);
140
-	$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route',FILTER_SANITIZE_STRING);
141
-	$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route',FILTER_SANITIZE_STRING);
142
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
143
-	$archive = filter_input(INPUT_GET,'archive',FILTER_SANITIZE_NUMBER_INT);
144
-	$origlat = filter_input(INPUT_GET,'origlat',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
145
-	$origlon = filter_input(INPUT_GET,'origlon',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
146
-	$dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT);
147
-	$number_results = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
119
+    ) {  
120
+	$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
121
+	$registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING);
122
+	$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
123
+	$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
124
+	$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
125
+	$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
126
+	$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
127
+	$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
128
+	$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
129
+	$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
130
+	$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
131
+	$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
132
+	$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
133
+	$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
134
+	$mmsi = filter_input(INPUT_GET, 'mmsi', FILTER_SANITIZE_NUMBER_INT);
135
+	$imo = filter_input(INPUT_GET, 'imo', FILTER_SANITIZE_NUMBER_INT);
136
+	$captain_id = filter_input(INPUT_GET, 'captain_id', FILTER_SANITIZE_NUMBER_INT);
137
+	$race_id = filter_input(INPUT_GET, 'race_id', FILTER_SANITIZE_NUMBER_INT);
138
+	$captain_name = filter_input(INPUT_GET, 'captain_name', FILTER_SANITIZE_STRING);
139
+	$race_name = filter_input(INPUT_GET, 'race_name', FILTER_SANITIZE_STRING);
140
+	$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
141
+	$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
142
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
143
+	$archive = filter_input(INPUT_GET, 'archive', FILTER_SANITIZE_NUMBER_INT);
144
+	$origlat = filter_input(INPUT_GET, 'origlat', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
145
+	$origlon = filter_input(INPUT_GET, 'origlon', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
146
+	$dist = filter_input(INPUT_GET, 'dist', FILTER_SANITIZE_NUMBER_INT);
147
+	$number_results = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
148 148
 	if ($dist != '') {
149 149
 		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934;
150 150
 		elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852;
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
 	if ($archive == 1) {
154 154
 		if ($type == 'aircraft') {
155 155
 			$SpotterArchive = new SpotterArchive();
156
-			$spotter_array = $SpotterArchive->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist);
156
+			$spotter_array = $SpotterArchive->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist);
157 157
 		}
158 158
 	} else {
159 159
 		if ($type == 'aircraft') {
160
-			$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist);
160
+			$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist);
161 161
 		} elseif ($type == 'tracker') {
162
-			$spotter_array = $Tracker->searchTrackerData($q,$callsign,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist);
162
+			$spotter_array = $Tracker->searchTrackerData($q, $callsign, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist);
163 163
 		} elseif ($type == 'marine') {
164
-			$spotter_array = $Marine->searchMarineData($q,$callsign,$mmsi,$imo,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist,$captain_id,$captain_name,$race_id,$race_name);
164
+			$spotter_array = $Marine->searchMarineData($q, $callsign, $mmsi, $imo, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist, $captain_id, $captain_name, $race_id, $race_name);
165 165
 		}
166 166
 	}
167 167
 	 
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 	//remove 3D=true parameter
198 198
 	$no3D = str_replace("&3D=true", "", $_SERVER['QUERY_STRING']);
199 199
 	$kmlURL = str_replace("http://", "kml://", $globalURL);
200
-	if (!isset($_GET['3D'])){
200
+	if (!isset($_GET['3D'])) {
201 201
 		print '<li><a href="'.$globalURL.'/search?'.$no3D.'" class="active"><i class="fa fa-table"></i> '._("Table").'</a></li>';
202 202
 	} else {
203 203
 		print '<li><span class="notablet"><a href="'.$globalURL.'/search?'.$no3D.'"><i class="fa fa-table"></i> '._("Table").'</a></span></li>';
204 204
 	}
205
-	if (isset($_GET['3D'])){
205
+	if (isset($_GET['3D'])) {
206 206
 		print '<li><a href="'.$globalURL.'/search?'.$no3D.'&3D=true" class="active"><i class="fa fa-globe"></i> '._("3D Map").'</a></li>';
207 207
 	} else {
208 208
 		print '<li ><a href="'.$globalURL.'/search?'.$no3D.'&3D=true" class="notablet nomobile"><i class="fa fa-globe"></i> '._("3D Map").'</a><a href="'.$kmlURL.'/search/kml?'.htmlentities($_SERVER['QUERY_STRING']).'" class="tablet mobile"><i class="fa fa-globe"></i> 3D Map</a></li>';
@@ -223,36 +223,36 @@  discard block
 block discarded – undo
223 223
 		print '<div class="column">';
224 224
 		print '<div class="info">';
225 225
 		print '<h1>'._("Search Results for").' ';
226
-		if (isset($_GET['q']) && $_GET['q'] != ""){ print _("Keyword:").' <span>'.$q.'</span> '; }
227
-		if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
228
-		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
229
-		if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; }
230
-		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; }
231
-		if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; }
232
-		if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; }
233
-		if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; }
234
-		if (isset($_GET['airport']) && $_GET['airport'] != ""){ print _("Airport:").' <span>'.$airport.'</span> '; }
235
-		if (isset($_GET['airport_country']) && $_GET['airport_country'] != ""){ print _("Airport country:").' <span>'.$airport_country.'</span> '; }
236
-		if (isset($_GET['callsign']) && $_GET['callsign'] != ""){ print _("Callsign:").' <span>'.$callsign.'</span> '; }
237
-		if (isset($_GET['owner']) && $_GET['owner'] != ""){ print _("Owner:").' <span>'.$owner.'</span> '; }
238
-		if (isset($_GET['pilot_id']) && $_GET['pilot_id'] != ""){ print _("Pilot id:").' <span>'.$pilot_id.'</span> '; }
239
-		if (isset($_GET['pilot_name']) && $_GET['pilot_name'] != ""){ print _("Pilot name:").' <span>'.$pilot_name.'</span> '; }
240
-		if (isset($_GET['captain_id']) && $_GET['captain_id'] != ""){ print _("Captain id:").' <span>'.$captain_id.'</span> '; }
241
-		if (isset($_GET['captain_name']) && $_GET['captain_name'] != ""){ print _("Captain name:").' <span>'.$captain_name.'</span> '; }
242
-		if (isset($_GET['race_id']) && $_GET['race_id'] != ""){ print _("Race id:").' <span>'.$race_id.'</span> '; }
243
-		if (isset($_GET['race_name']) && $_GET['race_name'] != ""){ print _("Race name:").' <span>'.$race_name.'</span> '; }
244
-		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && (!isset($_GET['arrival_airport_route']) || $_GET['arrival_airport_route'] == "")){ print _("Route out of:").' <span>'.$departure_airport_route.'</span> '; }
245
-		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] == "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != ""){ print _("Route into:").' <span>'.$arrival_airport_route.'</span> '; }
246
-		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != ""){ print _("Route between:").' <span>'.$departure_airport_route.'</span> and <span>'.$_GET['arrival_airport_route'].'</span> '; }
247
-		if (isset($_GET['mmsi']) && $_GET['mmsi'] != ""){ print _("MMSI:").' <span>'.$mmsi.'</span> '; }
248
-		if (isset($_GET['imo']) && $_GET['imo'] != ""){ print _("IMO:").' <span>'.$imo.'</span> '; }
249
-		if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] == ""){ print _("Date starting at:").' <span>'.$start_date.'</span> '; }
250
-		if (isset($_GET['start_date']) && $_GET['start_date'] == "" && isset($_GET['end_date']) && $_GET['end_date'] != ""){ print _("Date ending at:").' <span>'.$end_date.'</span> '; }
251
-		if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] != ""){ print _("Date between:").' <span>'.$start_date.'</span> and <span>'.$end_date.'</span> '; }
252
-		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == ""){ print _("Altitude starting at:").' <span>'.number_format($lowest_altitude).' feet</span> '; }
253
-		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != ""){ print _("Altitude ending at:").' <span>'.number_format($highest_altitude).' feet</span> '; }
254
-		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != ""){ print _("Altitude between:").' <span>'.number_format($lowest_altitude).' feet</span> '._("and").' <span>'.number_format($highest_altitude).' feet</span> '; }
255
-		if (isset($_GET['number_results']) && $_GET['number_results'] != ""){ print _("limit per page:").' <span>'.$number_results.'</span> '; }
226
+		if (isset($_GET['q']) && $_GET['q'] != "") { print _("Keyword:").' <span>'.$q.'</span> '; }
227
+		if (isset($_GET['aircraft']) && $_GET['aircraft'] != "") { print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
228
+		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != "") { print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
229
+		if (isset($_GET['registration']) && $_GET['registration'] != "") { print _("Registration:").' <span>'.$registration.'</span> '; }
230
+		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print _("Highlights:").' <span>'.$highlights.'</span> '; }
231
+		if (isset($_GET['airline']) && $_GET['airline'] != "") { print _("Airline:").' <span>'.$airline.'</span> '; }
232
+		if (isset($_GET['airline_country']) && $_GET['airline_country'] != "") { print _("Airline country:").' <span>'.$airline_country.'</span> '; }
233
+		if (isset($_GET['airline_type']) && $_GET['airline_type'] != "") { print _("Airline type:").' <span>'.$airline_type.'</span> '; }
234
+		if (isset($_GET['airport']) && $_GET['airport'] != "") { print _("Airport:").' <span>'.$airport.'</span> '; }
235
+		if (isset($_GET['airport_country']) && $_GET['airport_country'] != "") { print _("Airport country:").' <span>'.$airport_country.'</span> '; }
236
+		if (isset($_GET['callsign']) && $_GET['callsign'] != "") { print _("Callsign:").' <span>'.$callsign.'</span> '; }
237
+		if (isset($_GET['owner']) && $_GET['owner'] != "") { print _("Owner:").' <span>'.$owner.'</span> '; }
238
+		if (isset($_GET['pilot_id']) && $_GET['pilot_id'] != "") { print _("Pilot id:").' <span>'.$pilot_id.'</span> '; }
239
+		if (isset($_GET['pilot_name']) && $_GET['pilot_name'] != "") { print _("Pilot name:").' <span>'.$pilot_name.'</span> '; }
240
+		if (isset($_GET['captain_id']) && $_GET['captain_id'] != "") { print _("Captain id:").' <span>'.$captain_id.'</span> '; }
241
+		if (isset($_GET['captain_name']) && $_GET['captain_name'] != "") { print _("Captain name:").' <span>'.$captain_name.'</span> '; }
242
+		if (isset($_GET['race_id']) && $_GET['race_id'] != "") { print _("Race id:").' <span>'.$race_id.'</span> '; }
243
+		if (isset($_GET['race_name']) && $_GET['race_name'] != "") { print _("Race name:").' <span>'.$race_name.'</span> '; }
244
+		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && (!isset($_GET['arrival_airport_route']) || $_GET['arrival_airport_route'] == "")) { print _("Route out of:").' <span>'.$departure_airport_route.'</span> '; }
245
+		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] == "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != "") { print _("Route into:").' <span>'.$arrival_airport_route.'</span> '; }
246
+		if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != "") { print _("Route between:").' <span>'.$departure_airport_route.'</span> and <span>'.$_GET['arrival_airport_route'].'</span> '; }
247
+		if (isset($_GET['mmsi']) && $_GET['mmsi'] != "") { print _("MMSI:").' <span>'.$mmsi.'</span> '; }
248
+		if (isset($_GET['imo']) && $_GET['imo'] != "") { print _("IMO:").' <span>'.$imo.'</span> '; }
249
+		if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] == "") { print _("Date starting at:").' <span>'.$start_date.'</span> '; }
250
+		if (isset($_GET['start_date']) && $_GET['start_date'] == "" && isset($_GET['end_date']) && $_GET['end_date'] != "") { print _("Date ending at:").' <span>'.$end_date.'</span> '; }
251
+		if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] != "") { print _("Date between:").' <span>'.$start_date.'</span> and <span>'.$end_date.'</span> '; }
252
+		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == "") { print _("Altitude starting at:").' <span>'.number_format($lowest_altitude).' feet</span> '; }
253
+		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != "") { print _("Altitude ending at:").' <span>'.number_format($highest_altitude).' feet</span> '; }
254
+		if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != "") { print _("Altitude between:").' <span>'.number_format($lowest_altitude).' feet</span> '._("and").' <span>'.number_format($highest_altitude).' feet</span> '; }
255
+		if (isset($_GET['number_results']) && $_GET['number_results'] != "") { print _("limit per page:").' <span>'.$number_results.'</span> '; }
256 256
 		print '</h1>';
257 257
 		print '</div>';
258 258
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 					    </select>
387 387
 					</div>
388 388
 				</div>
389
-				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
389
+				<script type="text/javascript">getSelect('manufacturer','<?php if (isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
390 390
 				<div class="form-group">
391 391
 					<label class="control-label col-sm-2"><?php echo _("Type"); ?></label>
392 392
 						<div class="col-sm-10">
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 							</select>
396 396
 						</div>
397 397
 				</div>
398
-				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
398
+				<script type="text/javascript">getSelect('aircrafttypes','<?php if (isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
399 399
 				<div class="form-group">
400 400
 					<label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> 
401 401
 					<div class="col-sm-10">
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 					</div>
419 419
 				</div>
420 420
 <?php
421
-	}else {
421
+	} else {
422 422
 ?>
423 423
 				<div class="form-group">
424 424
 					<label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> 
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 ?>
432 432
 				<div class="form-group">
433 433
 					<div class="col-sm-offset-2 col-sm-10">
434
-					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
435
-					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
434
+					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
435
+					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print 'checked="checked"'; } ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
436 436
 					</div>
437 437
 				</div>
438 438
 			</fieldset>
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 						</select>
447 447
 					</div>
448 448
 				</div>
449
-				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script>
449
+				<script type="text/javascript">getSelect('airlinenames','<?php if (isset($_GET['airline'])) print $airline; ?>');</script>
450 450
 				<div class="form-group">
451 451
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
452 452
 					<div class="col-sm-10">
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 						</select>
456 456
 					</div>
457 457
 				</div>
458
-				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script>
458
+				<script type="text/javascript">getSelect('airlinecountries','<?php if (isset($_GET['airline_country'])) print $airline_country; ?>');</script>
459 459
 				<div class="form-group">
460 460
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
461 461
 					<div class="col-sm-10">
@@ -464,10 +464,10 @@  discard block
 block discarded – undo
464 464
 				</div>
465 465
 				<div class="form-group">
466 466
 					<div class="col-sm-offset-2 col-sm-10">
467
-						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
468
-						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
469
-						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
470
-						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
467
+						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all") { print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
468
+						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger") { print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
469
+						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "cargo") { print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
470
+						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "military") { print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
471 471
 					</div>
472 472
 				</div>
473 473
 			</fieldset>
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 						</select>
482 482
 					</div>
483 483
 				</div>
484
-				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
484
+				<script type="text/javascript">getSelect('airportnames','<?php if (isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
485 485
 				<div class="form-group">
486 486
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
487 487
 					<div class="col-sm-10">
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 						</select>
491 491
 					</div>
492 492
 				</div>
493
-				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script>
493
+				<script type="text/javascript">getSelect('airportcountries','<?php if (isset($_GET['airport_country'])) print $airport_country; ?>');</script>
494 494
 			</fieldset>
495 495
 			<fieldset>
496 496
 				<legend><?php echo _("Route"); ?></legend>
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 						</select>
503 503
 					</div>
504 504
 				</div>
505
-				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
505
+				<script type="text/javascript">getSelect('departureairportnames','<?php if (isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
506 506
 				<div class="form-group">
507 507
 					<label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> 
508 508
 					<div class="col-sm-10">
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 						</select>
512 512
 					</div>
513 513
 				</div>
514
-				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
514
+				<script type="text/javascript">getSelect('arrivalairportnames','<?php if (isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
515 515
 			</fieldset>
516 516
 			<fieldset>
517 517
 				<legend>Altitude</legend>
@@ -522,9 +522,9 @@  discard block
 block discarded – undo
522 522
 							<option></option>
523 523
 <?php
524 524
 $altitude_array = Array(1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000);
525
-foreach($altitude_array as $altitude)
525
+foreach ($altitude_array as $altitude)
526 526
 {
527
-	if(isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == $altitude)
527
+	if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == $altitude)
528 528
 	{
529 529
 		print '<option value="'.$altitude.'" selected="selected">'.number_format($altitude).' feet</option>';
530 530
 	} else {
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
 							<option></option>
543 543
 <?php
544 544
 	$altitude_array = Array(1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000);
545
-	foreach($altitude_array as $altitude)
545
+	foreach ($altitude_array as $altitude)
546 546
 	{
547
-		if(isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == $altitude)
547
+		if (isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == $altitude)
548 548
 		{
549 549
 			print '<option value="'.$altitude.'" selected="selected">'.number_format($altitude).' feet</option>';
550 550
 		} else {
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
 				<div class="col-sm-10">
707 707
 					<select class="form-control" name="number_results">
708 708
 <?php
709
-$number_results_array = Array(25, 50, 100, 150, 200, 250, 300, 400, 500,  600, 700, 800, 900, 1000);
710
-foreach($number_results_array as $number)
709
+$number_results_array = Array(25, 50, 100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900, 1000);
710
+foreach ($number_results_array as $number)
711 711
 {
712
-	if(isset($_GET['number_results']) && $_GET['number_results'] == $number)
712
+	if (isset($_GET['number_results']) && $_GET['number_results'] == $number)
713 713
 	{
714 714
 		print '<option value="'.$number.'" selected="selected">'.$number.'</option>';
715 715
 	} else {
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 		<fieldset>
729 729
 			<div class="form-group">
730 730
 				<div class="col-sm-offset-2 col-sm-10">
731
-					<label class="checkbox-inline"><input type="checkbox" name="archive" value="1" disabled /><?php echo sprintf(_("Search in archive (older than %s months)"),$globalArchiveKeepMonths); ?></label>
731
+					<label class="checkbox-inline"><input type="checkbox" name="archive" value="1" disabled /><?php echo sprintf(_("Search in archive (older than %s months)"), $globalArchiveKeepMonths); ?></label>
732 732
 					<p class="help-block">Disabled in demo</p>
733 733
 				</div>
734 734
 			</div>
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 		<fieldset>
740 740
 			<div class="form-group">
741 741
 				<div class="col-sm-offset-2 col-sm-10">
742
-					<label class="checkbox-inline"><input type="checkbox" name="archive" value="1" /><?php echo sprintf(_("Search in archive (older than %s months)"),$globalArchiveKeepMonths); ?></label>
742
+					<label class="checkbox-inline"><input type="checkbox" name="archive" value="1" /><?php echo sprintf(_("Search in archive (older than %s months)"), $globalArchiveKeepMonths); ?></label>
743 743
 				</div>
744 744
 			</div>
745 745
 		</fieldset>
Please login to merge, or discard this patch.
Braces   +158 added lines, -43 removed lines patch added patch discarded remove patch
@@ -46,8 +46,10 @@  discard block
 block discarded – undo
46 46
 			$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
47 47
 			$sql_date = $end_date;
48 48
 		}
49
-	} else $sql_date = '';
50
-}
49
+	} else {
50
+		$sql_date = '';
51
+	}
52
+	}
51 53
 
52 54
 if (isset($_GET['highest_altitude'])) {
53 55
 	//for altitude manipulation
@@ -61,8 +63,12 @@  discard block
 block discarded – undo
61 63
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
62 64
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
63 65
 		$sql_altitude = $start_altitude;
64
-	} else $sql_altitude = '';
65
-} else $sql_altitude = '';
66
+	} else {
67
+		$sql_altitude = '';
68
+	}
69
+	} else {
70
+	$sql_altitude = '';
71
+}
66 72
 
67 73
 //calculuation for the pagination
68 74
 if(!isset($_GET['limit']))
@@ -80,7 +86,7 @@  discard block
 block discarded – undo
80 86
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
81 87
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
82 88
 	}
83
-}  else {
89
+} else {
84 90
 	$limit_explode = explode(",", $_GET['limit']);
85 91
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
86 92
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -146,10 +152,15 @@  discard block
 block discarded – undo
146 152
 	$dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT);
147 153
 	$number_results = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
148 154
 	if ($dist != '') {
149
-		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934;
150
-		elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852;
155
+		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') {
156
+			$dist = $dist*1.60934;
157
+		} elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') {
158
+			$dist = $dist*1.852;
159
+		}
160
+	}
161
+	if (!isset($sql_date)) {
162
+		$sql_date = '';
151 163
 	}
152
-	if (!isset($sql_date)) $sql_date = '';
153 164
 	if ($archive == 1) {
154 165
 		if ($type == 'aircraft') {
155 166
 			$SpotterArchive = new SpotterArchive();
@@ -227,7 +238,10 @@  discard block
 block discarded – undo
227 238
 		if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
228 239
 		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
229 240
 		if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; }
230
-		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; }
241
+		if (isset($_GET['highlights'])) {
242
+			if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> ';
243
+		}
244
+		}
231 245
 		if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; }
232 246
 		if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; }
233 247
 		if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; }
@@ -367,7 +381,10 @@  discard block
 block discarded – undo
367 381
 			<div class="form-group">
368 382
 				<label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label>
369 383
 				<div class="col-sm-10">
370
-					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $q; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
384
+					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) {
385
+	print $q;
386
+}
387
+?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
371 388
 				</div>
372 389
 			</div>
373 390
 		</fieldset>
@@ -386,7 +403,10 @@  discard block
 block discarded – undo
386 403
 					    </select>
387 404
 					</div>
388 405
 				</div>
389
-				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
406
+				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) {
407
+	print $manufacturer;
408
+}
409
+?>')</script>
390 410
 				<div class="form-group">
391 411
 					<label class="control-label col-sm-2"><?php echo _("Type"); ?></label>
392 412
 						<div class="col-sm-10">
@@ -395,11 +415,17 @@  discard block
 block discarded – undo
395 415
 							</select>
396 416
 						</div>
397 417
 				</div>
398
-				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
418
+				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) {
419
+	print $aircraft_icao;
420
+}
421
+?>');</script>
399 422
 				<div class="form-group">
400 423
 					<label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> 
401 424
 					<div class="col-sm-10">
402
-						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $registration; ?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
425
+						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) {
426
+	print $registration;
427
+}
428
+?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
403 429
 					</div>
404 430
 				</div>
405 431
 <?php
@@ -408,22 +434,31 @@  discard block
 block discarded – undo
408 434
 				<div class="form-group">
409 435
 					<label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> 
410 436
 					<div class="col-sm-10">
411
-						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $pilot_id; ?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
437
+						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) {
438
+	print $pilot_id;
439
+}
440
+?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
412 441
 					</div>
413 442
 				</div>
414 443
 				<div class="form-group">
415 444
 					<label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> 
416 445
 					<div class="col-sm-10">
417
-						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $pilot_name; ?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
446
+						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) {
447
+	print $pilot_name;
448
+}
449
+?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
418 450
 					</div>
419 451
 				</div>
420 452
 <?php
421
-	}else {
453
+	} else {
422 454
 ?>
423 455
 				<div class="form-group">
424 456
 					<label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> 
425 457
 					<div class="col-sm-10">
426
-						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $owner; ?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
458
+						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) {
459
+	print $owner;
460
+}
461
+?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
427 462
 					</div>
428 463
 				</div>
429 464
 <?php
@@ -431,8 +466,14 @@  discard block
 block discarded – undo
431 466
 ?>
432 467
 				<div class="form-group">
433 468
 					<div class="col-sm-offset-2 col-sm-10">
434
-					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
435
-					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
469
+					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
470
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
471
+}
472
+} ?>> <label for="highlights"><?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
473
+					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
474
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
475
+}
476
+} ?>> <?php echo _("Include only aircraft with special highlights (unique liveries, destinations etc.)"); ?></label>
436 477
 					</div>
437 478
 				</div>
438 479
 			</fieldset>
@@ -446,7 +487,10 @@  discard block
 block discarded – undo
446 487
 						</select>
447 488
 					</div>
448 489
 				</div>
449
-				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script>
490
+				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) {
491
+	print $airline;
492
+}
493
+?>');</script>
450 494
 				<div class="form-group">
451 495
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
452 496
 					<div class="col-sm-10">
@@ -455,19 +499,34 @@  discard block
 block discarded – undo
455 499
 						</select>
456 500
 					</div>
457 501
 				</div>
458
-				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script>
502
+				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) {
503
+	print $airline_country;
504
+}
505
+?>');</script>
459 506
 				<div class="form-group">
460 507
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
461 508
 					<div class="col-sm-10">
462
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
509
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
510
+	print $callsign;
511
+}
512
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
463 513
 					</div>
464 514
 				</div>
465 515
 				<div class="form-group">
466 516
 					<div class="col-sm-offset-2 col-sm-10">
467 517
 						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
468
-						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
469
-						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
470
-						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
518
+						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) {
519
+	if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"';
520
+}
521
+} ?>> <?php echo _("Only Passenger airlines"); ?></label>
522
+						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) {
523
+	if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"';
524
+}
525
+} ?>> <?php echo _("Only Cargo airlines"); ?></label>
526
+						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) {
527
+	if ( $_GET['airline_type'] == "military"){ print 'checked="checked"';
528
+}
529
+} ?>> <?php echo _("Only Military airlines"); ?></label>
471 530
 					</div>
472 531
 				</div>
473 532
 			</fieldset>
@@ -481,7 +540,10 @@  discard block
 block discarded – undo
481 540
 						</select>
482 541
 					</div>
483 542
 				</div>
484
-				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
543
+				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) {
544
+	print $airport_icao;
545
+}
546
+?>');</script>
485 547
 				<div class="form-group">
486 548
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
487 549
 					<div class="col-sm-10">
@@ -490,7 +552,10 @@  discard block
 block discarded – undo
490 552
 						</select>
491 553
 					</div>
492 554
 				</div>
493
-				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script>
555
+				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) {
556
+	print $airport_country;
557
+}
558
+?>');</script>
494 559
 			</fieldset>
495 560
 			<fieldset>
496 561
 				<legend><?php echo _("Route"); ?></legend>
@@ -502,7 +567,10 @@  discard block
 block discarded – undo
502 567
 						</select>
503 568
 					</div>
504 569
 				</div>
505
-				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
570
+				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) {
571
+	print $departure_airport_route;
572
+}
573
+?>');</script>
506 574
 				<div class="form-group">
507 575
 					<label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> 
508 576
 					<div class="col-sm-10">
@@ -511,7 +579,10 @@  discard block
 block discarded – undo
511 579
 						</select>
512 580
 					</div>
513 581
 				</div>
514
-				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
582
+				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) {
583
+	print $arrival_airport_route;
584
+}
585
+?>');</script>
515 586
 			</fieldset>
516 587
 			<fieldset>
517 588
 				<legend>Altitude</legend>
@@ -561,19 +632,33 @@  discard block
 block discarded – undo
561 632
 				<div class="form-group">
562 633
 					<label class="control-label col-sm-2"><?php echo _("Latitude"); ?></label>
563 634
 					<div class="col-sm-10">
564
-						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) print $origlat; ?>" />
635
+						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) {
636
+	print $origlat;
637
+}
638
+?>" />
565 639
 					</div>
566 640
 				</div>
567 641
 				<div class="form-group">
568 642
 					<label class="control-label col-sm-2"><?php echo _("Longitude"); ?></label>
569 643
 					<div class="col-sm-10">
570
-						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) print $origlon; ?>" />
644
+						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) {
645
+	print $origlon;
646
+}
647
+?>" />
571 648
 					</div>
572 649
 				</div>
573 650
 				<div class="form-group">
574
-					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label>
651
+					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) {
652
+	print $globalDistanceUnit;
653
+} else {
654
+	print 'km';
655
+}
656
+print ')'; ?></label>
575 657
 					<div class="col-sm-10">
576
-						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) print $distance; ?>" />
658
+						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) {
659
+	print $distance;
660
+}
661
+?>" />
577 662
 					</div>
578 663
 				</div>
579 664
 			</fieldset>
@@ -584,7 +669,10 @@  discard block
 block discarded – undo
584 669
 				<div class="form-group">
585 670
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
586 671
 					<div class="col-sm-10">
587
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
672
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
673
+	print $callsign;
674
+}
675
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
588 676
 					</div>
589 677
 				</div>
590 678
 			</fieldset>
@@ -595,7 +683,10 @@  discard block
 block discarded – undo
595 683
 				<div class="form-group">
596 684
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
597 685
 					<div class="col-sm-10">
598
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
686
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
687
+	print $callsign;
688
+}
689
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
599 690
 					</div>
600 691
 				</div>
601 692
 			</fieldset>
@@ -606,7 +697,10 @@  discard block
 block discarded – undo
606 697
 				<div class="form-group">
607 698
 					<label class="control-label col-sm-2"><?php echo _("Captain id"); ?></label> 
608 699
 					<div class="col-sm-10">
609
-						<input type="text" name="captain_id" class="form-control" value="<?php if (isset($_GET['captain_id'])) print $captain_id; ?>" size="8" placeholder="<?php echo _("Captain id"); ?>" />
700
+						<input type="text" name="captain_id" class="form-control" value="<?php if (isset($_GET['captain_id'])) {
701
+	print $captain_id;
702
+}
703
+?>" size="8" placeholder="<?php echo _("Captain id"); ?>" />
610 704
 					</div>
611 705
 				</div>
612 706
 			</fieldset>
@@ -614,7 +708,10 @@  discard block
 block discarded – undo
614 708
 				<div class="form-group">
615 709
 					<label class="control-label col-sm-2"><?php echo _("Captain name"); ?></label> 
616 710
 					<div class="col-sm-10">
617
-						<input type="text" name="captain_name" class="form-control" value="<?php if (isset($_GET['captain_name'])) print $captain_name; ?>" size="8" placeholder="<?php echo _("Captain name"); ?>" />
711
+						<input type="text" name="captain_name" class="form-control" value="<?php if (isset($_GET['captain_name'])) {
712
+	print $captain_name;
713
+}
714
+?>" size="8" placeholder="<?php echo _("Captain name"); ?>" />
618 715
 					</div>
619 716
 				</div>
620 717
 			</fieldset>
@@ -622,7 +719,10 @@  discard block
 block discarded – undo
622 719
 				<div class="form-group">
623 720
 					<label class="control-label col-sm-2"><?php echo _("Race id"); ?></label> 
624 721
 					<div class="col-sm-10">
625
-						<input type="text" name="race_id" class="form-control" value="<?php if (isset($_GET['race_id'])) print $race_id; ?>" size="8" placeholder="<?php echo _("Race id"); ?>" />
722
+						<input type="text" name="race_id" class="form-control" value="<?php if (isset($_GET['race_id'])) {
723
+	print $race_id;
724
+}
725
+?>" size="8" placeholder="<?php echo _("Race id"); ?>" />
626 726
 					</div>
627 727
 				</div>
628 728
 			</fieldset>
@@ -630,7 +730,10 @@  discard block
 block discarded – undo
630 730
 				<div class="form-group">
631 731
 					<label class="control-label col-sm-2"><?php echo _("Race name"); ?></label> 
632 732
 					<div class="col-sm-10">
633
-						<input type="text" name="race_name" class="form-control" value="<?php if (isset($_GET['race_name'])) print $race_name; ?>" size="8" placeholder="<?php echo _("Race name"); ?>" />
733
+						<input type="text" name="race_name" class="form-control" value="<?php if (isset($_GET['race_name'])) {
734
+	print $race_name;
735
+}
736
+?>" size="8" placeholder="<?php echo _("Race name"); ?>" />
634 737
 					</div>
635 738
 				</div>
636 739
 			</fieldset>
@@ -641,7 +744,10 @@  discard block
 block discarded – undo
641 744
 				<div class="form-group">
642 745
 					<label class="control-label col-sm-2"><?php echo _("MMSI"); ?></label> 
643 746
 					<div class="col-sm-10">
644
-						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) print $mmsi; ?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
747
+						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) {
748
+	print $mmsi;
749
+}
750
+?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
645 751
 					</div>
646 752
 				</div>
647 753
 			</fieldset>
@@ -649,7 +755,10 @@  discard block
 block discarded – undo
649 755
 				<div class="form-group">
650 756
 					<label class="control-label col-sm-2"><?php echo _("IMO"); ?></label> 
651 757
 					<div class="col-sm-10">
652
-						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) print $imo; ?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
758
+						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) {
759
+	print $imo;
760
+}
761
+?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
653 762
 					</div>
654 763
 				</div>
655 764
 			</fieldset>
@@ -663,7 +772,10 @@  discard block
 block discarded – undo
663 772
 					<label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label>
664 773
 					<div class="col-sm-10">
665 774
 						<div class='input-group date' id='datetimepicker1'>
666
-							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') print $start_date; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
775
+							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') {
776
+	print $start_date;
777
+}
778
+?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
667 779
 							<span class="input-group-addon">
668 780
 								<span class="glyphicon glyphicon-calendar"></span>
669 781
 							</span>
@@ -674,7 +786,10 @@  discard block
 block discarded – undo
674 786
 					<label class="control-label col-sm-2"><?php echo _("End Date"); ?></label>
675 787
 					<div class="col-sm-10">
676 788
 						<div class='input-group date' id='datetimepicker2'>
677
-						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') print $end_date; ?>" placeholder="<?php echo _("End Date/Time"); ?>" />
789
+						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') {
790
+	print $end_date;
791
+}
792
+?>" placeholder="<?php echo _("End Date/Time"); ?>" />
678 793
 						<span class="input-group-addon">
679 794
 							<span class="glyphicon glyphicon-calendar"></span>
680 795
 						</span>
Please login to merge, or discard this patch.
live-geojson.php 2 patches
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
 $min = true;
65 65
 $allhistory = false;
66 66
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
68
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
69
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
71
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
72
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
73
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
74
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
75
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
76
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
77
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
78
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'], FILTER_SANITIZE_NUMBER_INT);
79 79
 
80 80
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
81 81
 	$min = true;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 $spotter_array = array();
85 85
 
86 86
 if (isset($_GET['ident'])) {
87
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
87
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
88 88
 	if ($tracker) {
89 89
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
90 90
 	} elseif ($marine) {
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 	$allhistory = true;
100 100
 } elseif (isset($_GET['flightaware_id'])) {
101
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
101
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
102 102
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
103 103
 	if (empty($spotter_array)) {
104 104
 		$from_archive = true;
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 	$allhistory = true;
108 108
 } elseif (isset($_GET['famtrack_id'])) {
109
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
109
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
110 110
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
111 111
 	$allhistory = true;
112 112
 } elseif (isset($_GET['fammarine_id'])) {
113
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
113
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
114 114
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
115 115
 	$allhistory = true;
116 116
 /*
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
 */
131 131
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min && !isset($_GET['archive'])) {
132 132
 	$usecoord = true;
133
-	$coord = explode(',',$_GET['coord']);
134
-	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
133
+	$coord = explode(',', $_GET['coord']);
134
+	if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
135 135
 	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
136 136
 		if ($tracker) {
137
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
137
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
138 138
 		} elseif ($marine) {
139
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
139
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
140 140
 		} else {
141
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
141
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
142 142
 		}
143 143
 	} else {
144 144
 		if ($tracker) {
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 	$from_archive = true;
154 154
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
155 155
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
156
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
157
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
158
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
159
-	$begindate = date('Y-m-d H:i:s',$begindate);
160
-	$enddate = date('Y-m-d H:i:s',$enddate);
161
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
156
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
157
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
158
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
159
+	$begindate = date('Y-m-d H:i:s', $begindate);
160
+	$enddate = date('Y-m-d H:i:s', $enddate);
161
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
162 162
 } elseif ($min) {
163 163
 	if ($tracker) {
164 164
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 #	$min = true;
171 171
 } else {
172 172
 	if ($tracker) {
173
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
173
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
174 174
 	} elseif ($marine) {
175
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
175
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
176 176
 	} else {
177
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
177
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
178 178
 	}
179 179
 }
180 180
 
181 181
 if ($usecoord) {
182 182
 	if (isset($_GET['archive'])) {
183
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
183
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
184 184
 	} else {
185 185
 		if ($tracker) {
186 186
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	if ($flightcnt == '') $flightcnt = 0;
194 194
 } else $flightcnt = 0;
195 195
 
196
-$sqltime = round(microtime(true)-$begintime,2);
196
+$sqltime = round(microtime(true) - $begintime, 2);
197 197
 
198
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
198
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
199 199
 if ($currenttime != '') $currenttime = round($currenttime/1000);
200 200
 
201 201
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		if (!empty($spotter_array) && is_array($spotter_array))
215 215
 		{
216 216
 			$output .= '"features": [';
217
-			foreach($spotter_array as $spotter_item)
217
+			foreach ($spotter_array as $spotter_item)
218 218
 			{
219 219
 				$j++;
220 220
 				unset($idistance);
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 */
272 272
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
273 273
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
274
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
275
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
274
+							if ($compress) $output .= '"c": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
275
+							else $output .= '"callsign": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
276 276
 							//'
277 277
 						} else {
278 278
 							if ($compress) $output .= '"c": "NA",';
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 						}
285 285
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
286 286
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
287
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
287
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
288 288
 						} elseif (isset($spotter_item['aircraft_type'])) {
289 289
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
290 290
 						} elseif (!$min) {
@@ -370,19 +370,19 @@  discard block
 block discarded – undo
370 370
 									else $output .= '"aircraft_shadow": "car.png",';
371 371
 								}
372 372
 							} elseif ($marine) {
373
-								if (isset($spotter_item['type']) && ($spotter_item['type']  == '50&#39; Performance Cruiser' || $spotter_item['type']  == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
373
+								if (isset($spotter_item['type']) && ($spotter_item['type'] == '50&#39; Performance Cruiser' || $spotter_item['type'] == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
374 374
 									if ($compress) $output .= '"as": "50perfcruiser.png",';
375 375
 									else $output .= '"aircraft_shadow": "50perfcruiser.png",';
376
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Sailaway Cruiser 38') {
376
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Sailaway Cruiser 38') {
377 377
 									if ($compress) $output .= '"as": "cruiser38.png",';
378 378
 									else $output .= '"aircraft_shadow": "cruiser38.png",';
379
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Mini Transat') {
379
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Mini Transat') {
380 380
 									if ($compress) $output .= '"as": "transat.png",';
381 381
 									else $output .= '"aircraft_shadow": "transat.png",';
382
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == '52&#39; Cruising Cat') {
382
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == '52&#39; Cruising Cat') {
383 383
 									if ($compress) $output .= '"as": "catamaran.png",';
384 384
 									else $output .= '"aircraft_shadow": "catamaran.png",';
385
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Caribbean Rose') {
385
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Caribbean Rose') {
386 386
 									if ($compress) $output .= '"as": "carib.png",';
387 387
 									else $output .= '"aircraft_shadow": "carib.png",';
388 388
 								} else {
@@ -448,15 +448,15 @@  discard block
 block discarded – undo
448 448
 						if (isset($archivespeed) || $usenextlatlon) {
449 449
 							if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
450 450
 								if (isset($spotter_item['arrival_airport_latitude'])) {
451
-									$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
452
-									$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
451
+									$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
452
+									$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
453 453
 									$farr_lat = $spotter_item['arrival_airport_latitude'];
454 454
 									$farr_lon = $spotter_item['arrival_airport_longitude'];
455 455
 								} else {
456 456
 									$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
457 457
 									if (isset($aairport[0]['latitude'])) {
458
-										$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
459
-										$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
458
+										$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
459
+										$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
460 460
 										$farr_lat = $aairport[0]['latitude'];
461 461
 										$farr_lon = $aairport[0]['longitude'];
462 462
 									}
@@ -469,59 +469,59 @@  discard block
 block discarded – undo
469 469
 						if ($currenttime != '') {
470 470
 							if (strtotime($spotter_item['date']) < $currenttime) {
471 471
 								if (isset($archivespeed)) {
472
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
473
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
472
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
473
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
474 474
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
475 475
 									else {
476
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
477
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
476
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
477
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
478 478
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
479 479
 										else {
480
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
480
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
481 481
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
482 482
 										}
483 483
 									}
484 484
 								} elseif ($usenextlatlon) {
485
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
486
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
485
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
486
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
487 487
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
488 488
 									else {
489
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
490
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
489
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
490
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
491 491
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
492 492
 										else {
493
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
493
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
494 494
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
495 495
 										}
496 496
 									}
497 497
 								}
498 498
 							} else {
499 499
 								if (isset($archivespeed)) {
500
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
500
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
501 501
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
502 502
 								} elseif ($usenextlatlon) {
503
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
503
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
504 504
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
505 505
 								}
506 506
 							}
507 507
 						} else {
508 508
 							if (isset($archivespeed)) {
509
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
510
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
509
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
510
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
511 511
 								if (!isset($idistance) || $fdistance < $idistance) {
512 512
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
513 513
 								} else {
514
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed);
514
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed);
515 515
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
516 516
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
517 517
 								}
518 518
 							} elseif ($usenextlatlon) {
519
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
520
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
519
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
520
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
521 521
 								if (!isset($idistance) || $fdistance < $idistance) {
522 522
 										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
523 523
 								} else {
524
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading);
524
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading);
525 525
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
526 526
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
527 527
 								}
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 
531 531
 						if (!$min) $output .= '"image": "'.$image.'",';
532 532
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
533
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
533
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
534 534
 						}
535 535
 						if (isset($spotter_item['image_source_website'])) {
536 536
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
565 565
 						}
566 566
 						if (isset($spotter_item['acars'])) {
567
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
567
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
568 568
 						}
569 569
 						// type when not aircraft ?
570 570
 						if (isset($spotter_item['type'])) {
@@ -584,12 +584,12 @@  discard block
 block discarded – undo
584 584
 								if ($currenttime != '') {
585 585
 									if (strtotime($spotter_item['date']) < $currenttime) {
586 586
 										if (!isset($archivespeed)) $archivespeed = 1;
587
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
588
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
587
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
588
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
589 589
 										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
590 590
 										else {
591
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
592
-											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
591
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
592
+											$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
593 593
 											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
594 594
 											else {
595 595
 												$output .= $spotter_item['longitude'].', ';
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
                 
669 669
 			}
670 670
 */
671
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
671
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
672 672
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
673 673
 				
674 674
 				if (
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
677 677
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
678 678
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
679
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
679
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
680 680
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
681
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
681
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
682 682
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
683
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
683
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
684 684
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
685 685
 				    ) {
686 686
 					if ($tracker) {
@@ -709,9 +709,9 @@  discard block
 block discarded – undo
709 709
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
710 710
 							$MapMatching = new MapMatching();
711 711
 							if (isset($spotter_item['date_iso_8601'])) {
712
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601'])))));
712
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date_iso_8601'])))));
713 713
 							} else {
714
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date'])))));
714
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date'])))));
715 715
 							}
716 716
 							$spotter_history_array = $MapMatching->match($spotter_history_array_mm);
717 717
 						}
@@ -743,9 +743,9 @@  discard block
 block discarded – undo
743 743
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
744 744
 							}
745 745
 							$output_history .= '[';
746
-							$output_history .=  $spotter_history['longitude'].', ';
747
-							$output_history .=  $spotter_history['latitude'].', ';
748
-							$output_history .=  $spotter_history['altitude']*30.48;
746
+							$output_history .= $spotter_history['longitude'].', ';
747
+							$output_history .= $spotter_history['latitude'].', ';
748
+							$output_history .= $spotter_history['altitude']*30.48;
749 749
 							$output_history .= '],';
750 750
 							/*
751 751
 							if ($from_archive === false) {
@@ -768,8 +768,8 @@  discard block
 block discarded – undo
768 768
 								$d = true;
769 769
 							}
770 770
 							$output_history .= '[';
771
-							$output_history .=  $spotter_history['longitude'].', ';
772
-							$output_history .=  $spotter_history['latitude'];
771
+							$output_history .= $spotter_history['longitude'].', ';
772
+							$output_history .= $spotter_history['latitude'];
773 773
 							$output_history .= '],';
774 774
 							/*
775 775
 							if ($from_archive === false) {
@@ -785,9 +785,9 @@  discard block
 block discarded – undo
785 785
 						//echo $output_history;
786 786
 						if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) {
787 787
 							$output_historyd = '[';
788
-							$output_historyd .=  $spotter_item['longitude'].', ';
789
-							$output_historyd .=  $spotter_item['latitude'];
790
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
788
+							$output_historyd .= $spotter_item['longitude'].', ';
789
+							$output_historyd .= $spotter_item['latitude'];
790
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
791 791
 							$output_historyd .= '],';
792 792
 							//$output_history = $output_historyd.$output_history;
793 793
 							$output_history = $output_history.$output_historyd;
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 							$last = array_pop($spotter_history_array);
796 796
 							$latitude = $last['latitude'];
797 797
 							$longitude = $last['longitude'];
798
-							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output);
798
+							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output);
799 799
 						}
800 800
 						
801 801
 						$output_history  = substr($output_history, 0, -1);
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 					
808 808
 				}
809 809
 				
810
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
810
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
811 811
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
812 812
 				     && (isset($spotter_item['departure_airport']) 
813 813
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 
842 842
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
843 843
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
844
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
844
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
845 845
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
846 846
 				     && (isset($spotter_item['arrival_airport']) 
847 847
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -868,11 +868,11 @@  discard block
 block discarded – undo
868 868
 					}
869 869
 				    }
870 870
 				    if ($havedata) {
871
-					$line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon);
871
+					$line = $Common->greatCircle($spotter_item['latitude'], $spotter_item['longitude'], $end_lat, $end_lon);
872 872
 					foreach ($line[0] as $coord) {
873 873
 						$output_dest .= '['.$coord[0].','.$coord[1].'],';
874 874
 					}
875
-					$output_dest  = substr($output_dest, 0, -1);
875
+					$output_dest = substr($output_dest, 0, -1);
876 876
 				    }
877 877
 				    $output_dest .= ']}},';
878 878
 				    if ($havedata) $output .= $output_dest;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 			$output  = substr($output, 0, -1);
883 883
 			$output .= ']';
884 884
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
885
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
885
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
886 886
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
887 887
 			$output .= '"fc": "'.$j.'"';
888 888
 		} else {
Please login to merge, or discard this patch.
Braces   +361 added lines, -146 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,29 +59,58 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $from_archive = false;
64 69
 $min = true;
65 70
 $allhistory = false;
66 71
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
77
+}
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
83
+}
84
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
86
+}
87
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
88
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
91
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
94
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
97
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
100
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
103
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
104
+}
105
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') {
106
+	$filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
107
+}
79 108
 
80 109
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
81 110
 	$min = true;
82
-} else $min = false;
111
+} else {
112
+	$min = false;
113
+}
83 114
 
84 115
 $spotter_array = array();
85 116
 
@@ -190,24 +221,38 @@  discard block
 block discarded – undo
190 221
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
191 222
 		}
192 223
 	}
193
-	if ($flightcnt == '') $flightcnt = 0;
194
-} else $flightcnt = 0;
224
+	if ($flightcnt == '') {
225
+		$flightcnt = 0;
226
+	}
227
+	} else {
228
+	$flightcnt = 0;
229
+}
195 230
 
196 231
 $sqltime = round(microtime(true)-$begintime,2);
197 232
 
198 233
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
199
-if ($currenttime != '') $currenttime = round($currenttime/1000);
234
+if ($currenttime != '') {
235
+	$currenttime = round($currenttime/1000);
236
+}
200 237
 
201
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
202
-else $usenextlatlon = true;
203
-if ($usenextlatlon === false) $currenttime = '';
238
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
239
+	$usenextlatlon = false;
240
+} else {
241
+	$usenextlatlon = true;
242
+}
243
+if ($usenextlatlon === false) {
244
+	$currenttime = '';
245
+}
204 246
 $j = 0;
205 247
 $prev_flightaware_id = '';
206 248
 $aircrafts_shadow = array();
207 249
 $output = '{';
208 250
 	$output .= '"type": "FeatureCollection",';
209
-		if ($min) $output .= '"minimal": "true",';
210
-		else $output .= '"minimal": "false",';
251
+		if ($min) {
252
+			$output .= '"minimal": "true",';
253
+		} else {
254
+			$output .= '"minimal": "false",';
255
+		}
211 256
 		//$output .= '"fc": "'.$flightcnt.'",';
212 257
 		$output .= '"sqt": "'.$sqltime.'",';
213 258
 
@@ -252,18 +297,29 @@  discard block
 block discarded – undo
252 297
 						}
253 298
 						$output .= '"properties": {';
254 299
 						if (isset($spotter_item['flightaware_id'])) {
255
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
256
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
300
+							if ($compress) {
301
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
302
+							} else {
303
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
304
+							}
257 305
 						} elseif (isset($spotter_item['famtrackid'])) {
258
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
259
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
306
+							if ($compress) {
307
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
308
+							} else {
309
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
310
+							}
260 311
 						} elseif (isset($spotter_item['fammarine_id'])) {
261
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
262
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
312
+							if ($compress) {
313
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
314
+							} else {
315
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
316
+							}
263 317
 						}
264 318
 						$output .= '"fc": "'.$flightcnt.'",';
265 319
 						$output .= '"sqt": "'.$sqltime.'",';
266
-						if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
320
+						if (isset($begindate)) {
321
+							$output .= '"archive_date": "'.$begindate.'",';
322
+						}
267 323
 
268 324
 /*
269 325
 							if ($min) $output .= '"minimal": "true",';
@@ -271,16 +327,25 @@  discard block
 block discarded – undo
271 327
 */
272 328
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
273 329
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
274
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
275
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
330
+							if ($compress) {
331
+								$output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
332
+							} else {
333
+								$output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
334
+							}
276 335
 							//'
277 336
 						} else {
278
-							if ($compress) $output .= '"c": "NA",';
279
-							else $output .= '"callsign": "NA",';
337
+							if ($compress) {
338
+								$output .= '"c": "NA",';
339
+							} else {
340
+								$output .= '"callsign": "NA",';
341
+							}
280 342
 						}
281 343
 						if (isset($spotter_item['registration'])) {
282
-							if ($compress) $output .= '"reg": '.json_encode($spotter_item['registration']).',';
283
-							else $output .= '"registration": '.json_encode($spotter_item['registration']).',';
344
+							if ($compress) {
345
+								$output .= '"reg": '.json_encode($spotter_item['registration']).',';
346
+							} else {
347
+								$output .= '"registration": '.json_encode($spotter_item['registration']).',';
348
+							}
284 349
 						}
285 350
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
286 351
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
@@ -291,20 +356,30 @@  discard block
 block discarded – undo
291 356
 							$output .= '"aircraft_name": "NA",';
292 357
 						}
293 358
 						if (isset($spotter_item['aircraft_icao'])) {
294
-							if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
295
-							else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
359
+							if ($compress) {
360
+								$output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
361
+							} else {
362
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
363
+							}
296 364
 						}
297 365
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) {
298
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
299
-							else {
366
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
367
+								$spotter_item['aircraft_shadow'] = '';
368
+							} else {
300 369
 								$aircraft_icao = $spotter_item['aircraft_icao'];
301
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
302
-								else {
370
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
371
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
372
+								} else {
303 373
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
304
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
305
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
306
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
307
-									else $spotter_item['aircraft_shadow'] = '';
374
+									if (count($aircraft_info) > 0) {
375
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
376
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
377
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
378
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
379
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
380
+									} else {
381
+										$spotter_item['aircraft_shadow'] = '';
382
+									}
308 383
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
309 384
 								}
310 385
 							}
@@ -312,90 +387,171 @@  discard block
 block discarded – undo
312 387
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
313 388
 							if ($tracker) {
314 389
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
315
-									if ($compress) $output .= '"as": "ambulance.png",';
316
-									else $output .= '"aircraft_shadow": "ambulance.png",';
390
+									if ($compress) {
391
+										$output .= '"as": "ambulance.png",';
392
+									} else {
393
+										$output .= '"aircraft_shadow": "ambulance.png",';
394
+									}
317 395
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
318
-									if ($compress) $output .= '"as": "police.png",';
319
-									else $output .= '"aircraft_shadow": "police.png",';
396
+									if ($compress) {
397
+										$output .= '"as": "police.png",';
398
+									} else {
399
+										$output .= '"aircraft_shadow": "police.png",';
400
+									}
320 401
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
321
-									if ($compress) $output .= '"as": "ship.png",';
322
-									else $output .= '"aircraft_shadow": "ship.png",';
402
+									if ($compress) {
403
+										$output .= '"as": "ship.png",';
404
+									} else {
405
+										$output .= '"aircraft_shadow": "ship.png",';
406
+									}
323 407
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
324
-									if ($compress) $output .= '"as": "ship.png",';
325
-									else $output .= '"aircraft_shadow": "ship.png",';
408
+									if ($compress) {
409
+										$output .= '"as": "ship.png",';
410
+									} else {
411
+										$output .= '"aircraft_shadow": "ship.png",';
412
+									}
326 413
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
327
-									if ($compress) $output .= '"as": "ship.png",';
328
-									else $output .= '"aircraft_shadow": "ship.png",';
414
+									if ($compress) {
415
+										$output .= '"as": "ship.png",';
416
+									} else {
417
+										$output .= '"aircraft_shadow": "ship.png",';
418
+									}
329 419
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
330
-									if ($compress) $output .= '"as": "truck.png",';
331
-									else $output .= '"aircraft_shadow": "truck.png",';
420
+									if ($compress) {
421
+										$output .= '"as": "truck.png",';
422
+									} else {
423
+										$output .= '"aircraft_shadow": "truck.png",';
424
+									}
332 425
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
333
-									if ($compress) $output .= '"as": "truck.png",';
334
-									else $output .= '"aircraft_shadow": "truck.png",';
426
+									if ($compress) {
427
+										$output .= '"as": "truck.png",';
428
+									} else {
429
+										$output .= '"aircraft_shadow": "truck.png",';
430
+									}
335 431
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
336
-									if ($compress) $output .= '"as": "aircraft.png",';
337
-									else $output .= '"aircraft_shadow": "aircraft.png",';
432
+									if ($compress) {
433
+										$output .= '"as": "aircraft.png",';
434
+									} else {
435
+										$output .= '"aircraft_shadow": "aircraft.png",';
436
+									}
338 437
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
339
-									if ($compress) $output .= '"as": "aircraft.png",';
340
-									else $output .= '"aircraft_shadow": "aircraft.png",';
438
+									if ($compress) {
439
+										$output .= '"as": "aircraft.png",';
440
+									} else {
441
+										$output .= '"aircraft_shadow": "aircraft.png",';
442
+									}
341 443
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
342
-									if ($compress) $output .= '"as": "helico.png",';
343
-									else $output .= '"aircraft_shadow": "helico.png",';
444
+									if ($compress) {
445
+										$output .= '"as": "helico.png",';
446
+									} else {
447
+										$output .= '"aircraft_shadow": "helico.png",';
448
+									}
344 449
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
345
-									if ($compress) $output .= '"as": "rail.png",';
346
-									else $output .= '"aircraft_shadow": "rail.png",';
450
+									if ($compress) {
451
+										$output .= '"as": "rail.png",';
452
+									} else {
453
+										$output .= '"aircraft_shadow": "rail.png",';
454
+									}
347 455
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
348
-									if ($compress) $output .= '"as": "firetruck.png",';
349
-									else $output .= '"aircraft_shadow": "firetruck.png",';
456
+									if ($compress) {
457
+										$output .= '"as": "firetruck.png",';
458
+									} else {
459
+										$output .= '"aircraft_shadow": "firetruck.png",';
460
+									}
350 461
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
351
-									if ($compress) $output .= '"as": "bus.png",';
352
-									else $output .= '"aircraft_shadow": "bus.png",';
462
+									if ($compress) {
463
+										$output .= '"as": "bus.png",';
464
+									} else {
465
+										$output .= '"aircraft_shadow": "bus.png",';
466
+									}
353 467
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
354
-									if ($compress) $output .= '"as": "phone.png",';
355
-									else $output .= '"aircraft_shadow": "phone.png",';
468
+									if ($compress) {
469
+										$output .= '"as": "phone.png",';
470
+									} else {
471
+										$output .= '"aircraft_shadow": "phone.png",';
472
+									}
356 473
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
357
-									if ($compress) $output .= '"as": "jogger.png",';
358
-									else $output .= '"aircraft_shadow": "jogger.png",';
474
+									if ($compress) {
475
+										$output .= '"as": "jogger.png",';
476
+									} else {
477
+										$output .= '"aircraft_shadow": "jogger.png",';
478
+									}
359 479
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
360
-									if ($compress) $output .= '"as": "bike.png",';
361
-									else $output .= '"aircraft_shadow": "bike.png",';
480
+									if ($compress) {
481
+										$output .= '"as": "bike.png",';
482
+									} else {
483
+										$output .= '"aircraft_shadow": "bike.png",';
484
+									}
362 485
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
363
-									if ($compress) $output .= '"as": "motorcycle.png",';
364
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
486
+									if ($compress) {
487
+										$output .= '"as": "motorcycle.png",';
488
+									} else {
489
+										$output .= '"aircraft_shadow": "motorcycle.png",';
490
+									}
365 491
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
366
-									if ($compress) $output .= '"as": "balloon.png",';
367
-									else $output .= '"aircraft_shadow": "balloon.png",';
492
+									if ($compress) {
493
+										$output .= '"as": "balloon.png",';
494
+									} else {
495
+										$output .= '"aircraft_shadow": "balloon.png",';
496
+									}
368 497
 								} else {
369
-									if ($compress) $output .= '"as": "car.png",';
370
-									else $output .= '"aircraft_shadow": "car.png",';
498
+									if ($compress) {
499
+										$output .= '"as": "car.png",';
500
+									} else {
501
+										$output .= '"aircraft_shadow": "car.png",';
502
+									}
371 503
 								}
372 504
 							} elseif ($marine) {
373 505
 								if (isset($spotter_item['type']) && ($spotter_item['type']  == '50&#39; Performance Cruiser' || $spotter_item['type']  == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
374
-									if ($compress) $output .= '"as": "50perfcruiser.png",';
375
-									else $output .= '"aircraft_shadow": "50perfcruiser.png",';
506
+									if ($compress) {
507
+										$output .= '"as": "50perfcruiser.png",';
508
+									} else {
509
+										$output .= '"aircraft_shadow": "50perfcruiser.png",';
510
+									}
376 511
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Sailaway Cruiser 38') {
377
-									if ($compress) $output .= '"as": "cruiser38.png",';
378
-									else $output .= '"aircraft_shadow": "cruiser38.png",';
512
+									if ($compress) {
513
+										$output .= '"as": "cruiser38.png",';
514
+									} else {
515
+										$output .= '"aircraft_shadow": "cruiser38.png",';
516
+									}
379 517
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Mini Transat') {
380
-									if ($compress) $output .= '"as": "transat.png",';
381
-									else $output .= '"aircraft_shadow": "transat.png",';
518
+									if ($compress) {
519
+										$output .= '"as": "transat.png",';
520
+									} else {
521
+										$output .= '"aircraft_shadow": "transat.png",';
522
+									}
382 523
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == '52&#39; Cruising Cat') {
383
-									if ($compress) $output .= '"as": "catamaran.png",';
384
-									else $output .= '"aircraft_shadow": "catamaran.png",';
524
+									if ($compress) {
525
+										$output .= '"as": "catamaran.png",';
526
+									} else {
527
+										$output .= '"aircraft_shadow": "catamaran.png",';
528
+									}
385 529
 								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Caribbean Rose') {
386
-									if ($compress) $output .= '"as": "carib.png",';
387
-									else $output .= '"aircraft_shadow": "carib.png",';
530
+									if ($compress) {
531
+										$output .= '"as": "carib.png",';
532
+									} else {
533
+										$output .= '"aircraft_shadow": "carib.png",';
534
+									}
388 535
 								} else {
389
-									if ($compress) $output .= '"as": "ship.png",';
390
-									else $output .= '"aircraft_shadow": "ship.png",';
536
+									if ($compress) {
537
+										$output .= '"as": "ship.png",';
538
+									} else {
539
+										$output .= '"aircraft_shadow": "ship.png",';
540
+									}
391 541
 								}
392 542
 							} else {
393
-								if ($compress) $output .= '"as": "default.png",';
394
-								else $output .= '"aircraft_shadow": "default.png",';
543
+								if ($compress) {
544
+									$output .= '"as": "default.png",';
545
+								} else {
546
+									$output .= '"aircraft_shadow": "default.png",';
547
+								}
395 548
 							}
396 549
 						} else {
397
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
398
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
550
+							if ($compress) {
551
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
552
+							} else {
553
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
554
+							}
399 555
 						}
400 556
 						if (isset($spotter_item['airline_name'])) {
401 557
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -403,8 +559,11 @@  discard block
 block discarded – undo
403 559
 							$output .= '"airline_name": "NA",';
404 560
 						}
405 561
 						if (isset($spotter_item['departure_airport'])) {
406
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
407
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
562
+							if ($compress) {
563
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
564
+							} else {
565
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
566
+							}
408 567
 						}
409 568
 						if (isset($spotter_item['departure_airport_city'])) {
410 569
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -416,8 +575,11 @@  discard block
 block discarded – undo
416 575
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
417 576
 						}
418 577
 						if (isset($spotter_item['arrival_airport'])) {
419
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
420
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
578
+							if ($compress) {
579
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
580
+							} else {
581
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
582
+							}
421 583
 						}
422 584
 						if (isset($spotter_item['arrival_airport_city'])) {
423 585
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -436,11 +598,17 @@  discard block
 block discarded – undo
436 598
 						}
437 599
 						
438 600
 						if (isset($spotter_item['real_altitude'])) {
439
-							if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
440
-							else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
601
+							if ($compress) {
602
+								$output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
603
+							} else {
604
+								$output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
605
+							}
441 606
 						} elseif (isset($spotter_item['altitude'])) {
442
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
443
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
607
+							if ($compress) {
608
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
609
+							} else {
610
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
611
+							}
444 612
 						}
445 613
 						
446 614
 						$heading = $spotter_item['heading'];
@@ -464,19 +632,24 @@  discard block
 block discarded – undo
464 632
 							}
465 633
 						}
466 634
 						
467
-						if ($compress)$output .= '"h": "'.$heading.'",';
468
-						else $output .= '"heading": "'.$heading.'",';
635
+						if ($compress) {
636
+							$output .= '"h": "'.$heading.'",';
637
+						} else {
638
+							$output .= '"heading": "'.$heading.'",';
639
+						}
469 640
 						if ($currenttime != '') {
470 641
 							if (strtotime($spotter_item['date']) < $currenttime) {
471 642
 								if (isset($archivespeed)) {
472 643
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
473 644
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
474
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
475
-									else {
645
+									if (!isset($idistance) || $fdistance < $idistance) {
646
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
647
+									} else {
476 648
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
477 649
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
478
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
479
-										else {
650
+										if (!isset($idistance) || $fdistance < $idistance) {
651
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
652
+										} else {
480 653
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
481 654
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
482 655
 										}
@@ -484,12 +657,14 @@  discard block
 block discarded – undo
484 657
 								} elseif ($usenextlatlon) {
485 658
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
486 659
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
487
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
488
-									else {
660
+									if (!isset($idistance) || $fdistance < $idistance) {
661
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
662
+									} else {
489 663
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
490 664
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
491
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
492
-										else {
665
+										if (!isset($idistance) || $fdistance < $idistance) {
666
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
667
+										} else {
493 668
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
494 669
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
495 670
 										}
@@ -528,7 +703,9 @@  discard block
 block discarded – undo
528 703
 							}
529 704
 						}
530 705
 
531
-						if (!$min) $output .= '"image": "'.$image.'",';
706
+						if (!$min) {
707
+							$output .= '"image": "'.$image.'",';
708
+						}
532 709
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
533 710
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
534 711
 						}
@@ -536,8 +713,11 @@  discard block
 block discarded – undo
536 713
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
537 714
 						}
538 715
 						if (isset($spotter_item['squawk'])) {
539
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
540
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
716
+							if ($compress) {
717
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
718
+							} else {
719
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
720
+							}
541 721
 						}
542 722
 						if (isset($spotter_item['squawk_usage'])) {
543 723
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -568,14 +748,23 @@  discard block
 block discarded – undo
568 748
 						}
569 749
 						// type when not aircraft ?
570 750
 						if (isset($spotter_item['type'])) {
571
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
572
-							else $output .= '"type": "'.$spotter_item['type'].'"';
751
+							if ($compress) {
752
+								$output .= '"t": "'.$spotter_item['type'].'"';
753
+							} else {
754
+								$output .= '"type": "'.$spotter_item['type'].'"';
755
+							}
573 756
 						} elseif ($marine) {
574
-							if ($compress) $output .= '"t": "ship"';
575
-							else $output .= '"type": "ship"';
757
+							if ($compress) {
758
+								$output .= '"t": "ship"';
759
+							} else {
760
+								$output .= '"type": "ship"';
761
+							}
576 762
 						} else {
577
-							if ($compress) $output .= '"t": "aircraft"';
578
-							else $output .= '"type": "aircraft"';
763
+							if ($compress) {
764
+								$output .= '"t": "aircraft"';
765
+							} else {
766
+								$output .= '"type": "aircraft"';
767
+							}
579 768
 						}
580 769
 						$output .= '},';
581 770
 						$output .= '"geometry": {';
@@ -583,15 +772,19 @@  discard block
 block discarded – undo
583 772
 								$output .= '"coordinates": [';
584 773
 								if ($currenttime != '') {
585 774
 									if (strtotime($spotter_item['date']) < $currenttime) {
586
-										if (!isset($archivespeed)) $archivespeed = 1;
775
+										if (!isset($archivespeed)) {
776
+											$archivespeed = 1;
777
+										}
587 778
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
588 779
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
589
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
590
-										else {
780
+										if (!isset($idistance) || $fdistance < $idistance) {
781
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
782
+										} else {
591 783
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
592 784
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
593
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
594
-											else {
785
+											if (!isset($idistance) || $fdistance < $idistance) {
786
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
787
+											} else {
595 788
 												$output .= $spotter_item['longitude'].', ';
596 789
 												$output .= $spotter_item['latitude'];
597 790
 											}
@@ -669,7 +862,9 @@  discard block
 block discarded – undo
669 862
 			}
670 863
 */
671 864
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
672
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
865
+				if ($history == '' && isset($_COOKIE['history'])) {
866
+					$history = $_COOKIE['history'];
867
+				}
673 868
 				
674 869
 				if (
675 870
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -739,8 +934,11 @@  discard block
 block discarded – undo
739 934
 									$output_history .= ']}},';
740 935
 									$output .= $output_history;
741 936
 								}
742
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
743
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
937
+								if ($compress) {
938
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
939
+								} else {
940
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
941
+								}
744 942
 							}
745 943
 							$output_history .= '[';
746 944
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -761,10 +959,15 @@  discard block
 block discarded – undo
761 959
 							if ($d == false) {
762 960
 								if ($compress) {
763 961
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
764
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
765
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
962
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
963
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
964
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
965
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
966
+									}
766 967
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
767
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
968
+								} else {
969
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
970
+								}
768 971
 								$d = true;
769 972
 							}
770 973
 							$output_history .= '[';
@@ -787,7 +990,9 @@  discard block
 block discarded – undo
787 990
 							$output_historyd = '[';
788 991
 							$output_historyd .=  $spotter_item['longitude'].', ';
789 992
 							$output_historyd .=  $spotter_item['latitude'];
790
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
993
+							if (isset($spotter_history['altitude'])) {
994
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
995
+							}
791 996
 							$output_historyd .= '],';
792 997
 							//$output_history = $output_historyd.$output_history;
793 998
 							$output_history = $output_history.$output_historyd;
@@ -815,8 +1020,11 @@  discard block
 block discarded – undo
815 1020
 				        && $spotter_item['arrival_airport'] != 'NA' 
816 1021
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
817 1022
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
818
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
819
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
1023
+				    if ($compress) {
1024
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
1025
+				    } else {
1026
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
1027
+				    }
820 1028
 				    if (isset($spotter_item['departure_airport_latitude'])) {
821 1029
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
822 1030
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -849,8 +1057,11 @@  discard block
 block discarded – undo
849 1057
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
850 1058
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
851 1059
 				    $havedata = false;
852
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
853
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1060
+				    if ($compress) {
1061
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1062
+				    } else {
1063
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1064
+				    }
854 1065
 				    
855 1066
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
856 1067
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -875,7 +1086,9 @@  discard block
 block discarded – undo
875 1086
 					$output_dest  = substr($output_dest, 0, -1);
876 1087
 				    }
877 1088
 				    $output_dest .= ']}},';
878
-				    if ($havedata) $output .= $output_dest;
1089
+				    if ($havedata) {
1090
+				    	$output .= $output_dest;
1091
+				    }
879 1092
 				    unset($output_dest);
880 1093
 				}
881 1094
 			}
@@ -883,7 +1096,9 @@  discard block
 block discarded – undo
883 1096
 			$output .= ']';
884 1097
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
885 1098
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
886
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1099
+			if (isset($begindate)) {
1100
+				$output .= '"archive_date": "'.$begindate.'",';
1101
+			}
887 1102
 			$output .= '"fc": "'.$j.'"';
888 1103
 		} else {
889 1104
 			$output .= '"features": ';
Please login to merge, or discard this patch.