Completed
Push — master ( 251c31...5b2688 )
by Yannick
52:30 queued 24:36
created
require/class.MarineLive.php 1 patch
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
82 82
 				}
83 83
 			}
84
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
84
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
85 85
 		}
86 86
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
87
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
87
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
88 88
 		}
89 89
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
90 90
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
91 91
 		if ($filter_query_where != '') {
92
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
92
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
93 93
 		}
94 94
 		$filter_query = $filter_query_join.$filter_query_where;
95 95
 		return $filter_query;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 		if ($limit != '')
113 113
 		{
114 114
 			$limit_array = explode(',', $limit);
115
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
116
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
115
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
116
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
117 117
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
118 118
 			{
119 119
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
129 129
 			}
130 130
 		}
131
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
131
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
132 132
 
133 133
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
134 134
 		if ($globalDBdriver == 'mysql') {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		} else {
138 138
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
139 139
 		}
140
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
140
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
141 141
 
142 142
 		return $spotter_array;
143 143
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		global $globalDBdriver, $globalLiveInterval;
154 154
 		date_default_timezone_set('UTC');
155 155
 
156
-		$filter_query = $this->getFilter($filter,true,true);
156
+		$filter_query = $this->getFilter($filter, true, true);
157 157
 
158 158
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
159 159
 		if ($globalDBdriver == 'mysql') {
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		try {
168 168
 			$sth = $this->db->prepare($query);
169 169
 			$sth->execute();
170
-		} catch(PDOException $e) {
170
+		} catch (PDOException $e) {
171 171
 			echo $e->getMessage();
172 172
 			die;
173 173
 		}
@@ -182,26 +182,26 @@  discard block
 block discarded – undo
182 182
 	* @return Array the spotter information
183 183
 	*
184 184
 	*/
185
-	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '')
185
+	public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false, $id = '')
186 186
 	{
187 187
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
188 188
 		date_default_timezone_set('UTC');
189 189
 		$usecoord = false;
190 190
 		if (is_array($coord) && !empty($coord)) {
191
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
192
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
193
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
194
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
191
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
192
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
193
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
194
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
195 195
 			$usecoord = true;
196 196
 		}
197
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
198
-		$filter_query = $this->getFilter($filter,true,true);
197
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
198
+		$filter_query = $this->getFilter($filter, true, true);
199 199
 
200 200
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
201 201
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
202 202
 		if ($globalDBdriver == 'mysql') {
203 203
 			if (isset($globalArchive) && $globalArchive === TRUE) {
204
-				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name 
204
+				$query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name 
205 205
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
206 206
 				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
207 207
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 				    ORDER BY fammarine_id, date";
216 216
 				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
217 217
 			} else {
218
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
218
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
219 219
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
220 220
 				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
221 221
 				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			}
226 226
 		} else {
227 227
 			if (isset($globalArchive) && $globalArchive === TRUE) {
228
-				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name 
228
+				$query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name 
229 229
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
230 230
 				if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
231 231
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		try {
253 253
 			$sth = $this->db->prepare($query);
254 254
 			$sth->execute($query_values);
255
-		} catch(PDOException $e) {
255
+		} catch (PDOException $e) {
256 256
 			echo $e->getMessage();
257 257
 			die;
258 258
 		}
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	public function getLiveMarineCount($filter = array())
270 270
 	{
271 271
 		global $globalDBdriver, $globalLiveInterval;
272
-		$filter_query = $this->getFilter($filter,true,true);
272
+		$filter_query = $this->getFilter($filter, true, true);
273 273
 
274 274
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
275 275
 		if ($globalDBdriver == 'mysql') {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		try {
281 281
 			$sth = $this->db->prepare($query);
282 282
 			$sth->execute();
283
-		} catch(PDOException $e) {
283
+		} catch (PDOException $e) {
284 284
 			echo $e->getMessage();
285 285
 			die;
286 286
 		}
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 		$filter_query = $this->getFilter($filter);
304 304
 
305 305
 		if (is_array($coord)) {
306
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
307
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
308
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
309
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
306
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
307
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
308
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
309
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
310 310
 		} else return array();
311 311
 		if ($globalDBdriver == 'mysql') {
312 312
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query;
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
329 329
 		$Marine = new Marine($this->db);
330 330
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
331
-		$filter_query = $this->getFilter($filter,true,true);
331
+		$filter_query = $this->getFilter($filter, true, true);
332 332
 
333 333
 		if (is_array($coord)) {
334
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
335
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
336
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
337
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
334
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
335
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
336
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
337
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
338 338
 		} else return array();
339 339
 		/*
340 340
 		if ($globalDBdriver == 'mysql') {
@@ -349,13 +349,13 @@  discard block
 block discarded – undo
349 349
 		*/
350 350
 		if ($globalDBdriver == 'mysql') {
351 351
 			if (isset($globalArchive) && $globalArchive === TRUE) {
352
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
352
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
353 353
 				    FROM marine_live 
354 354
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date 
355 355
 				    AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
356 356
 				    AND marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY date DESC';
357 357
 			} else {
358
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
358
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
359 359
 				    FROM marine_live 
360 360
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
361 361
 				    FROM marine_live l 
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
 			}
368 368
 		} else {
369 369
 			if (isset($globalArchive) && $globalArchive === TRUE) {
370
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
370
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
371 371
 				    FROM marine_live 
372 372
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date 
373 373
 				    AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
374 374
 				    AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
375 375
 				    AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' ORDER BY date DESC";
376 376
 			} else {
377
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
377
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
378 378
 				    FROM marine_live 
379 379
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
380 380
 				    FROM marine_live l 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
                 if ($interval == '1m')
432 432
                 {
433 433
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
434
-                } else if ($interval == '15m'){
434
+                } else if ($interval == '15m') {
435 435
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
436 436
                 } 
437 437
             }
@@ -439,14 +439,14 @@  discard block
 block discarded – undo
439 439
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
440 440
         }
441 441
 
442
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
442
+                $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
443 443
                    WHERE marine_live.latitude <> '' 
444 444
                                    AND marine_live.longitude <> '' 
445 445
                    ".$additional_query."
446 446
                    HAVING distance < :radius  
447 447
                                    ORDER BY distance";
448 448
 
449
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
449
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
450 450
 
451 451
                 return $spotter_array;
452 452
         }
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 		date_default_timezone_set('UTC');
465 465
 
466 466
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
467
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
467
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
468 468
 
469
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
469
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
470 470
 
471 471
 		return $spotter_array;
472 472
 	}
@@ -477,14 +477,14 @@  discard block
 block discarded – undo
477 477
 	* @return Array the spotter information
478 478
 	*
479 479
 	*/
480
-	public function getDateLiveMarineDataByIdent($ident,$date)
480
+	public function getDateLiveMarineDataByIdent($ident, $date)
481 481
 	{
482 482
 		$Marine = new Marine($this->db);
483 483
 		date_default_timezone_set('UTC');
484 484
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
485 485
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
486
-		$date = date('c',$date);
487
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
486
+		$date = date('c', $date);
487
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
488 488
 		return $spotter_array;
489 489
 	}
490 490
 
@@ -494,14 +494,14 @@  discard block
 block discarded – undo
494 494
 	* @return Array the spotter information
495 495
 	*
496 496
 	*/
497
-	public function getDateLiveMarineDataByMMSI($mmsi,$date)
497
+	public function getDateLiveMarineDataByMMSI($mmsi, $date)
498 498
 	{
499 499
 		$Marine = new Marine($this->db);
500 500
 		date_default_timezone_set('UTC');
501 501
 		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
502 502
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.mmsi = :mmsi AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
503
-		$date = date('c',$date);
504
-		$spotter_array = $Marine->getDataFromDB($query,array(':mmsi' => $mmsi,':date' => $date));
503
+		$date = date('c', $date);
504
+		$spotter_array = $Marine->getDataFromDB($query, array(':mmsi' => $mmsi, ':date' => $date));
505 505
 		return $spotter_array;
506 506
 	}
507 507
 
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
 		date_default_timezone_set('UTC');
518 518
 
519 519
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
520
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
520
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
521 521
 
522
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
522
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
523 523
 
524 524
 		return $spotter_array;
525 525
 	}
@@ -530,15 +530,15 @@  discard block
 block discarded – undo
530 530
 	* @return Array the spotter information
531 531
 	*
532 532
 	*/
533
-	public function getDateLiveMarineDataById($id,$date)
533
+	public function getDateLiveMarineDataById($id, $date)
534 534
 	{
535 535
 		$Marine = new Marine($this->db);
536 536
 		date_default_timezone_set('UTC');
537 537
 
538 538
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
539
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
540
-                $date = date('c',$date);
541
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
539
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
540
+                $date = date('c', $date);
541
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
542 542
 
543 543
 		return $spotter_array;
544 544
 	}
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 	* @return Array the spotter information
551 551
 	*
552 552
 	*/
553
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
553
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
554 554
 	{
555 555
 		global $globalDBdriver, $globalLiveInterval;
556 556
 		date_default_timezone_set('UTC');
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		try {
570 570
 			$sth = $this->db->prepare($query);
571 571
 			$sth->execute(array(':id' => $id));
572
-		} catch(PDOException $e) {
572
+		} catch (PDOException $e) {
573 573
 			echo $e->getMessage();
574 574
 			die;
575 575
 		}
@@ -587,12 +587,12 @@  discard block
 block discarded – undo
587 587
 	{
588 588
 		date_default_timezone_set('UTC');
589 589
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
590
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
590
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
591 591
     		try {
592 592
 			
593 593
 			$sth = $this->db->prepare($query);
594 594
 			$sth->execute(array(':ident' => $ident));
595
-		} catch(PDOException $e) {
595
+		} catch (PDOException $e) {
596 596
 			echo $e->getMessage();
597 597
 			die;
598 598
 		}
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 			
623 623
 			$sth = $this->db->prepare($query);
624 624
 			$sth->execute();
625
-		} catch(PDOException $e) {
625
+		} catch (PDOException $e) {
626 626
 			return "error";
627 627
 		}
628 628
 
@@ -645,14 +645,14 @@  discard block
 block discarded – undo
645 645
 				
646 646
 				$sth = $this->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error";
650 650
 			}
651 651
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
652 652
                         $i = 0;
653
-                        $j =0;
653
+                        $j = 0;
654 654
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
655
-			foreach($all as $row)
655
+			foreach ($all as $row)
656 656
 			{
657 657
 				$i++;
658 658
 				$j++;
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
 					if ($globalDebug) echo ".";
661 661
 				    	try {
662 662
 						
663
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
663
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
664 664
 						$sth->execute();
665
-					} catch(PDOException $e) {
665
+					} catch (PDOException $e) {
666 666
 						return "error";
667 667
 					}
668 668
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 			if ($i > 0) {
674 674
     				try {
675 675
 					
676
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
676
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
677 677
 					$sth->execute();
678
-				} catch(PDOException $e) {
678
+				} catch (PDOException $e) {
679 679
 					return "error";
680 680
 				}
681 681
 			}
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 				
689 689
 				$sth = $this->db->prepare($query);
690 690
 				$sth->execute();
691
-			} catch(PDOException $e) {
691
+			} catch (PDOException $e) {
692 692
 				return "error";
693 693
 			}
694 694
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
 	public function deleteLiveMarineDataByIdent($ident)
737 737
 	{
738 738
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
739
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
739
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
740 740
         
741 741
     		try {
742 742
 			
743 743
 			$sth = $this->db->prepare($query);
744 744
 			$sth->execute(array(':ident' => $ident));
745
-		} catch(PDOException $e) {
745
+		} catch (PDOException $e) {
746 746
 			return "error";
747 747
 		}
748 748
 
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
 	public function deleteLiveMarineDataById($id)
759 759
 	{
760 760
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
761
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
761
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
762 762
         
763 763
     		try {
764 764
 			
765 765
 			$sth = $this->db->prepare($query);
766 766
 			$sth->execute(array(':id' => $id));
767
-		} catch(PDOException $e) {
767
+		} catch (PDOException $e) {
768 768
 			return "error";
769 769
 		}
770 770
 
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 	*/
781 781
 	public function getAllRaces()
782 782
 	{
783
-		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
783
+		$query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
784 784
 		$sth = $this->db->prepare($query);
785 785
 		$sth->execute();
786 786
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -796,13 +796,13 @@  discard block
 block discarded – undo
796 796
 	{
797 797
 		global $globalDBdriver, $globalTimezone;
798 798
 		if ($globalDBdriver == 'mysql') {
799
-			$query  = 'SELECT marine_live.ident FROM marine_live 
799
+			$query = 'SELECT marine_live.ident FROM marine_live 
800 800
 				WHERE marine_live.ident = :ident 
801 801
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
802 802
 				AND marine_live.date < UTC_TIMESTAMP()';
803 803
 			$query_data = array(':ident' => $ident);
804 804
 		} else {
805
-			$query  = "SELECT marine_live.ident FROM marine_live 
805
+			$query = "SELECT marine_live.ident FROM marine_live 
806 806
 				WHERE marine_live.ident = :ident 
807 807
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
808 808
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 		
812 812
 		$sth = $this->db->prepare($query);
813 813
 		$sth->execute($query_data);
814
-		$ident_result='';
815
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
814
+		$ident_result = '';
815
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
816 816
 		{
817 817
 			$ident_result = $row['ident'];
818 818
 		}
@@ -829,13 +829,13 @@  discard block
 block discarded – undo
829 829
 	{
830 830
 		global $globalDBdriver, $globalTimezone;
831 831
 		if ($globalDBdriver == 'mysql') {
832
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
832
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
833 833
 				WHERE marine_live.ident = :ident 
834 834
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
835 835
 //				AND marine_live.date < UTC_TIMESTAMP()";
836 836
 			$query_data = array(':ident' => $ident);
837 837
 		} else {
838
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
838
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
839 839
 				WHERE marine_live.ident = :ident 
840 840
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
841 841
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 		
845 845
 		$sth = $this->db->prepare($query);
846 846
 		$sth->execute($query_data);
847
-		$ident_result='';
848
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
847
+		$ident_result = '';
848
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
849 849
 		{
850 850
 			$ident_result = $row['fammarine_id'];
851 851
 		}
@@ -862,13 +862,13 @@  discard block
 block discarded – undo
862 862
 	{
863 863
 		global $globalDBdriver, $globalTimezone;
864 864
 		if ($globalDBdriver == 'mysql') {
865
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
865
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
866 866
 				WHERE marine_live.fammarine_id = :id 
867 867
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
868 868
 //				AND marine_live.date < UTC_TIMESTAMP()";
869 869
 			$query_data = array(':id' => $id);
870 870
 		} else {
871
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
871
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
872 872
 				WHERE marine_live.fammarine_id = :id 
873 873
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
874 874
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 		
878 878
 		$sth = $this->db->prepare($query);
879 879
 		$sth->execute($query_data);
880
-		$ident_result='';
881
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
880
+		$ident_result = '';
881
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
882 882
 		{
883 883
 			$ident_result = $row['fammarine_id'];
884 884
 		}
@@ -895,13 +895,13 @@  discard block
 block discarded – undo
895 895
 	{
896 896
 		global $globalDBdriver, $globalTimezone;
897 897
 		if ($globalDBdriver == 'mysql') {
898
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
898
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
899 899
 				WHERE marine_live.mmsi = :mmsi 
900 900
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
901 901
 //				AND marine_live.date < UTC_TIMESTAMP()";
902 902
 			$query_data = array(':mmsi' => $mmsi);
903 903
 		} else {
904
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
904
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
905 905
 				WHERE marine_live.mmsi = :mmsi 
906 906
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
907 907
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 		
911 911
 		$sth = $this->db->prepare($query);
912 912
 		$sth->execute($query_data);
913
-		$ident_result='';
914
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
913
+		$ident_result = '';
914
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
915 915
 		{
916 916
 			$ident_result = $row['fammarine_id'];
917 917
 		}
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 	* @return String success or false
930 930
 	*
931 931
 	*/
932
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '')
932
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '')
933 933
 	{
934 934
 		global $globalURL, $globalArchive, $globalDebug;
935 935
 		$Common = new Common();
@@ -981,33 +981,33 @@  discard block
 block discarded – undo
981 981
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
982 982
 
983 983
         
984
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
985
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
986
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
987
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
988
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
989
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
990
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
991
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
992
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
993
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
994
-		$typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
995
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
996
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
997
-		$statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
998
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
999
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1000
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
1001
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
1002
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
1003
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
1004
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1005
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
984
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
985
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
986
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
987
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
988
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
989
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
990
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
991
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
992
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
993
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
994
+		$typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
995
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
996
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
997
+		$statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
998
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
999
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1000
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
1001
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
1002
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
1003
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
1004
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
1005
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
1006 1006
 		if ($typeid == '') $typeid = NULL;
1007 1007
 		if ($statusid == '') $statusid = NULL;
1008 1008
 
1009 1009
             	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1010
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1010
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1011 1011
             	if ($arrival_date == '') $arrival_date = NULL;
1012 1012
             	$query = '';
1013 1013
 		if ($globalArchive) {
@@ -1016,19 +1016,19 @@  discard block
 block discarded – undo
1016 1016
 		}
1017 1017
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name) 
1018 1018
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:typeid,:status,:statusid,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name)';
1019
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':typeid' => $typeid,':status' => $status,':statusid' => $statusid,':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);
1019
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':typeid' => $typeid, ':status' => $status, ':statusid' => $statusid, ':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);
1020 1020
 		try {
1021 1021
 			$sth = $this->db->prepare($query);
1022 1022
 			$sth->execute($query_values);
1023 1023
 			$sth->closeCursor();
1024
-		} catch(PDOException $e) {
1024
+		} catch (PDOException $e) {
1025 1025
 			return "error : ".$e->getMessage();
1026 1026
 		}
1027 1027
 		
1028 1028
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1029 1029
 			if ($globalDebug) echo '(Add to Marine archive : ';
1030 1030
 			$MarineArchive = new MarineArchive($this->db);
1031
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name);
1031
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country, $captain_id, $captain_name, $race_id, $race_name);
1032 1032
 			if ($globalDebug) echo $result.')';
1033 1033
 		}
1034 1034
 		return "success";
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 
1037 1037
 	public function getOrderBy()
1038 1038
 	{
1039
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1039
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1040 1040
 		return $orderby;
1041 1041
 	}
1042 1042
 
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Spacing   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @return Array the SQL part
18 18
 	*/
19 19
 	
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40 40
 				} else {
41
-					$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";
41
+					$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";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
82 82
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
83 83
 		if ($filter_query_where != '') {
84
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
85 85
 		}
86 86
 		$filter_query = $filter_query_join.$filter_query_where;
87 87
 		return $filter_query;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	* @return Array the spotter information
97 97
 	*
98 98
 	*/
99
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
99
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
100 100
 	{
101 101
 		date_default_timezone_set('UTC');
102 102
 		if (!is_string($query))
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 			$sth = $this->db->prepare($query.$limitQuery);
117 117
 			$sth->execute($params);
118 118
 		} catch (PDOException $e) {
119
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
119
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
120 120
 			exit();
121 121
 		}
122 122
 		
123 123
 		$num_rows = 0;
124 124
 		$spotter_array = array();
125
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
125
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
126 126
 		{
127 127
 			$num_rows++;
128 128
 			$temp_array = array();
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 			}
162 162
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
163 163
 
164
-			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
164
+			if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
165 165
 			{
166 166
 				$Image = new Image($this->db);
167
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
167
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
168 168
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
169 169
 				unset($Image);
170 170
 				if (count($image_array) > 0) {
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 				{
201 201
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
202 202
 				} else {
203
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
203
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
204 204
 				}
205 205
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
206
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
207
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
206
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
207
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
208 208
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
209 209
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
210 210
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
211 211
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
212
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
213
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
212
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
213
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
214 214
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
215 215
 					}
216 216
 				}
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 		if ($limit != "")
244 244
 		{
245 245
 			$limit_array = explode(",", $limit);
246
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
247
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
246
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
247
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
248 248
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
249 249
 			{
250 250
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 		} else {
259 259
 			$orderby_query = " ORDER BY marine_output.date DESC";
260 260
 		}
261
-		$query  = $global_query.$filter_query." ".$orderby_query;
262
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
261
+		$query = $global_query.$filter_query." ".$orderby_query;
262
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
263 263
 		return $spotter_array;
264 264
 	}
265 265
     
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 		if ($id == '') return array();
278 278
 		$additional_query = "marine_output.fammarine_id = :id";
279 279
 		$query_values = array(':id' => $id);
280
-		$query  = $global_query." WHERE ".$additional_query." ";
281
-		$spotter_array = $this->getDataFromDB($query,$query_values);
280
+		$query = $global_query." WHERE ".$additional_query." ";
281
+		$spotter_array = $this->getDataFromDB($query, $query_values);
282 282
 		return $spotter_array;
283 283
 	}
284 284
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		$query_values = array();
298 298
 		$limit_query = '';
299 299
 		$additional_query = '';
300
-		$filter_query = $this->getFilter($filter,true,true);
300
+		$filter_query = $this->getFilter($filter, true, true);
301 301
 		if ($ident != "")
302 302
 		{
303 303
 			if (!is_string($ident))
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 		{
314 314
 			$limit_array = explode(",", $limit);
315 315
 			
316
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
317
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
316
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
317
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
318 318
 			
319 319
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
320 320
 			{
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		$query_values = array();
354 354
 		$limit_query = '';
355 355
 		$additional_query = '';
356
-		$filter_query = $this->getFilter($filter,true,true);
356
+		$filter_query = $this->getFilter($filter, true, true);
357 357
 		if (!is_string($type))
358 358
 		{
359 359
 			return false;
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 		{
367 367
 			$limit_array = explode(",", $limit);
368 368
 			
369
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
370
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
369
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
370
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
371 371
 			
372 372
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
373 373
 			{
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		return $spotter_array;
392 392
 	}
393 393
 	
394
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
394
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
395 395
 	{
396 396
 		global $global_query, $globalTimezone, $globalDBdriver;
397 397
 		
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 		$limit_query = '';
400 400
 		$additional_query = '';
401 401
 
402
-		$filter_query = $this->getFilter($filter,true,true);
402
+		$filter_query = $this->getFilter($filter, true, true);
403 403
 		
404 404
 		if ($date != "")
405 405
 		{
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 		{
426 426
 			$limit_array = explode(",", $limit);
427 427
 			
428
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
429
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
428
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
429
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
430 430
 			
431 431
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
432 432
 			{
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	* @return Array list of source name
458 458
 	*
459 459
 	*/
460
-	public function getAllSourceName($type = '',$filters = array())
460
+	public function getAllSourceName($type = '', $filters = array())
461 461
 	{
462
-		$filter_query = $this->getFilter($filters,true,true);
462
+		$filter_query = $this->getFilter($filters, true, true);
463 463
 		$query_values = array();
464
-		$query  = "SELECT DISTINCT marine_output.source_name 
464
+		$query = "SELECT DISTINCT marine_output.source_name 
465 465
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
466 466
 		if ($type != '') {
467 467
 			$query_values = array(':type' => $type);
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		$source_array = array();
477 477
 		$temp_array = array();
478 478
 		
479
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
479
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
480 480
 		{
481 481
 			$temp_array['source_name'] = $row['source_name'];
482 482
 			$source_array[] = $temp_array;
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	*/
494 494
 	public function getAllIdents($filters = array())
495 495
 	{
496
-		$filter_query = $this->getFilter($filters,true,true);
497
-		$query  = "SELECT DISTINCT marine_output.ident
496
+		$filter_query = $this->getFilter($filters, true, true);
497
+		$query = "SELECT DISTINCT marine_output.ident
498 498
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
499 499
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
500 500
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 		$ident_array = array();
505 505
 		$temp_array = array();
506 506
 		
507
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
507
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
508 508
 		{
509 509
 			$temp_array['ident'] = $row['ident'];
510 510
 			$ident_array[] = $temp_array;
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 	*/
522 522
 	public function getIdentity($mmsi)
523 523
 	{
524
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
524
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
525 525
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
526 526
 		$sth = $this->db->prepare($query);
527 527
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -534,23 +534,23 @@  discard block
 block discarded – undo
534 534
 	* Add identity
535 535
 	*
536 536
 	*/
537
-	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
537
+	public function addIdentity($mmsi, $imo, $ident, $callsign, $type)
538 538
 	{
539
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
539
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
540 540
 		if ($mmsi != '') {
541
-			$imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT);
542
-			$ident = filter_var($ident,FILTER_SANITIZE_STRING);
543
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
544
-			$type = filter_var($type,FILTER_SANITIZE_STRING);
541
+			$imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT);
542
+			$ident = filter_var($ident, FILTER_SANITIZE_STRING);
543
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
544
+			$type = filter_var($type, FILTER_SANITIZE_STRING);
545 545
 			$identinfo = $this->getIdentity($mmsi);
546 546
 			if (empty($identinfo)) {
547
-				$query  = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
547
+				$query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
548 548
 				$sth = $this->db->prepare($query);
549
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type));
549
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type));
550 550
 			} elseif ($ident != '' && $identinfo['ship_name'] != $ident) {
551
-				$query  = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
551
+				$query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
552 552
 				$sth = $this->db->prepare($query);
553
-				$sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type));
553
+				$sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type));
554 554
 			}
555 555
 		}
556 556
 	}
@@ -571,12 +571,12 @@  discard block
 block discarded – undo
571 571
 		} else $offset = '+00:00';
572 572
 
573 573
 		if ($globalDBdriver == 'mysql') {
574
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
574
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
575 575
 								FROM marine_output
576 576
 								WHERE marine_output.date <> '' 
577 577
 								ORDER BY marine_output.date ASC LIMIT 0,100";
578 578
 		} else {
579
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
579
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
580 580
 								FROM marine_output
581 581
 								WHERE marine_output.date <> '' 
582 582
 								ORDER BY marine_output.date ASC LIMIT 0,100";
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 		$date_array = array();
589 589
 		$temp_array = array();
590 590
 		
591
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
591
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
592 592
 		{
593 593
 			$temp_array['date'] = $row['date'];
594 594
 
@@ -606,10 +606,10 @@  discard block
 block discarded – undo
606 606
 	* @return String success or false
607 607
 	*
608 608
 	*/
609
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
609
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
610 610
 	{
611 611
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
612
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
612
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
613 613
 		try {
614 614
 			$sth = $this->db->prepare($query);
615 615
 			$sth->execute($query_values);
@@ -627,10 +627,10 @@  discard block
 block discarded – undo
627 627
 	* @return String success or false
628 628
 	*
629 629
 	*/
630
-	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
630
+	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL)
631 631
 	{
632 632
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
633
-		$query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code);
633
+		$query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code);
634 634
 		try {
635 635
 			$sth = $this->db->prepare($query);
636 636
 			$sth->execute($query_values);
@@ -649,11 +649,11 @@  discard block
 block discarded – undo
649 649
 	* @return String success or false
650 650
 	*
651 651
 	*/
652
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
652
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
653 653
 	{
654 654
 
655 655
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
656
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
656
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
657 657
 
658 658
 		try {
659 659
 			$sth = $this->db->prepare($query);
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
677 677
 	{
678 678
 		$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 WHERE fammarine_id = :fammarine_id';
679
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
679
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
680 680
 
681 681
 		try {
682 682
 			$sth = $this->db->prepare($query);
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 	* @param String $verticalrate vertival rate of flight
715 715
 	* @return String success or false
716 716
 	*/
717
-	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 = '')
717
+	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 = '')
718 718
 	{
719 719
 		global $globalURL, $globalMarineImageFetch;
720 720
 		
@@ -781,36 +781,36 @@  discard block
 block discarded – undo
781 781
 		}
782 782
 
783 783
     
784
-		if ($date == "" || strtotime($date) < time()-20*60)
784
+		if ($date == "" || strtotime($date) < time() - 20*60)
785 785
 		{
786 786
 			$date = date("Y-m-d H:i:s", time());
787 787
 		}
788 788
 
789
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
790
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
791
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
792
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
793
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
794
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
795
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
796
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
797
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
798
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
799
-		$type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
800
-		$status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
801
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
802
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
803
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
804
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
805
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
806
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
807
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
808
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
789
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
790
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
791
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
792
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
793
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
794
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
795
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
796
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
797
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
798
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
799
+		$type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
800
+		$status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
801
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
802
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
803
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
804
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
805
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
806
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
807
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
808
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
809 809
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
810 810
 			$Image = new Image($this->db);
811
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
811
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
812 812
 			if (!isset($image_array[0]['mmsi'])) {
813
-				$Image->addMarineImage($mmsi,$imo,$ident);
813
+				$Image->addMarineImage($mmsi, $imo, $ident);
814 814
 			}
815 815
 			unset($Image);
816 816
 		}
@@ -823,10 +823,10 @@  discard block
 block discarded – undo
823 823
 		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
824 824
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
825 825
 		if ($arrival_date == '') $arrival_date = NULL;
826
-		$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) 
826
+		$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) 
827 827
 		    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)";
828 828
 
829
-		$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);
829
+		$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);
830 830
 		try {
831 831
 			$sth = $this->db->prepare($query);
832 832
 			$sth->execute($query_values);
@@ -850,13 +850,13 @@  discard block
 block discarded – undo
850 850
 	{
851 851
 		global $globalDBdriver, $globalTimezone;
852 852
 		if ($globalDBdriver == 'mysql') {
853
-			$query  = "SELECT marine_output.ident FROM marine_output 
853
+			$query = "SELECT marine_output.ident FROM marine_output 
854 854
 								WHERE marine_output.ident = :ident 
855 855
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
856 856
 								AND marine_output.date < UTC_TIMESTAMP()";
857 857
 			$query_data = array(':ident' => $ident);
858 858
 		} else {
859
-			$query  = "SELECT marine_output.ident FROM marine_output 
859
+			$query = "SELECT marine_output.ident FROM marine_output 
860 860
 								WHERE marine_output.ident = :ident 
861 861
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
862 862
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -865,8 +865,8 @@  discard block
 block discarded – undo
865 865
 		
866 866
 		$sth = $this->db->prepare($query);
867 867
 		$sth->execute($query_data);
868
-    		$ident_result='';
869
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
868
+    		$ident_result = '';
869
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
870 870
 		{
871 871
 			$ident_result = $row['ident'];
872 872
 		}
@@ -892,8 +892,8 @@  discard block
 block discarded – undo
892 892
 				return false;
893 893
 			} else {
894 894
 				$q_array = explode(" ", $q);
895
-				foreach ($q_array as $q_item){
896
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
895
+				foreach ($q_array as $q_item) {
896
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
897 897
 					$additional_query .= " AND (";
898 898
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
899 899
 					$additional_query .= ")";
@@ -901,11 +901,11 @@  discard block
 block discarded – undo
901 901
 			}
902 902
 		}
903 903
 		if ($globalDBdriver == 'mysql') {
904
-			$query  = "SELECT marine_output.* FROM marine_output 
904
+			$query = "SELECT marine_output.* FROM marine_output 
905 905
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
906 906
 				AND marine_output.date < UTC_TIMESTAMP()";
907 907
 		} else {
908
-			$query  = "SELECT marine_output.* FROM marine_output 
908
+			$query = "SELECT marine_output.* FROM marine_output 
909 909
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
910 910
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
911 911
 		}
@@ -924,16 +924,16 @@  discard block
 block discarded – undo
924 924
 	*
925 925
 	*/
926 926
 
927
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
927
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
928 928
 	{
929 929
 		global $globalDBdriver, $globalArchive;
930 930
 		//$filter_query = $this->getFilter($filters,true,true);
931
-		$Connection= new Connection($this->db);
931
+		$Connection = new Connection($this->db);
932 932
 		if (!$Connection->tableExists('countries')) return array();
933 933
 		require_once('class.SpotterLive.php');
934 934
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
935 935
 			$MarineLive = new MarineLive($this->db);
936
-			$filter_query = $MarineLive->getFilter($filters,true,true);
936
+			$filter_query = $MarineLive->getFilter($filters, true, true);
937 937
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
938 938
 			if ($olderthanmonths > 0) {
939 939
 				if ($globalDBdriver == 'mysql') {
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 		} else {
954 954
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
955 955
 			$MarineArchive = new MarineArchive($this->db);
956
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
956
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
957 957
 			$filter_query .= " over_country <> ''";
958 958
 			if ($olderthanmonths > 0) {
959 959
 				if ($globalDBdriver == 'mysql') {
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 		$flight_array = array();
982 982
 		$temp_array = array();
983 983
         
984
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
984
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
985 985
 		{
986 986
 			$temp_array['marine_count'] = $row['nb'];
987 987
 			$temp_array['marine_country'] = $row['name'];
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
 	* @return Array the callsign list
1001 1001
 	*
1002 1002
 	*/
1003
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1003
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1004 1004
 	{
1005 1005
 		global $globalDBdriver;
1006
-		$filter_query = $this->getFilter($filters,true,true);
1007
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1006
+		$filter_query = $this->getFilter($filters, true, true);
1007
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1008 1008
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1009 1009
 		 if ($olderthanmonths > 0) {
1010 1010
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -1018,28 +1018,28 @@  discard block
 block discarded – undo
1018 1018
 		if ($year != '') {
1019 1019
 			if ($globalDBdriver == 'mysql') {
1020 1020
 				$query .= " AND YEAR(marine_output.date) = :year";
1021
-				$query_values = array_merge($query_values,array(':year' => $year));
1021
+				$query_values = array_merge($query_values, array(':year' => $year));
1022 1022
 			} else {
1023 1023
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1024
-				$query_values = array_merge($query_values,array(':year' => $year));
1024
+				$query_values = array_merge($query_values, array(':year' => $year));
1025 1025
 			}
1026 1026
 		}
1027 1027
 		if ($month != '') {
1028 1028
 			if ($globalDBdriver == 'mysql') {
1029 1029
 				$query .= " AND MONTH(marine_output.date) = :month";
1030
-				$query_values = array_merge($query_values,array(':month' => $month));
1030
+				$query_values = array_merge($query_values, array(':month' => $month));
1031 1031
 			} else {
1032 1032
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1033
-				$query_values = array_merge($query_values,array(':month' => $month));
1033
+				$query_values = array_merge($query_values, array(':month' => $month));
1034 1034
 			}
1035 1035
 		}
1036 1036
 		if ($day != '') {
1037 1037
 			if ($globalDBdriver == 'mysql') {
1038 1038
 				$query .= " AND DAY(marine_output.date) = :day";
1039
-				$query_values = array_merge($query_values,array(':day' => $day));
1039
+				$query_values = array_merge($query_values, array(':day' => $day));
1040 1040
 			} else {
1041 1041
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1042
-				$query_values = array_merge($query_values,array(':day' => $day));
1042
+				$query_values = array_merge($query_values, array(':day' => $day));
1043 1043
 			}
1044 1044
 		}
1045 1045
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 		$callsign_array = array();
1052 1052
 		$temp_array = array();
1053 1053
         
1054
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1054
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1055 1055
 		{
1056 1056
 			$temp_array['callsign_icao'] = $row['ident'];
1057 1057
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 		$date_array = array();
1104 1104
 		$temp_array = array();
1105 1105
         
1106
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1106
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1107 1107
 		{
1108 1108
 			$temp_array['date_name'] = $row['date_name'];
1109 1109
 			$temp_array['date_count'] = $row['date_count'];
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 			$datetime = new DateTime();
1130 1130
 			$offset = $datetime->format('P');
1131 1131
 		} else $offset = '+00:00';
1132
-		$filter_query = $this->getFilter($filters,true,true);
1132
+		$filter_query = $this->getFilter($filters, true, true);
1133 1133
 		if ($globalDBdriver == 'mysql') {
1134 1134
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1135 1135
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 		$date_array = array();
1151 1151
 		$temp_array = array();
1152 1152
         
1153
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1153
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1154 1154
 		{
1155 1155
 			$temp_array['date_name'] = $row['date_name'];
1156 1156
 			$temp_array['date_count'] = $row['date_count'];
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 			$datetime = new DateTime();
1176 1176
 			$offset = $datetime->format('P');
1177 1177
 		} else $offset = '+00:00';
1178
-		$filter_query = $this->getFilter($filters,true,true);
1178
+		$filter_query = $this->getFilter($filters, true, true);
1179 1179
 		if ($globalDBdriver == 'mysql') {
1180 1180
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1181 1181
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 		$date_array = array();
1197 1197
 		$temp_array = array();
1198 1198
         
1199
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1199
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1200 1200
 		{
1201 1201
 			$temp_array['date_name'] = $row['date_name'];
1202 1202
 			$temp_array['date_count'] = $row['date_count'];
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
 		$date_array = array();
1244 1244
 		$temp_array = array();
1245 1245
         
1246
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1246
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1247 1247
 		{
1248 1248
 			$temp_array['month_name'] = $row['month_name'];
1249 1249
 			$temp_array['year_name'] = $row['year_name'];
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 			$datetime = new DateTime();
1273 1273
 			$offset = $datetime->format('P');
1274 1274
 		} else $offset = '+00:00';
1275
-		$filter_query = $this->getFilter($filters,true,true);
1275
+		$filter_query = $this->getFilter($filters, true, true);
1276 1276
 		if ($globalDBdriver == 'mysql') {
1277 1277
 			$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
1278 1278
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 		$date_array = array();
1294 1294
 		$temp_array = array();
1295 1295
         
1296
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1296
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1297 1297
 		{
1298 1298
 			$temp_array['year_name'] = $row['year_name'];
1299 1299
 			$temp_array['month_name'] = $row['month_name'];
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 	* @return Array the hour list
1314 1314
 	*
1315 1315
 	*/
1316
-	public function countAllHours($orderby,$filters = array())
1316
+	public function countAllHours($orderby, $filters = array())
1317 1317
 	{
1318 1318
 		global $globalTimezone, $globalDBdriver;
1319 1319
 		if ($globalTimezone != '') {
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
 		$hour_array = array();
1362 1362
 		$temp_array = array();
1363 1363
         
1364
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1364
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1365 1365
 		{
1366 1366
 			$temp_array['hour_name'] = $row['hour_name'];
1367 1367
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1383,8 +1383,8 @@  discard block
 block discarded – undo
1383 1383
 	public function countAllHoursByDate($date, $filters = array())
1384 1384
 	{
1385 1385
 		global $globalTimezone, $globalDBdriver;
1386
-		$filter_query = $this->getFilter($filters,true,true);
1387
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1386
+		$filter_query = $this->getFilter($filters, true, true);
1387
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1388 1388
 		if ($globalTimezone != '') {
1389 1389
 			date_default_timezone_set($globalTimezone);
1390 1390
 			$datetime = new DateTime($date);
@@ -1392,12 +1392,12 @@  discard block
 block discarded – undo
1392 1392
 		} else $offset = '+00:00';
1393 1393
 
1394 1394
 		if ($globalDBdriver == 'mysql') {
1395
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1395
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1396 1396
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1397 1397
 								GROUP BY hour_name 
1398 1398
 								ORDER BY hour_name ASC";
1399 1399
 		} else {
1400
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1400
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1401 1401
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1402 1402
 								GROUP BY hour_name 
1403 1403
 								ORDER BY hour_name ASC";
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 		$hour_array = array();
1410 1410
 		$temp_array = array();
1411 1411
         
1412
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1412
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1413 1413
 		{
1414 1414
 			$temp_array['hour_name'] = $row['hour_name'];
1415 1415
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1431,8 +1431,8 @@  discard block
 block discarded – undo
1431 1431
 	public function countAllHoursByIdent($ident, $filters = array())
1432 1432
 	{
1433 1433
 		global $globalTimezone, $globalDBdriver;
1434
-		$filter_query = $this->getFilter($filters,true,true);
1435
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1434
+		$filter_query = $this->getFilter($filters, true, true);
1435
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1436 1436
 		if ($globalTimezone != '') {
1437 1437
 			date_default_timezone_set($globalTimezone);
1438 1438
 			$datetime = new DateTime();
@@ -1440,12 +1440,12 @@  discard block
 block discarded – undo
1440 1440
 		} else $offset = '+00:00';
1441 1441
 
1442 1442
 		if ($globalDBdriver == 'mysql') {
1443
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1443
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1444 1444
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1445 1445
 								GROUP BY hour_name 
1446 1446
 								ORDER BY hour_name ASC";
1447 1447
 		} else {
1448
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1448
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1449 1449
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1450 1450
 								GROUP BY hour_name 
1451 1451
 								ORDER BY hour_name ASC";
@@ -1453,12 +1453,12 @@  discard block
 block discarded – undo
1453 1453
       
1454 1454
 		
1455 1455
 		$sth = $this->db->prepare($query);
1456
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1456
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1457 1457
       
1458 1458
 		$hour_array = array();
1459 1459
 		$temp_array = array();
1460 1460
         
1461
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1461
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1462 1462
 		{
1463 1463
 			$temp_array['hour_name'] = $row['hour_name'];
1464 1464
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1477,33 +1477,33 @@  discard block
 block discarded – undo
1477 1477
 	* @return Integer the number of vessels
1478 1478
 	*
1479 1479
 	*/
1480
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1480
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1481 1481
 	{
1482 1482
 		global $globalDBdriver;
1483 1483
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1484
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1484
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1485 1485
 		$query_values = array();
1486 1486
 		$query = '';
1487 1487
 		if ($year != '') {
1488 1488
 			if ($globalDBdriver == 'mysql') {
1489 1489
 				$query .= " AND YEAR(marine_output.date) = :year";
1490
-				$query_values = array_merge($query_values,array(':year' => $year));
1490
+				$query_values = array_merge($query_values, array(':year' => $year));
1491 1491
 			} else {
1492 1492
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1493
-				$query_values = array_merge($query_values,array(':year' => $year));
1493
+				$query_values = array_merge($query_values, array(':year' => $year));
1494 1494
 			}
1495 1495
 		}
1496 1496
 		if ($month != '') {
1497 1497
 			if ($globalDBdriver == 'mysql') {
1498 1498
 				$query .= " AND MONTH(marine_output.date) = :month";
1499
-				$query_values = array_merge($query_values,array(':month' => $month));
1499
+				$query_values = array_merge($query_values, array(':month' => $month));
1500 1500
 			} else {
1501 1501
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1502
-				$query_values = array_merge($query_values,array(':month' => $month));
1502
+				$query_values = array_merge($query_values, array(':month' => $month));
1503 1503
 			}
1504 1504
 		}
1505 1505
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1506
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1506
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1507 1507
 		
1508 1508
 		$sth = $this->db->prepare($queryi);
1509 1509
 		$sth->execute($query_values);
@@ -1516,32 +1516,32 @@  discard block
 block discarded – undo
1516 1516
 	* @return Integer the number of vessels
1517 1517
 	*
1518 1518
 	*/
1519
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1519
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
1520 1520
 	{
1521 1521
 		global $globalDBdriver;
1522
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1522
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1523 1523
 		$query_values = array();
1524 1524
 		$query = '';
1525 1525
 		if ($year != '') {
1526 1526
 			if ($globalDBdriver == 'mysql') {
1527 1527
 				$query .= " AND YEAR(marine_output.date) = :year";
1528
-				$query_values = array_merge($query_values,array(':year' => $year));
1528
+				$query_values = array_merge($query_values, array(':year' => $year));
1529 1529
 			} else {
1530 1530
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1531
-				$query_values = array_merge($query_values,array(':year' => $year));
1531
+				$query_values = array_merge($query_values, array(':year' => $year));
1532 1532
 			}
1533 1533
 		}
1534 1534
 		if ($month != '') {
1535 1535
 			if ($globalDBdriver == 'mysql') {
1536 1536
 				$query .= " AND MONTH(marine_output.date) = :month";
1537
-				$query_values = array_merge($query_values,array(':month' => $month));
1537
+				$query_values = array_merge($query_values, array(':month' => $month));
1538 1538
 			} else {
1539 1539
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1540
-				$query_values = array_merge($query_values,array(':month' => $month));
1540
+				$query_values = array_merge($query_values, array(':month' => $month));
1541 1541
 			}
1542 1542
 		}
1543 1543
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1544
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1544
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1545 1545
 		
1546 1546
 		$sth = $this->db->prepare($queryi);
1547 1547
 		$sth->execute($query_values);
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 	public function countAllHoursFromToday($filters = array())
1559 1559
 	{
1560 1560
 		global $globalTimezone, $globalDBdriver;
1561
-		$filter_query = $this->getFilter($filters,true,true);
1561
+		$filter_query = $this->getFilter($filters, true, true);
1562 1562
 		if ($globalTimezone != '') {
1563 1563
 			date_default_timezone_set($globalTimezone);
1564 1564
 			$datetime = new DateTime();
@@ -1566,12 +1566,12 @@  discard block
 block discarded – undo
1566 1566
 		} else $offset = '+00:00';
1567 1567
 
1568 1568
 		if ($globalDBdriver == 'mysql') {
1569
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1569
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1570 1570
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1571 1571
 								GROUP BY hour_name 
1572 1572
 								ORDER BY hour_name ASC";
1573 1573
 		} else {
1574
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1574
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1575 1575
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1576 1576
 								GROUP BY hour_name 
1577 1577
 								ORDER BY hour_name ASC";
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
 		$hour_array = array();
1584 1584
 		$temp_array = array();
1585 1585
         
1586
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1586
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1587 1587
 		{
1588 1588
 			$temp_array['hour_name'] = $row['hour_name'];
1589 1589
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1602,9 +1602,9 @@  discard block
 block discarded – undo
1602 1602
 	*/
1603 1603
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1604 1604
 	{
1605
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1605
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1606 1606
 
1607
-		$query  = "SELECT marine_output.marine_id
1607
+		$query = "SELECT marine_output.marine_id
1608 1608
 				FROM marine_output 
1609 1609
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1610 1610
         
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
 		$sth = $this->db->prepare($query);
1613 1613
 		$sth->execute();
1614 1614
 
1615
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1615
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1616 1616
 		{
1617 1617
 			return $row['marine_id'];
1618 1618
 		}
@@ -1637,23 +1637,23 @@  discard block
 block discarded – undo
1637 1637
 		}
1638 1638
 		
1639 1639
 		$current_date = date("Y-m-d H:i:s");
1640
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1640
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1641 1641
 		
1642 1642
 		$diff = abs(strtotime($current_date) - strtotime($date));
1643 1643
 
1644
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1644
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1645 1645
 		$years = $time_array['years'];
1646 1646
 		
1647
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1647
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1648 1648
 		$months = $time_array['months'];
1649 1649
 		
1650
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1650
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1651 1651
 		$days = $time_array['days'];
1652
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1652
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1653 1653
 		$hours = $time_array['hours'];
1654
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1654
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1655 1655
 		$minutes = $time_array['minutes'];
1656
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1656
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1657 1657
 		
1658 1658
 		return $time_array;
1659 1659
 	}
@@ -1676,63 +1676,63 @@  discard block
 block discarded – undo
1676 1676
 			$temp_array['direction_degree'] = $direction;
1677 1677
 			$temp_array['direction_shortname'] = "N";
1678 1678
 			$temp_array['direction_fullname'] = "North";
1679
-		} elseif ($direction >= 22.5 && $direction < 45){
1679
+		} elseif ($direction >= 22.5 && $direction < 45) {
1680 1680
 			$temp_array['direction_degree'] = $direction;
1681 1681
 			$temp_array['direction_shortname'] = "NNE";
1682 1682
 			$temp_array['direction_fullname'] = "North-Northeast";
1683
-		} elseif ($direction >= 45 && $direction < 67.5){
1683
+		} elseif ($direction >= 45 && $direction < 67.5) {
1684 1684
 			$temp_array['direction_degree'] = $direction;
1685 1685
 			$temp_array['direction_shortname'] = "NE";
1686 1686
 			$temp_array['direction_fullname'] = "Northeast";
1687
-		} elseif ($direction >= 67.5 && $direction < 90){
1687
+		} elseif ($direction >= 67.5 && $direction < 90) {
1688 1688
 			$temp_array['direction_degree'] = $direction;
1689 1689
 			$temp_array['direction_shortname'] = "ENE";
1690 1690
 			$temp_array['direction_fullname'] = "East-Northeast";
1691
-		} elseif ($direction >= 90 && $direction < 112.5){
1691
+		} elseif ($direction >= 90 && $direction < 112.5) {
1692 1692
 			$temp_array['direction_degree'] = $direction;
1693 1693
 			$temp_array['direction_shortname'] = "E";
1694 1694
 			$temp_array['direction_fullname'] = "East";
1695
-		} elseif ($direction >= 112.5 && $direction < 135){
1695
+		} elseif ($direction >= 112.5 && $direction < 135) {
1696 1696
 			$temp_array['direction_degree'] = $direction;
1697 1697
 			$temp_array['direction_shortname'] = "ESE";
1698 1698
 			$temp_array['direction_fullname'] = "East-Southeast";
1699
-		} elseif ($direction >= 135 && $direction < 157.5){
1699
+		} elseif ($direction >= 135 && $direction < 157.5) {
1700 1700
 			$temp_array['direction_degree'] = $direction;
1701 1701
 			$temp_array['direction_shortname'] = "SE";
1702 1702
 			$temp_array['direction_fullname'] = "Southeast";
1703
-		} elseif ($direction >= 157.5 && $direction < 180){
1703
+		} elseif ($direction >= 157.5 && $direction < 180) {
1704 1704
 			$temp_array['direction_degree'] = $direction;
1705 1705
 			$temp_array['direction_shortname'] = "SSE";
1706 1706
 			$temp_array['direction_fullname'] = "South-Southeast";
1707
-		} elseif ($direction >= 180 && $direction < 202.5){
1707
+		} elseif ($direction >= 180 && $direction < 202.5) {
1708 1708
 			$temp_array['direction_degree'] = $direction;
1709 1709
 			$temp_array['direction_shortname'] = "S";
1710 1710
 			$temp_array['direction_fullname'] = "South";
1711
-		} elseif ($direction >= 202.5 && $direction < 225){
1711
+		} elseif ($direction >= 202.5 && $direction < 225) {
1712 1712
 			$temp_array['direction_degree'] = $direction;
1713 1713
 			$temp_array['direction_shortname'] = "SSW";
1714 1714
 			$temp_array['direction_fullname'] = "South-Southwest";
1715
-		} elseif ($direction >= 225 && $direction < 247.5){
1715
+		} elseif ($direction >= 225 && $direction < 247.5) {
1716 1716
 			$temp_array['direction_degree'] = $direction;
1717 1717
 			$temp_array['direction_shortname'] = "SW";
1718 1718
 			$temp_array['direction_fullname'] = "Southwest";
1719
-		} elseif ($direction >= 247.5 && $direction < 270){
1719
+		} elseif ($direction >= 247.5 && $direction < 270) {
1720 1720
 			$temp_array['direction_degree'] = $direction;
1721 1721
 			$temp_array['direction_shortname'] = "WSW";
1722 1722
 			$temp_array['direction_fullname'] = "West-Southwest";
1723
-		} elseif ($direction >= 270 && $direction < 292.5){
1723
+		} elseif ($direction >= 270 && $direction < 292.5) {
1724 1724
 			$temp_array['direction_degree'] = $direction;
1725 1725
 			$temp_array['direction_shortname'] = "W";
1726 1726
 			$temp_array['direction_fullname'] = "West";
1727
-		} elseif ($direction >= 292.5 && $direction < 315){
1727
+		} elseif ($direction >= 292.5 && $direction < 315) {
1728 1728
 			$temp_array['direction_degree'] = $direction;
1729 1729
 			$temp_array['direction_shortname'] = "WNW";
1730 1730
 			$temp_array['direction_fullname'] = "West-Northwest";
1731
-		} elseif ($direction >= 315 && $direction < 337.5){
1731
+		} elseif ($direction >= 315 && $direction < 337.5) {
1732 1732
 			$temp_array['direction_degree'] = $direction;
1733 1733
 			$temp_array['direction_shortname'] = "NW";
1734 1734
 			$temp_array['direction_fullname'] = "Northwest";
1735
-		} elseif ($direction >= 337.5 && $direction < 360){
1735
+		} elseif ($direction >= 337.5 && $direction < 360) {
1736 1736
 			$temp_array['direction_degree'] = $direction;
1737 1737
 			$temp_array['direction_shortname'] = "NNW";
1738 1738
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1749,11 +1749,11 @@  discard block
 block discarded – undo
1749 1749
 	* @param Float $longitude longitute of the flight
1750 1750
 	* @return String the countrie
1751 1751
 	*/
1752
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1752
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1753 1753
 	{
1754 1754
 		global $globalDBdriver, $globalDebug;
1755
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1756
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1755
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1756
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1757 1757
 	
1758 1758
 		$Connection = new Connection($this->db);
1759 1759
 		if (!$Connection->tableExists('countries')) return '';
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 	public function getCountryFromISO2($iso2)
1794 1794
 	{
1795 1795
 		global $globalDBdriver, $globalDebug;
1796
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1796
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1797 1797
 	
1798 1798
 		$Connection = new Connection($this->db);
1799 1799
 		if (!$Connection->tableExists('countries')) return '';
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
 		
1842 1842
 		$bitly_data = json_decode($bitly_data);
1843 1843
 		$bitly_url = '';
1844
-		if ($bitly_data->status_txt = "OK"){
1844
+		if ($bitly_data->status_txt = "OK") {
1845 1845
 			$bitly_url = $bitly_data->data->url;
1846 1846
 		}
1847 1847
 
@@ -1855,11 +1855,11 @@  discard block
 block discarded – undo
1855 1855
 	* @return Array the vessel type list
1856 1856
 	*
1857 1857
 	*/
1858
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1858
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1859 1859
 	{
1860 1860
 		global $globalDBdriver;
1861
-		$filter_query = $this->getFilter($filters,true,true);
1862
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
1861
+		$filter_query = $this->getFilter($filters, true, true);
1862
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
1863 1863
 		    FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL";
1864 1864
 		if ($olderthanmonths > 0) {
1865 1865
 			if ($globalDBdriver == 'mysql') {
@@ -1879,28 +1879,28 @@  discard block
 block discarded – undo
1879 1879
 		if ($year != '') {
1880 1880
 			if ($globalDBdriver == 'mysql') {
1881 1881
 				$query .= " AND YEAR(marine_output.date) = :year";
1882
-				$query_values = array_merge($query_values,array(':year' => $year));
1882
+				$query_values = array_merge($query_values, array(':year' => $year));
1883 1883
 			} else {
1884 1884
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1885
-				$query_values = array_merge($query_values,array(':year' => $year));
1885
+				$query_values = array_merge($query_values, array(':year' => $year));
1886 1886
 			}
1887 1887
 		}
1888 1888
 		if ($month != '') {
1889 1889
 			if ($globalDBdriver == 'mysql') {
1890 1890
 				$query .= " AND MONTH(marine_output.date) = :month";
1891
-				$query_values = array_merge($query_values,array(':month' => $month));
1891
+				$query_values = array_merge($query_values, array(':month' => $month));
1892 1892
 			} else {
1893 1893
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1894
-				$query_values = array_merge($query_values,array(':month' => $month));
1894
+				$query_values = array_merge($query_values, array(':month' => $month));
1895 1895
 			}
1896 1896
 		}
1897 1897
 		if ($day != '') {
1898 1898
 			if ($globalDBdriver == 'mysql') {
1899 1899
 				$query .= " AND DAY(marine_output.date) = :day";
1900
-				$query_values = array_merge($query_values,array(':day' => $day));
1900
+				$query_values = array_merge($query_values, array(':day' => $day));
1901 1901
 			} else {
1902 1902
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1903
-				$query_values = array_merge($query_values,array(':day' => $day));
1903
+				$query_values = array_merge($query_values, array(':day' => $day));
1904 1904
 			}
1905 1905
 		}
1906 1906
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
@@ -1909,7 +1909,7 @@  discard block
 block discarded – undo
1909 1909
 		$sth->execute($query_values);
1910 1910
 		$marine_array = array();
1911 1911
 		$temp_array = array();
1912
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1912
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1913 1913
 		{
1914 1914
 			$temp_array['marine_type'] = $row['marine_type'];
1915 1915
 			$temp_array['marine_type_id'] = $row['marine_type_id'];
@@ -1925,13 +1925,13 @@  discard block
 block discarded – undo
1925 1925
 	* @return Array the tracker information
1926 1926
 	*
1927 1927
 	*/
1928
-	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1928
+	public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
1929 1929
 	{
1930 1930
 		global $globalTimezone, $globalDBdriver;
1931 1931
 		date_default_timezone_set('UTC');
1932 1932
 		$query_values = array();
1933 1933
 		$additional_query = '';
1934
-		$filter_query = $this->getFilter($filters,true,true);
1934
+		$filter_query = $this->getFilter($filters, true, true);
1935 1935
 		if ($q != "")
1936 1936
 		{
1937 1937
 			if (!is_string($q))
@@ -1939,8 +1939,8 @@  discard block
 block discarded – undo
1939 1939
 				return false;
1940 1940
 			} else {
1941 1941
 				$q_array = explode(" ", $q);
1942
-				foreach ($q_array as $q_item){
1943
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1942
+				foreach ($q_array as $q_item) {
1943
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1944 1944
 					$additional_query .= " AND (";
1945 1945
 					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1946 1946
 					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
@@ -1952,42 +1952,42 @@  discard block
 block discarded – undo
1952 1952
 		}
1953 1953
 		if ($callsign != "")
1954 1954
 		{
1955
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1955
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1956 1956
 			if (!is_string($callsign))
1957 1957
 			{
1958 1958
 				return false;
1959 1959
 			} else {
1960 1960
 				$additional_query .= " AND marine_output.ident = :callsign";
1961
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
1961
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
1962 1962
 			}
1963 1963
 		}
1964 1964
 		if ($mmsi != "")
1965 1965
 		{
1966
-			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
1966
+			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
1967 1967
 			if (!is_numeric($mmsi))
1968 1968
 			{
1969 1969
 				return false;
1970 1970
 			} else {
1971 1971
 				$additional_query .= " AND marine_output.mmsi = :mmsi";
1972
-				$query_values = array_merge($query_values,array(':mmsi' => $mmsi));
1972
+				$query_values = array_merge($query_values, array(':mmsi' => $mmsi));
1973 1973
 			}
1974 1974
 		}
1975 1975
 		if ($imo != "")
1976 1976
 		{
1977
-			$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1977
+			$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1978 1978
 			if (!is_numeric($imo))
1979 1979
 			{
1980 1980
 				return false;
1981 1981
 			} else {
1982 1982
 				$additional_query .= " AND marine_output.imo = :imo";
1983
-				$query_values = array_merge($query_values,array(':imo' => $imo));
1983
+				$query_values = array_merge($query_values, array(':imo' => $imo));
1984 1984
 			}
1985 1985
 		}
1986 1986
 		if ($date_posted != "")
1987 1987
 		{
1988 1988
 			$date_array = explode(",", $date_posted);
1989
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
1990
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
1989
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
1990
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
1991 1991
 			if ($globalTimezone != '') {
1992 1992
 				date_default_timezone_set($globalTimezone);
1993 1993
 				$datetime = new DateTime();
@@ -2014,8 +2014,8 @@  discard block
 block discarded – undo
2014 2014
 		if ($limit != "")
2015 2015
 		{
2016 2016
 			$limit_array = explode(",", $limit);
2017
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
2018
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
2017
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
2018
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
2019 2019
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2020 2020
 			{
2021 2021
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -2033,28 +2033,28 @@  discard block
 block discarded – undo
2033 2033
 			}
2034 2034
 		}
2035 2035
 		if ($origLat != "" && $origLon != "" && $dist != "") {
2036
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
2036
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
2037 2037
 			if ($globalDBdriver == 'mysql') {
2038
-				$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 
2038
+				$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 
2039 2039
 				    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)) 
2040 2040
 				    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;
2041 2041
 			} else {
2042
-				$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 
2042
+				$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 
2043 2043
 				    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)) 
2044 2044
 				    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;
2045 2045
 			}
2046 2046
 		} else {
2047
-			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2047
+			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2048 2048
 			    ".$additional_query."
2049 2049
 			    ".$orderby_query;
2050 2050
 		}
2051
-		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query);
2051
+		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query);
2052 2052
 		return $marine_array;
2053 2053
 	}
2054 2054
 
2055 2055
 	public function getOrderBy()
2056 2056
 	{
2057
-		$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 Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_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"));
2057
+		$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 Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_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"));
2058 2058
 		
2059 2059
 		return $orderby;
2060 2060
 		
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 53;
8 8
 
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 		global $globalNoDB;
11 11
 		if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 			$this->db = null;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 					if ($user === null && $pass === null) {
17 17
 						$this->createDBConnection();
18 18
 					} else {
19
-						$this->createDBConnection(null,$user,$pass);
19
+						$this->createDBConnection(null, $user, $pass);
20 20
 					}
21 21
 				} else {
22 22
 					$this->createDBConnection($dbname);
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 		while (true) {
101 101
 			try {
102 102
 				if ($globalDBSdriver == 'mysql') {
103
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
103
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
104 104
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 105
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
106
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
107
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
108
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
109
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
110
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
111 111
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 112
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 113
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
118 118
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
119 119
 				} else {
120
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
120
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
121 121
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 122
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
123
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
124
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
125
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
126
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
127
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
128 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 129
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 130
 				}
131 131
 				break;
132
-			} catch(PDOException $e) {
132
+			} catch (PDOException $e) {
133 133
 				$i++;
134 134
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
135 135
 				//exit;
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 		try {
155 155
 			//$Connection = new Connection();
156 156
 			$results = $this->db->query($query);
157
-		} catch(PDOException $e) {
157
+		} catch (PDOException $e) {
158 158
 			return false;
159 159
 		}
160
-		if($results->rowCount()>0) {
160
+		if ($results->rowCount() > 0) {
161 161
 		    return true; 
162 162
 		}
163 163
 		else return false;
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 			     return false;
180 180
 			}
181 181
 			
182
-		} catch(PDOException $e) {
183
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182
+		} catch (PDOException $e) {
183
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
184 184
             			throw $e;
185 185
 	                }
186 186
 	                //echo 'error ! '.$e->getMessage();
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	/*
193 193
 	* Check if index exist
194 194
 	*/
195
-	public function indexExists($table,$index)
195
+	public function indexExists($table, $index)
196 196
 	{
197 197
 		global $globalDBdriver, $globalDBname;
198 198
 		if ($globalDBdriver == 'mysql') {
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 		try {
204 204
 			//$Connection = new Connection();
205 205
 			$results = $this->db->query($query);
206
-		} catch(PDOException $e) {
206
+		} catch (PDOException $e) {
207 207
 			return false;
208 208
 		}
209 209
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
210
-		if($nb[0]['nb'] > 0) {
210
+		if ($nb[0]['nb'] > 0) {
211 211
 			return true; 
212 212
 		}
213 213
 		else return false;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$query = "SELECT * FROM ".$table." LIMIT 0";
223 223
 		try {
224 224
 			$results = $this->db->query($query);
225
-		} catch(PDOException $e) {
225
+		} catch (PDOException $e) {
226 226
 			return "error : ".$e->getMessage()."\n";
227 227
 		}
228 228
 		$columns = array();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		return $columns;
235 235
 	}
236 236
 
237
-	public function getColumnType($table,$column) {
237
+	public function getColumnType($table, $column) {
238 238
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
239 239
 		$tomet = $select->getColumnMeta(0);
240 240
 		return $tomet['native_type'];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	* Check if a column name exist in a table
245 245
 	* @return Boolean column exist or not
246 246
 	*/
247
-	public function checkColumnName($table,$name)
247
+	public function checkColumnName($table, $name)
248 248
 	{
249 249
 		global $globalDBdriver, $globalDBname;
250 250
 		if ($globalDBdriver == 'mysql') {
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 		}
255 255
 			try {
256 256
 				$sth = $this->db()->prepare($query);
257
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
258
-			} catch(PDOException $e) {
257
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
258
+			} catch (PDOException $e) {
259 259
 				echo "error : ".$e->getMessage()."\n";
260 260
 			}
261 261
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 				try {
295 295
 					$sth = $this->db->prepare($query);
296 296
 					$sth->execute();
297
-				} catch(PDOException $e) {
297
+				} catch (PDOException $e) {
298 298
 					return "error : ".$e->getMessage()."\n";
299 299
 				}
300 300
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
marine-data.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
 
10 10
 $from_archive = false;
11 11
 if (isset($_GET['ident'])) {
12
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
13 13
 	if (isset($_GET['currenttime'])) {
14
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
14
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
15 15
 		$currenttime = round($currenttime/1000);
16
-		$spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident,$currenttime);
16
+		$spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident, $currenttime);
17 17
 		
18 18
 		if (empty($spotter_array)) {
19 19
 			$from_archive = true;
20
-			$spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident,$currenttime);
20
+			$spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident, $currenttime);
21 21
 		}
22 22
 		
23 23
 	} else {
@@ -31,16 +31,16 @@  discard block
 block discarded – undo
31 31
 	}
32 32
 }
33 33
 if (isset($_GET['fammarine_id'])) {
34
-	$fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING);
34
+	$fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING);
35 35
 	if (isset($_GET['currenttime'])) {
36
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
36
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
37 37
 		$currenttime = round($currenttime/1000);
38
-		$spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id,$currenttime);
38
+		$spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id, $currenttime);
39 39
 		
40 40
 		if (empty($spotter_array)) {
41 41
 			$from_archive = true;
42 42
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
43
-			$spotter_array = $MarineArchive->getDateArchiveMarineDataById($fammarine_id,$currenttime);
43
+			$spotter_array = $MarineArchive->getDateArchiveMarineDataById($fammarine_id, $currenttime);
44 44
 		}
45 45
 		
46 46
 	} else {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
65
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
66 66
 	} else $image = $spotter_item['image_thumbnail'];
67 67
 
68 68
 }
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 */
91 91
 print '<div><span>'._("Speed").'</span>';
92 92
 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
93
-	print round($spotter_item['ground_speed']*0.621371,2).' mph';
93
+	print round($spotter_item['ground_speed']*0.621371, 2).' mph';
94 94
 } elseif ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
95
-	print round($spotter_item['ground_speed']*0.539957,2).' knots';
95
+	print round($spotter_item['ground_speed']*0.539957, 2).' knots';
96 96
 } else {
97 97
 	print $spotter_item['ground_speed'].' km/h';
98 98
 }
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Spacing   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -814,17 +814,17 @@  discard block
 block discarded – undo
814 814
 			try {
815 815
 				$sth = $Connection->db->prepare($query);
816 816
 				$sth->execute();
817
-			} catch(PDOException $e) {
817
+			} catch (PDOException $e) {
818 818
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
819 819
 			}
820 820
 		}
821
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
821
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
822 822
 			// Add aircraft_manufacturer to stats_aircraft
823 823
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824 824
 			try {
825 825
 				$sth = $Connection->db->prepare($query);
826 826
 				$sth->execute();
827
-			} catch(PDOException $e) {
827
+			} catch (PDOException $e) {
828 828
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
829 829
     			}
830 830
     		}
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 		try {
834 834
 			$sth = $Connection->db->prepare($query);
835 835
 			$sth->execute();
836
-		} catch(PDOException $e) {
836
+		} catch (PDOException $e) {
837 837
 			return "error (update schema_version) : ".$e->getMessage()."\n";
838 838
 		}
839 839
 		return $error;
@@ -849,23 +849,23 @@  discard block
 block discarded – undo
849 849
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 850
 		}
851 851
 		if ($error != '') return 'Import airlines.sql : '.$error;
852
-		if (!$Connection->checkColumnName('airlines','forsource')) {
852
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
853 853
 			// Add forsource to airlines
854 854
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
855 855
 			try {
856 856
 				$sth = $Connection->db->prepare($query);
857 857
 				$sth->execute();
858
-			} catch(PDOException $e) {
858
+			} catch (PDOException $e) {
859 859
 				return "error (add forsource column) : ".$e->getMessage()."\n";
860 860
 			}
861 861
 		}
862
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
862
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
863 863
 			// Add forsource to airlines
864 864
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
865 865
 			try {
866 866
 				$sth = $Connection->db->prepare($query);
867 867
 				$sth->execute();
868
-			} catch(PDOException $e) {
868
+			} catch (PDOException $e) {
869 869
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
870 870
 			}
871 871
 			// Add unique key
@@ -877,17 +877,17 @@  discard block
 block discarded – undo
877 877
 			try {
878 878
 				$sth = $Connection->db->prepare($query);
879 879
 				$sth->execute();
880
-			} catch(PDOException $e) {
880
+			} catch (PDOException $e) {
881 881
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
882 882
 			}
883 883
 		}
884
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
884
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
885 885
 			// Add forsource to airlines
886 886
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
887 887
 			try {
888 888
 				$sth = $Connection->db->prepare($query);
889 889
 				$sth->execute();
890
-			} catch(PDOException $e) {
890
+			} catch (PDOException $e) {
891 891
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
892 892
 			}
893 893
 			// Add unique key
@@ -899,17 +899,17 @@  discard block
 block discarded – undo
899 899
 			try {
900 900
 				$sth = $Connection->db->prepare($query);
901 901
 				$sth->execute();
902
-			} catch(PDOException $e) {
902
+			} catch (PDOException $e) {
903 903
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
904 904
 			}
905 905
 		}
906
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
906
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
907 907
 			// Add forsource to airlines
908 908
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
909 909
 			try {
910 910
 				$sth = $Connection->db->prepare($query);
911 911
 				$sth->execute();
912
-			} catch(PDOException $e) {
912
+			} catch (PDOException $e) {
913 913
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
914 914
 			}
915 915
 			// Add unique key
@@ -921,36 +921,36 @@  discard block
 block discarded – undo
921 921
 			try {
922 922
 				$sth = $Connection->db->prepare($query);
923 923
 				$sth->execute();
924
-			} catch(PDOException $e) {
924
+			} catch (PDOException $e) {
925 925
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
926 926
 			}
927 927
 		}
928
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
928
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
929 929
 			// Add forsource to airlines
930 930
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
931 931
 			try {
932 932
 				$sth = $Connection->db->prepare($query);
933 933
 				$sth->execute();
934
-			} catch(PDOException $e) {
934
+			} catch (PDOException $e) {
935 935
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
936 936
 			}
937 937
 		}
938
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
938
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
939 939
 			// Add forsource to airlines
940 940
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
941 941
 			try {
942 942
 				$sth = $Connection->db->prepare($query);
943 943
 				$sth->execute();
944
-			} catch(PDOException $e) {
944
+			} catch (PDOException $e) {
945 945
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
946 946
 			}
947
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
947
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
948 948
 				// Add unique key
949 949
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
950 950
 				try {
951 951
 					$sth = $Connection->db->prepare($query);
952 952
 					$sth->execute();
953
-				} catch(PDOException $e) {
953
+				} catch (PDOException $e) {
954 954
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
955 955
 				}
956 956
 			} else {
@@ -963,18 +963,18 @@  discard block
 block discarded – undo
963 963
 				try {
964 964
 					$sth = $Connection->db->prepare($query);
965 965
 					$sth->execute();
966
-				} catch(PDOException $e) {
966
+				} catch (PDOException $e) {
967 967
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
968 968
 				}
969 969
 			}
970 970
 		}
971
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
971
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
972 972
 			// Add forsource to airlines
973 973
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
974 974
 			try {
975 975
 				$sth = $Connection->db->prepare($query);
976 976
 				$sth->execute();
977
-			} catch(PDOException $e) {
977
+			} catch (PDOException $e) {
978 978
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
979 979
 			}
980 980
 			// Add unique key
@@ -986,17 +986,17 @@  discard block
 block discarded – undo
986 986
 			try {
987 987
 				$sth = $Connection->db->prepare($query);
988 988
 				$sth->execute();
989
-			} catch(PDOException $e) {
989
+			} catch (PDOException $e) {
990 990
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
991 991
 			}
992 992
 		}
993
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
993
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
994 994
 			// Add forsource to airlines
995 995
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
996 996
 			try {
997 997
 				$sth = $Connection->db->prepare($query);
998 998
 				$sth->execute();
999
-			} catch(PDOException $e) {
999
+			} catch (PDOException $e) {
1000 1000
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1001 1001
 			}
1002 1002
 			// Add unique key
@@ -1008,17 +1008,17 @@  discard block
 block discarded – undo
1008 1008
 			try {
1009 1009
 				$sth = $Connection->db->prepare($query);
1010 1010
 				$sth->execute();
1011
-			} catch(PDOException $e) {
1011
+			} catch (PDOException $e) {
1012 1012
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1013 1013
 			}
1014 1014
 		}
1015
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1015
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1016 1016
 			// Add forsource to airlines
1017 1017
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1018 1018
 			try {
1019 1019
 				$sth = $Connection->db->prepare($query);
1020 1020
 				$sth->execute();
1021
-			} catch(PDOException $e) {
1021
+			} catch (PDOException $e) {
1022 1022
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1023 1023
 			}
1024 1024
 			// Add unique key
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 			try {
1031 1031
 				$sth = $Connection->db->prepare($query);
1032 1032
 				$sth->execute();
1033
-			} catch(PDOException $e) {
1033
+			} catch (PDOException $e) {
1034 1034
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1035 1035
 			}
1036 1036
 		}
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 		try {
1040 1040
 			$sth = $Connection->db->prepare($query);
1041 1041
 			$sth->execute();
1042
-		} catch(PDOException $e) {
1042
+		} catch (PDOException $e) {
1043 1043
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1044 1044
 		}
1045 1045
 		return $error;
@@ -1049,13 +1049,13 @@  discard block
 block discarded – undo
1049 1049
 		global $globalDBdriver;
1050 1050
 		$Connection = new Connection();
1051 1051
 		$error = '';
1052
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1052
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1053 1053
 			// Add forsource to airlines
1054 1054
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1055 1055
 			try {
1056 1056
 				$sth = $Connection->db->prepare($query);
1057 1057
 				$sth->execute();
1058
-			} catch(PDOException $e) {
1058
+			} catch (PDOException $e) {
1059 1059
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1060 1060
 			}
1061 1061
 			// Add unique key
@@ -1067,17 +1067,17 @@  discard block
 block discarded – undo
1067 1067
 			try {
1068 1068
 				$sth = $Connection->db->prepare($query);
1069 1069
 				$sth->execute();
1070
-			} catch(PDOException $e) {
1070
+			} catch (PDOException $e) {
1071 1071
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1072 1072
 			}
1073 1073
 		}
1074
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1074
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1075 1075
 			// Add forsource to airlines
1076 1076
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1077 1077
 			try {
1078 1078
 				$sth = $Connection->db->prepare($query);
1079 1079
 				$sth->execute();
1080
-			} catch(PDOException $e) {
1080
+			} catch (PDOException $e) {
1081 1081
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1082 1082
 			}
1083 1083
 			// Add unique key
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 			try {
1090 1090
 				$sth = $Connection->db->prepare($query);
1091 1091
 				$sth->execute();
1092
-			} catch(PDOException $e) {
1092
+			} catch (PDOException $e) {
1093 1093
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1094 1094
 			}
1095 1095
 		}
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 		try {
1098 1098
 			$sth = $Connection->db->prepare($query);
1099 1099
 			$sth->execute();
1100
-		} catch(PDOException $e) {
1100
+		} catch (PDOException $e) {
1101 1101
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1102 1102
 		}
1103 1103
 		return $error;
@@ -1107,12 +1107,12 @@  discard block
 block discarded – undo
1107 1107
 		global $globalDBdriver;
1108 1108
 		$Connection = new Connection();
1109 1109
 		$error = '';
1110
-		if (!$Connection->checkColumnName('atc','format_source')) {
1110
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1111 1111
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1112 1112
 			try {
1113 1113
 				$sth = $Connection->db->prepare($query);
1114 1114
 				$sth->execute();
1115
-			} catch(PDOException $e) {
1115
+			} catch (PDOException $e) {
1116 1116
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1117 1117
 			}
1118 1118
 		}
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 		try {
1121 1121
 			$sth = $Connection->db->prepare($query);
1122 1122
 			$sth->execute();
1123
-		} catch(PDOException $e) {
1123
+		} catch (PDOException $e) {
1124 1124
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1125 1125
 		}
1126 1126
 		return $error;
@@ -1130,13 +1130,13 @@  discard block
 block discarded – undo
1130 1130
 		global $globalDBdriver;
1131 1131
 		$Connection = new Connection();
1132 1132
 		$error = '';
1133
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1133
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1134 1134
 			// Add forsource to airlines
1135 1135
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1136 1136
 			try {
1137 1137
 				$sth = $Connection->db->prepare($query);
1138 1138
 				$sth->execute();
1139
-			} catch(PDOException $e) {
1139
+			} catch (PDOException $e) {
1140 1140
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1141 1141
 			}
1142 1142
 			// Add unique key
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 			try {
1149 1149
 				$sth = $Connection->db->prepare($query);
1150 1150
 				$sth->execute();
1151
-			} catch(PDOException $e) {
1151
+			} catch (PDOException $e) {
1152 1152
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1153 1153
 			}
1154 1154
 		}
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 		try {
1157 1157
 			$sth = $Connection->db->prepare($query);
1158 1158
 			$sth->execute();
1159
-		} catch(PDOException $e) {
1159
+		} catch (PDOException $e) {
1160 1160
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1161 1161
 		}
1162 1162
 		return $error;
@@ -1166,23 +1166,23 @@  discard block
 block discarded – undo
1166 1166
 		global $globalDBdriver;
1167 1167
 		$Connection = new Connection();
1168 1168
 		$error = '';
1169
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1169
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1170 1170
 			// Add unique key
1171 1171
 			$query = "alter table spotter_live add index(latitude,longitude)";
1172 1172
 			try {
1173 1173
 				$sth = $Connection->db->prepare($query);
1174 1174
 				$sth->execute();
1175
-			} catch(PDOException $e) {
1175
+			} catch (PDOException $e) {
1176 1176
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1177 1177
 			}
1178 1178
                 }
1179
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1179
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1180 1180
 			// Add mfr to aircraft
1181 1181
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1182 1182
 			try {
1183 1183
 				$sth = $Connection->db->prepare($query);
1184 1184
 				$sth->execute();
1185
-			} catch(PDOException $e) {
1185
+			} catch (PDOException $e) {
1186 1186
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1187 1187
 			}
1188 1188
 		}
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
 		try {
1199 1199
 			$sth = $Connection->db->prepare($query);
1200 1200
 			$sth->execute();
1201
-		} catch(PDOException $e) {
1201
+		} catch (PDOException $e) {
1202 1202
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1203 1203
 		}
1204 1204
 		return $error;
@@ -1208,13 +1208,13 @@  discard block
 block discarded – undo
1208 1208
 		global $globalDBdriver;
1209 1209
 		$Connection = new Connection();
1210 1210
 		$error = '';
1211
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1211
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1212 1212
 			// drop mfr to aircraft
1213 1213
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1214 1214
 			try {
1215 1215
 				$sth = $Connection->db->prepare($query);
1216 1216
 				$sth->execute();
1217
-			} catch(PDOException $e) {
1217
+			} catch (PDOException $e) {
1218 1218
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1219 1219
 			}
1220 1220
 		}
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 		try {
1231 1231
 			$sth = $Connection->db->prepare($query);
1232 1232
 			$sth->execute();
1233
-		} catch(PDOException $e) {
1233
+		} catch (PDOException $e) {
1234 1234
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1235 1235
 		}
1236 1236
 		return $error;
@@ -1240,33 +1240,33 @@  discard block
 block discarded – undo
1240 1240
 		global $globalDBdriver;
1241 1241
 		$Connection = new Connection();
1242 1242
 		$error = '';
1243
-		if (!$Connection->indexExists('notam','ref_idx')) {
1243
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1244 1244
 			// Add index key
1245 1245
 			$query = "create index ref_idx on notam (ref)";
1246 1246
 			try {
1247 1247
 				$sth = $Connection->db->prepare($query);
1248 1248
 				$sth->execute();
1249
-			} catch(PDOException $e) {
1249
+			} catch (PDOException $e) {
1250 1250
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1251 1251
 			}
1252 1252
                 }
1253
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1253
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1254 1254
 			// Add index key
1255 1255
 			$query = "create index registration_idx on accidents (registration)";
1256 1256
 			try {
1257 1257
 				$sth = $Connection->db->prepare($query);
1258 1258
 				$sth->execute();
1259
-			} catch(PDOException $e) {
1259
+			} catch (PDOException $e) {
1260 1260
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1261 1261
 			}
1262 1262
                 }
1263
-		if (!$Connection->indexExists('accidents','rdts')) {
1263
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1264 1264
 			// Add index key
1265 1265
 			$query = "create index rdts on accidents (registration,date,type,source)";
1266 1266
 			try {
1267 1267
 				$sth = $Connection->db->prepare($query);
1268 1268
 				$sth->execute();
1269
-			} catch(PDOException $e) {
1269
+			} catch (PDOException $e) {
1270 1270
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1271 1271
 			}
1272 1272
                 }
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 		try {
1276 1276
 			$sth = $Connection->db->prepare($query);
1277 1277
 			$sth->execute();
1278
-		} catch(PDOException $e) {
1278
+		} catch (PDOException $e) {
1279 1279
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1280 1280
 		}
1281 1281
 		return $error;
@@ -1285,23 +1285,23 @@  discard block
 block discarded – undo
1285 1285
 		global $globalDBdriver;
1286 1286
 		$Connection = new Connection();
1287 1287
 		$error = '';
1288
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1288
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1289 1289
 			// Add airline_name to accidents
1290 1290
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1291 1291
 			try {
1292 1292
 				$sth = $Connection->db->prepare($query);
1293 1293
 				$sth->execute();
1294
-			} catch(PDOException $e) {
1294
+			} catch (PDOException $e) {
1295 1295
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1296 1296
 			}
1297 1297
 		}
1298
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1298
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1299 1299
 			// Add airline_icao to accidents
1300 1300
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1301 1301
 			try {
1302 1302
 				$sth = $Connection->db->prepare($query);
1303 1303
 				$sth->execute();
1304
-			} catch(PDOException $e) {
1304
+			} catch (PDOException $e) {
1305 1305
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1306 1306
 			}
1307 1307
 		}
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 		try {
1310 1310
 			$sth = $Connection->db->prepare($query);
1311 1311
 			$sth->execute();
1312
-		} catch(PDOException $e) {
1312
+		} catch (PDOException $e) {
1313 1313
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1314 1314
 		}
1315 1315
 		return $error;
@@ -1319,13 +1319,13 @@  discard block
 block discarded – undo
1319 1319
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1320 1320
 		$Connection = new Connection();
1321 1321
 		$error = '';
1322
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1322
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1323 1323
 			// Add alliance to airlines
1324 1324
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1325 1325
 			try {
1326 1326
 				$sth = $Connection->db->prepare($query);
1327 1327
 				$sth->execute();
1328
-			} catch(PDOException $e) {
1328
+			} catch (PDOException $e) {
1329 1329
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1330 1330
 			}
1331 1331
 		}
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 		try {
1353 1353
 			$sth = $Connection->db->prepare($query);
1354 1354
 			$sth->execute();
1355
-		} catch(PDOException $e) {
1355
+		} catch (PDOException $e) {
1356 1356
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1357 1357
 		}
1358 1358
 		return $error;
@@ -1362,13 +1362,13 @@  discard block
 block discarded – undo
1362 1362
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1363 1363
 		$Connection = new Connection();
1364 1364
 		$error = '';
1365
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1365
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1366 1366
 			// Add ban_eu to airlines
1367 1367
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1368 1368
 			try {
1369 1369
 				$sth = $Connection->db->prepare($query);
1370 1370
 				$sth->execute();
1371
-			} catch(PDOException $e) {
1371
+			} catch (PDOException $e) {
1372 1372
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1373 1373
 			}
1374 1374
 		}
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 		try {
1377 1377
 			$sth = $Connection->db->prepare($query);
1378 1378
 			$sth->execute();
1379
-		} catch(PDOException $e) {
1379
+		} catch (PDOException $e) {
1380 1380
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1381 1381
 		}
1382 1382
 		return $error;
@@ -1387,19 +1387,19 @@  discard block
 block discarded – undo
1387 1387
 		$Connection = new Connection();
1388 1388
 		$error = '';
1389 1389
 		if ($globalDBdriver == 'mysql') {
1390
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1390
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1391 1391
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1392 1392
 				try {
1393 1393
 					$sth = $Connection->db->prepare($query);
1394 1394
 					$sth->execute();
1395
-				} catch(PDOException $e) {
1395
+				} catch (PDOException $e) {
1396 1396
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1397 1397
 				}
1398 1398
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1399 1399
 				try {
1400 1400
 					$sth = $Connection->db->prepare($query);
1401 1401
 					$sth->execute();
1402
-				} catch(PDOException $e) {
1402
+				} catch (PDOException $e) {
1403 1403
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1404 1404
 				}
1405 1405
 				
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 				try {
1408 1408
 					$sth = $Connection->db->prepare($query);
1409 1409
 					$sth->execute();
1410
-				} catch(PDOException $e) {
1410
+				} catch (PDOException $e) {
1411 1411
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1412 1412
 				}
1413 1413
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
 				try {
1459 1459
 					$sth = $Connection->db->prepare($query);
1460 1460
 					$sth->execute();
1461
-				} catch(PDOException $e) {
1461
+				} catch (PDOException $e) {
1462 1462
 					return "error (fix date) : ".$e->getMessage()."\n";
1463 1463
 				}
1464 1464
 			}
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 		try {
1544 1544
 			$sth = $Connection->db->prepare($query);
1545 1545
 			$sth->execute();
1546
-		} catch(PDOException $e) {
1546
+		} catch (PDOException $e) {
1547 1547
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1548 1548
 		}
1549 1549
 		return $error;
@@ -1552,13 +1552,13 @@  discard block
 block discarded – undo
1552 1552
 		global $globalDBdriver;
1553 1553
 		$Connection = new Connection();
1554 1554
 		$error = '';
1555
-		if (!$Connection->indexExists('accidents','type')) {
1555
+		if (!$Connection->indexExists('accidents', 'type')) {
1556 1556
 			// Add index key
1557 1557
 			$query = "create index type on accidents (type,date)";
1558 1558
 			try {
1559 1559
 				$sth = $Connection->db->prepare($query);
1560 1560
 				$sth->execute();
1561
-			} catch(PDOException $e) {
1561
+			} catch (PDOException $e) {
1562 1562
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1563 1563
 			}
1564 1564
                 }
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
 		try {
1567 1567
 			$sth = $Connection->db->prepare($query);
1568 1568
 			$sth->execute();
1569
-		} catch(PDOException $e) {
1569
+		} catch (PDOException $e) {
1570 1570
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1571 1571
 		}
1572 1572
 		return $error;
@@ -1576,12 +1576,12 @@  discard block
 block discarded – undo
1576 1576
 		global $globalDBdriver;
1577 1577
 		$Connection = new Connection();
1578 1578
 		$error = '';
1579
-		if (!$Connection->checkColumnName('aircraft_modes','source_type')) {
1579
+		if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) {
1580 1580
 			$query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'";
1581 1581
 			try {
1582 1582
 				$sth = $Connection->db->prepare($query);
1583 1583
 				$sth->execute();
1584
-			} catch(PDOException $e) {
1584
+			} catch (PDOException $e) {
1585 1585
 				return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n";
1586 1586
 			}
1587 1587
 		}
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 		try {
1648 1648
 			$sth = $Connection->db->prepare($query);
1649 1649
 			$sth->execute();
1650
-		} catch(PDOException $e) {
1650
+		} catch (PDOException $e) {
1651 1651
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1652 1652
 		}
1653 1653
 		return $error;
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 			try {
1700 1700
 				$sth = $Connection->db->prepare($query);
1701 1701
 				$sth->execute();
1702
-			} catch(PDOException $e) {
1702
+			} catch (PDOException $e) {
1703 1703
 				return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
1704 1704
 			}
1705 1705
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1708,18 +1708,18 @@  discard block
 block discarded – undo
1708 1708
 				try {
1709 1709
 					$sth = $Connection->db->prepare($query);
1710 1710
 					$sth->execute();
1711
-				} catch(PDOException $e) {
1711
+				} catch (PDOException $e) {
1712 1712
 					return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n";
1713 1713
 				}
1714 1714
 			}
1715 1715
 		}
1716
-		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1716
+		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) {
1717 1717
 			// Add index key
1718 1718
 			$query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)";
1719 1719
 			try {
1720 1720
 				$sth = $Connection->db->prepare($query);
1721 1721
 				$sth->execute();
1722
-			} catch(PDOException $e) {
1722
+			} catch (PDOException $e) {
1723 1723
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1724 1724
 			}
1725 1725
                 }
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 		try {
1728 1728
 			$sth = $Connection->db->prepare($query);
1729 1729
 			$sth->execute();
1730
-		} catch(PDOException $e) {
1730
+		} catch (PDOException $e) {
1731 1731
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1732 1732
 		}
1733 1733
 		return $error;
@@ -1738,148 +1738,148 @@  discard block
 block discarded – undo
1738 1738
 		$Connection = new Connection();
1739 1739
 		$error = '';
1740 1740
 		if ($globalDBdriver == 'mysql') {
1741
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1741
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1742 1742
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL";
1743 1743
 				try {
1744 1744
 					$sth = $Connection->db->prepare($query);
1745 1745
 					$sth->execute();
1746
-				} catch(PDOException $e) {
1746
+				} catch (PDOException $e) {
1747 1747
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1748 1748
 				}
1749 1749
 			}
1750
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1750
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1751 1751
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL";
1752 1752
 				try {
1753 1753
 					$sth = $Connection->db->prepare($query);
1754 1754
 					$sth->execute();
1755
-				} catch(PDOException $e) {
1755
+				} catch (PDOException $e) {
1756 1756
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1757 1757
 				}
1758 1758
 			}
1759
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1759
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1760 1760
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL";
1761 1761
 				try {
1762 1762
 					$sth = $Connection->db->prepare($query);
1763 1763
 					$sth->execute();
1764
-				} catch(PDOException $e) {
1764
+				} catch (PDOException $e) {
1765 1765
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1766 1766
 				}
1767 1767
 			}
1768
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1768
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1769 1769
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL";
1770 1770
 				try {
1771 1771
 					$sth = $Connection->db->prepare($query);
1772 1772
 					$sth->execute();
1773
-				} catch(PDOException $e) {
1773
+				} catch (PDOException $e) {
1774 1774
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1775 1775
 				}
1776 1776
 			}
1777
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1777
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1778 1778
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL";
1779 1779
 				try {
1780 1780
 					$sth = $Connection->db->prepare($query);
1781 1781
 					$sth->execute();
1782
-				} catch(PDOException $e) {
1782
+				} catch (PDOException $e) {
1783 1783
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1784 1784
 				}
1785 1785
 			}
1786
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1786
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1787 1787
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL";
1788 1788
 				try {
1789 1789
 					$sth = $Connection->db->prepare($query);
1790 1790
 					$sth->execute();
1791
-				} catch(PDOException $e) {
1791
+				} catch (PDOException $e) {
1792 1792
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1793 1793
 				}
1794 1794
 			}
1795
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1795
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1796 1796
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL";
1797 1797
 				try {
1798 1798
 					$sth = $Connection->db->prepare($query);
1799 1799
 					$sth->execute();
1800
-				} catch(PDOException $e) {
1800
+				} catch (PDOException $e) {
1801 1801
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1802 1802
 				}
1803 1803
 			}
1804
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1804
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1805 1805
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL";
1806 1806
 				try {
1807 1807
 					$sth = $Connection->db->prepare($query);
1808 1808
 					$sth->execute();
1809
-				} catch(PDOException $e) {
1809
+				} catch (PDOException $e) {
1810 1810
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1811 1811
 				}
1812 1812
 			}
1813 1813
 		} else {
1814
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1814
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1815 1815
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL";
1816 1816
 				try {
1817 1817
 					$sth = $Connection->db->prepare($query);
1818 1818
 					$sth->execute();
1819
-				} catch(PDOException $e) {
1819
+				} catch (PDOException $e) {
1820 1820
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1821 1821
 				}
1822 1822
 			}
1823
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1823
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1824 1824
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL";
1825 1825
 				try {
1826 1826
 					$sth = $Connection->db->prepare($query);
1827 1827
 					$sth->execute();
1828
-				} catch(PDOException $e) {
1828
+				} catch (PDOException $e) {
1829 1829
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1830 1830
 				}
1831 1831
 			}
1832
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1832
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1833 1833
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL";
1834 1834
 				try {
1835 1835
 					$sth = $Connection->db->prepare($query);
1836 1836
 					$sth->execute();
1837
-				} catch(PDOException $e) {
1837
+				} catch (PDOException $e) {
1838 1838
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1839 1839
 				}
1840 1840
 			}
1841
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1841
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1842 1842
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL";
1843 1843
 				try {
1844 1844
 					$sth = $Connection->db->prepare($query);
1845 1845
 					$sth->execute();
1846
-				} catch(PDOException $e) {
1846
+				} catch (PDOException $e) {
1847 1847
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1848 1848
 				}
1849 1849
 			}
1850
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1850
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1851 1851
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL";
1852 1852
 				try {
1853 1853
 					$sth = $Connection->db->prepare($query);
1854 1854
 					$sth->execute();
1855
-				} catch(PDOException $e) {
1855
+				} catch (PDOException $e) {
1856 1856
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1857 1857
 				}
1858 1858
 			}
1859
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1859
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1860 1860
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL";
1861 1861
 				try {
1862 1862
 					$sth = $Connection->db->prepare($query);
1863 1863
 					$sth->execute();
1864
-				} catch(PDOException $e) {
1864
+				} catch (PDOException $e) {
1865 1865
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1866 1866
 				}
1867 1867
 			}
1868
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1868
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1869 1869
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL";
1870 1870
 				try {
1871 1871
 					$sth = $Connection->db->prepare($query);
1872 1872
 					$sth->execute();
1873
-				} catch(PDOException $e) {
1873
+				} catch (PDOException $e) {
1874 1874
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1875 1875
 				}
1876 1876
 			}
1877
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1877
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1878 1878
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL";
1879 1879
 				try {
1880 1880
 					$sth = $Connection->db->prepare($query);
1881 1881
 					$sth->execute();
1882
-				} catch(PDOException $e) {
1882
+				} catch (PDOException $e) {
1883 1883
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1884 1884
 				}
1885 1885
 			}
@@ -1888,7 +1888,7 @@  discard block
 block discarded – undo
1888 1888
 		try {
1889 1889
 			$sth = $Connection->db->prepare($query);
1890 1890
 			$sth->execute();
1891
-		} catch(PDOException $e) {
1891
+		} catch (PDOException $e) {
1892 1892
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1893 1893
 		}
1894 1894
 		return $error;
@@ -1903,14 +1903,14 @@  discard block
 block discarded – undo
1903 1903
 			try {
1904 1904
 				$sth = $Connection->db->prepare($query);
1905 1905
 				$sth->execute();
1906
-			} catch(PDOException $e) {
1906
+			} catch (PDOException $e) {
1907 1907
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1908 1908
 			}
1909 1909
 			$query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL";
1910 1910
 			try {
1911 1911
 				$sth = $Connection->db->prepare($query);
1912 1912
 				$sth->execute();
1913
-			} catch(PDOException $e) {
1913
+			} catch (PDOException $e) {
1914 1914
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1915 1915
 			}
1916 1916
 		} else {
@@ -1918,14 +1918,14 @@  discard block
 block discarded – undo
1918 1918
 			try {
1919 1919
 				$sth = $Connection->db->prepare($query);
1920 1920
 				$sth->execute();
1921
-			} catch(PDOException $e) {
1921
+			} catch (PDOException $e) {
1922 1922
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1923 1923
 			}
1924 1924
 			$query = "alter table marine_identity alter column mmsi type varchar(255)";
1925 1925
 			try {
1926 1926
 				$sth = $Connection->db->prepare($query);
1927 1927
 				$sth->execute();
1928
-			} catch(PDOException $e) {
1928
+			} catch (PDOException $e) {
1929 1929
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1930 1930
 			}
1931 1931
 		}
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 		try {
1934 1934
 			$sth = $Connection->db->prepare($query);
1935 1935
 			$sth->execute();
1936
-		} catch(PDOException $e) {
1936
+		} catch (PDOException $e) {
1937 1937
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1938 1938
 		}
