Completed
Push — master ( bb48eb...8e257c )
by Yannick
34:24
created
require/class.Weather.php 1 patch
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.
require/class.MarineImport.php 1 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.
require/class.Marine.php 1 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.
search.php 1 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.
live-geojson.php 1 patch
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.