1939 1939
 		return $error;
@@ -1943,32 +1943,32 @@  discard block
 block discarded – undo
1943 1943
 		global $globalDBdriver;
1944 1944
 		$Connection = new Connection();
1945 1945
 		$error = '';
1946
-		if (!$Connection->checkColumnName('source_location','last_seen')) {
1946
+		if (!$Connection->checkColumnName('source_location', 'last_seen')) {
1947 1947
 			$query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL";
1948 1948
 			try {
1949 1949
 				$sth = $Connection->db->prepare($query);
1950 1950
 				$sth->execute();
1951
-			} catch(PDOException $e) {
1951
+			} catch (PDOException $e) {
1952 1952
 				return "error (add column last_seen in source_location) : ".$e->getMessage()."\n";
1953 1953
 			}
1954 1954
 		}
1955 1955
 		if ($globalDBdriver == 'mysql') {
1956
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1956
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1957 1957
 				$query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL";
1958 1958
 				try {
1959 1959
 					$sth = $Connection->db->prepare($query);
1960 1960
 					$sth->execute();
1961
-				} catch(PDOException $e) {
1961
+				} catch (PDOException $e) {
1962 1962
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1963 1963
 				}
1964 1964
 			}
1965 1965
 		} else {
1966
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1966
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1967 1967
 				$query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL";
1968 1968
 				try {
1969 1969
 					$sth = $Connection->db->prepare($query);
1970 1970
 					$sth->execute();
1971
-				} catch(PDOException $e) {
1971
+				} catch (PDOException $e) {
1972 1972
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1973 1973
 				}
1974 1974
 			}
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 		try {
1978 1978
 			$sth = $Connection->db->prepare($query);
1979 1979
 			$sth->execute();
1980
-		} catch(PDOException $e) {
1980
+		} catch (PDOException $e) {
1981 1981
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1982 1982
 		}
1983 1983
 		return $error;
@@ -1987,12 +1987,12 @@  discard block
 block discarded – undo
1987 1987
 		global $globalDBdriver;
1988 1988
 		$Connection = new Connection();
1989 1989
 		$error = '';
1990
-		if (!$Connection->checkColumnName('source_location','description')) {
1990
+		if (!$Connection->checkColumnName('source_location', 'description')) {
1991 1991
 			$query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL";
1992 1992
 			try {
1993 1993
 				$sth = $Connection->db->prepare($query);
1994 1994
 				$sth->execute();
1995
-			} catch(PDOException $e) {
1995
+			} catch (PDOException $e) {
1996 1996
 				return "error (add column description in source_location) : ".$e->getMessage()."\n";
1997 1997
 			}
1998 1998
 		}
@@ -2000,7 +2000,7 @@  discard block
 block discarded – undo
2000 2000
 		try {
2001 2001
 			$sth = $Connection->db->prepare($query);
2002 2002
 			$sth->execute();
2003
-		} catch(PDOException $e) {
2003
+		} catch (PDOException $e) {
2004 2004
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2005 2005
 		}
2006 2006
 		return $error;
@@ -2010,39 +2010,39 @@  discard block
 block discarded – undo
2010 2010
 		global $globalDBdriver;
2011 2011
 		$Connection = new Connection();
2012 2012
 		$error = '';
2013
-		if (!$Connection->checkColumnName('spotter_live','real_altitude')) {
2013
+		if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) {
2014 2014
 			$query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL";
2015 2015
 			try {
2016 2016
 				$sth = $Connection->db->prepare($query);
2017 2017
 				$sth->execute();
2018
-			} catch(PDOException $e) {
2018
+			} catch (PDOException $e) {
2019 2019
 				return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n";
2020 2020
 			}
2021 2021
 		}
2022
-		if (!$Connection->checkColumnName('spotter_output','real_altitude')) {
2022
+		if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) {
2023 2023
 			$query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL";
2024 2024
 			try {
2025 2025
 				$sth = $Connection->db->prepare($query);
2026 2026
 				$sth->execute();
2027
-			} catch(PDOException $e) {
2027
+			} catch (PDOException $e) {
2028 2028
 				return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n";
2029 2029
 			}
2030 2030
 		}
2031
-		if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) {
2031
+		if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) {
2032 2032
 			$query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL";
2033 2033
 			try {
2034 2034
 				$sth = $Connection->db->prepare($query);
2035 2035
 				$sth->execute();
2036
-			} catch(PDOException $e) {
2036
+			} catch (PDOException $e) {
2037 2037
 				return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n";
2038 2038
 			}
2039 2039
 		}
2040
-		if (!$Connection->checkColumnName('spotter_archive','real_altitude')) {
2040
+		if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) {
2041 2041
 			$query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL";
2042 2042
 			try {
2043 2043
 				$sth = $Connection->db->prepare($query);
2044 2044
 				$sth->execute();
2045
-			} catch(PDOException $e) {
2045
+			} catch (PDOException $e) {
2046 2046
 				return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n";
2047 2047
 			}
2048 2048
 		}
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 		try {
2051 2051
 			$sth = $Connection->db->prepare($query);
2052 2052
 			$sth->execute();
2053
-		} catch(PDOException $e) {
2053
+		} catch (PDOException $e) {
2054 2054
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2055 2055
 		}
2056 2056
 		return $error;
@@ -2072,14 +2072,14 @@  discard block
 block discarded – undo
2072 2072
 		try {
2073 2073
 			$sth = $Connection->db->prepare($query);
2074 2074
 			$sth->execute();
2075
-		} catch(PDOException $e) {
2075
+		} catch (PDOException $e) {
2076 2076
 			return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n";
2077 2077
 		}
2078 2078
 		$query = "UPDATE config SET value = '44' WHERE name = 'schema_version'";
2079 2079
 		try {
2080 2080
 			$sth = $Connection->db->prepare($query);
2081 2081
 			$sth->execute();
2082
-		} catch(PDOException $e) {
2082
+		} catch (PDOException $e) {
2083 2083
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2084 2084
 		}
2085 2085
 		return $error;
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
 		try {
2121 2121
 			$sth = $Connection->db->prepare($query);
2122 2122
 			$sth->execute();
2123
-		} catch(PDOException $e) {
2123
+		} catch (PDOException $e) {
2124 2124
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2125 2125
 		}
2126 2126
 		return $error;
@@ -2143,7 +2143,7 @@  discard block
 block discarded – undo
2143 2143
 		try {
2144 2144
 			$sth = $Connection->db->prepare($query);
2145 2145
 			$sth->execute();
2146
-		} catch(PDOException $e) {
2146
+		} catch (PDOException $e) {
2147 2147
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2148 2148
 		}
2149 2149
 		return $error;
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
 		try {
2194 2194
 			$sth = $Connection->db->prepare($query);
2195 2195
 			$sth->execute();
2196
-		} catch(PDOException $e) {
2196
+		} catch (PDOException $e) {
2197 2197
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2198 2198
 		}
2199 2199
 		return $error;
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 		try {
2217 2217
 			$sth = $Connection->db->prepare($query);
2218 2218
 			$sth->execute();
2219
-		} catch(PDOException $e) {
2219
+		} catch (PDOException $e) {
2220 2220
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2221 2221
 		}
2222 2222
 		return $error;
@@ -2239,7 +2239,7 @@  discard block
 block discarded – undo
2239 2239
 		try {
2240 2240
 			$sth = $Connection->db->prepare($query);
2241 2241
 			$sth->execute();
2242
-		} catch(PDOException $e) {
2242
+		} catch (PDOException $e) {
2243 2243
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2244 2244
 		}
2245 2245
 		return $error;
@@ -2260,7 +2260,7 @@  discard block
 block discarded – undo
2260 2260
 		try {
2261 2261
 			$sth = $Connection->db->prepare($query);
2262 2262
 			$sth->execute();
2263
-		} catch(PDOException $e) {
2263
+		} catch (PDOException $e) {
2264 2264
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2265 2265
 		}
2266 2266
 		return $error;
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
 		try {
2286 2286
 			$sth = $Connection->db->prepare($query);
2287 2287
 			$sth->execute();
2288
-		} catch(PDOException $e) {
2288
+		} catch (PDOException $e) {
2289 2289
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2290 2290
 		}
2291 2291
 		return $error;
@@ -2295,39 +2295,39 @@  discard block
 block discarded – undo
2295 2295
 		global $globalDBdriver;
2296 2296
 		$Connection = new Connection();
2297 2297
 		$error = '';
2298
-		if (!$Connection->checkColumnName('marine_live','captain_name')) {
2298
+		if (!$Connection->checkColumnName('marine_live', 'captain_name')) {
2299 2299
 			$query = "ALTER TABLE marine_live ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL";
2300 2300
 			try {
2301 2301
 				$sth = $Connection->db->prepare($query);
2302 2302
 				$sth->execute();
2303
-			} catch(PDOException $e) {
2303
+			} catch (PDOException $e) {
2304 2304
 				return "error (add columns captain and race in marine_live) : ".$e->getMessage()."\n";
2305 2305
 			}
2306 2306
 		}
2307
-		if (!$Connection->checkColumnName('marine_output','captain_name')) {
2307
+		if (!$Connection->checkColumnName('marine_output', 'captain_name')) {
2308 2308
 			$query = "ALTER TABLE marine_output ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL";
2309 2309
 			try {
2310 2310
 				$sth = $Connection->db->prepare($query);
2311 2311
 				$sth->execute();
2312
-			} catch(PDOException $e) {
2312
+			} catch (PDOException $e) {
2313 2313
 				return "error (add columns captain and race in marine_output) : ".$e->getMessage()."\n";
2314 2314
 			}
2315 2315
 		}
2316
-		if (!$Connection->checkColumnName('marine_archive','captain_name')) {
2316
+		if (!$Connection->checkColumnName('marine_archive', 'captain_name')) {
2317 2317
 			$query = "ALTER TABLE marine_archive ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL";
2318 2318
 			try {
2319 2319
 				$sth = $Connection->db->prepare($query);
2320 2320
 				$sth->execute();
2321
-			} catch(PDOException $e) {
2321
+			} catch (PDOException $e) {
2322 2322
 				return "error (add columns captain and race in marine_archive) : ".$e->getMessage()."\n";
2323 2323
 			}
2324 2324
 		}
2325
-		if (!$Connection->checkColumnName('marine_archive_output','captain_name')) {
2325
+		if (!$Connection->checkColumnName('marine_archive_output', 'captain_name')) {
2326 2326
 			$query = "ALTER TABLE marine_archive_output ADD COLUMN captain_name varchar(255) DEFAULT NULL,ADD COLUMN captain_id varchar(255) DEFAULT NULL,ADD COLUMN race_name varchar(255) DEFAULT NULL,ADD COLUMN race_id varchar(255) DEFAULT NULL";
2327 2327
 			try {
2328 2328
 				$sth = $Connection->db->prepare($query);
2329 2329
 				$sth->execute();
2330
-			} catch(PDOException $e) {
2330
+			} catch (PDOException $e) {
2331 2331
 				return "error (add columns captain and race in marine_archive_output) : ".$e->getMessage()."\n";
2332 2332
 			}
2333 2333
 		}
@@ -2335,7 +2335,7 @@  discard block
 block discarded – undo
2335 2335
 		try {
2336 2336
 			$sth = $Connection->db->prepare($query);
2337 2337
 			$sth->execute();
2338
-		} catch(PDOException $e) {
2338
+		} catch (PDOException $e) {
2339 2339
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2340 2340
 		}
2341 2341
 		return $error;
@@ -2353,14 +2353,14 @@  discard block
 block discarded – undo
2353 2353
 		try {
2354 2354
 			$sth = $Connection->db->prepare($query);
2355 2355
 			$sth->execute();
2356
-		} catch(PDOException $e) {
2356
+		} catch (PDOException $e) {
2357 2357
 			return "error (modify column ground_speede in marine_*) : ".$e->getMessage()."\n";
2358 2358
 		}
2359 2359
 		$query = "UPDATE config SET value = '53' WHERE name = 'schema_version'";
2360 2360
 		try {
2361 2361
 			$sth = $Connection->db->prepare($query);
2362 2362
 			$sth->execute();
2363
-		} catch(PDOException $e) {
2363
+		} catch (PDOException $e) {
2364 2364
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2365 2365
 		}
2366 2366
 		return $error;
@@ -2384,7 +2384,7 @@  discard block
 block discarded – undo
2384 2384
 					try {
2385 2385
 						$sth = $Connection->db->prepare($query);
2386 2386
 						$sth->execute();
2387
-					} catch(PDOException $e) {
2387
+					} catch (PDOException $e) {
2388 2388
 						return "error (check_version): ".$e->getMessage()."\n";
2389 2389
 					}
2390 2390
 					$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.