Completed
Push — master ( 98d6ef...c0dc86 )
by Yannick
30:22
created
airport-geojson.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (isset($_GET['coord'])) 
13 13
 {
14
-	$coords = explode(',',$_GET['coord']);
14
+	$coords = explode(',', $_GET['coord']);
15 15
 	$spotter_array = $Spotter->getAllAirportInfobyCoord($coords);
16 16
 } else {
17 17
 	$spotter_array = $Spotter->getAllAirportInfo();
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
             
23 23
 if (!empty($spotter_array))
24 24
 {	  
25
-	foreach($spotter_array as $spotter_item)
25
+	foreach ($spotter_array as $spotter_item)
26 26
 	{
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30 30
 		    $output .= '"properties": {';
31
-			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32
-			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
31
+			$output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",';
32
+			$output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
34 34
 			$output .= '"altitude": "'.$spotter_item['altitude'].'",';
35
-			$output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",';
35
+			$output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",';
36 36
 			if ($spotter_item['type'] == 'large_airport') {
37 37
 				$output .= '"icon": "'.$globalURL.'/images/airport.png",';
38 38
 			} elseif ($spotter_item['type'] == 'heliport') {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		    $output .= '}';
60 60
 		$output .= '},';
61 61
 	}
62
-	$output  = substr($output, 0, -1);
62
+	$output = substr($output, 0, -1);
63 63
 }
64 64
 $output .= ']}';
65 65
 print $output;
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
72 72
 				}
73 73
 			}
74
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
74
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
75 75
 		}
76 76
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80 80
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81 81
 		if ($filter_query_where != '') {
82
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
82
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
83 83
 		}
84 84
 		$filter_query = $filter_query_join.$filter_query_where;
85 85
 		return $filter_query;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		if ($limit != '')
103 103
 		{
104 104
 			$limit_array = explode(',', $limit);
105
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
105
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
107 107
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108 108
 			{
109 109
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
119 119
 			}
120 120
 		}
121
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
121
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
122 122
 
123 123
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
124 124
 		if ($globalDBdriver == 'mysql') {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		} else {
128 128
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
129 129
 		}
130
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
130
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
131 131
 
132 132
 		return $spotter_array;
133 133
 	}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		global $globalDBdriver, $globalLiveInterval;
144 144
 		date_default_timezone_set('UTC');
145 145
 
146
-		$filter_query = $this->getFilter($filter,true,true);
146
+		$filter_query = $this->getFilter($filter, true, true);
147 147
 
148 148
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
149 149
 		if ($globalDBdriver == 'mysql') {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		try {
158 158
 			$sth = $this->db->prepare($query);
159 159
 			$sth->execute();
160
-		} catch(PDOException $e) {
160
+		} catch (PDOException $e) {
161 161
 			echo $e->getMessage();
162 162
 			die;
163 163
 		}
@@ -177,15 +177,15 @@  discard block
 block discarded – undo
177 177
 		global $globalDBdriver, $globalLiveInterval;
178 178
 		date_default_timezone_set('UTC');
179 179
 
180
-		$filter_query = $this->getFilter($filter,true,true);
180
+		$filter_query = $this->getFilter($filter, true, true);
181 181
 
182 182
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
183 183
 		if ($globalDBdriver == 'mysql') {
184
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
185 185
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
186 186
 			ORDER BY marine_live.fammarine_id, marine_live.date";
187 187
                 } else {
188
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
188
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
189 189
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
190 190
 			ORDER BY marine_live.fammarine_id, marine_live.date";
191 191
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     		try {
194 194
 			$sth = $this->db->prepare($query);
195 195
 			$sth->execute();
196
-		} catch(PDOException $e) {
196
+		} catch (PDOException $e) {
197 197
 			echo $e->getMessage();
198 198
 			die;
199 199
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	public function getLiveMarineCount($filter = array())
211 211
 	{
212 212
 		global $globalDBdriver, $globalLiveInterval;
213
-		$filter_query = $this->getFilter($filter,true,true);
213
+		$filter_query = $this->getFilter($filter, true, true);
214 214
 
215 215
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
216 216
 		if ($globalDBdriver == 'mysql') {
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		try {
222 222
 			$sth = $this->db->prepare($query);
223 223
 			$sth->execute();
224
-		} catch(PDOException $e) {
224
+		} catch (PDOException $e) {
225 225
 			echo $e->getMessage();
226 226
 			die;
227 227
 		}
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 		$filter_query = $this->getFilter($filter);
245 245
 
246 246
 		if (is_array($coord)) {
247
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
247
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
248
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
249
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
250
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
251 251
 		} else return array();
252 252
 		if ($globalDBdriver == 'mysql') {
253 253
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
@@ -272,17 +272,17 @@  discard block
 block discarded – undo
272 272
 		$filter_query = $this->getFilter($filter);
273 273
 
274 274
 		if (is_array($coord)) {
275
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
276
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
275
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
276
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
277
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
278
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
279 279
 		} else return array();
280 280
 		if ($globalDBdriver == 'mysql') {
281 281
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
282 282
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
283 283
 			ORDER BY marine_live.fammarine_id, marine_live.date";
284 284
 		} else {
285
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
285
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
286 286
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong."
287 287
 			ORDER BY marine_live.fammarine_id, marine_live.date";
288 288
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
                 if ($interval == '1m')
332 332
                 {
333 333
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
334
-                } else if ($interval == '15m'){
334
+                } else if ($interval == '15m') {
335 335
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
336 336
                 } 
337 337
             }
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
340 340
         }
341 341
 
342
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
342
+                $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
343 343
                    WHERE marine_live.latitude <> '' 
344 344
                                    AND marine_live.longitude <> '' 
345 345
                    ".$additional_query."
346 346
                    HAVING distance < :radius  
347 347
                                    ORDER BY distance";
348 348
 
349
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
349
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
350 350
 
351 351
                 return $spotter_array;
352 352
         }
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 		date_default_timezone_set('UTC');
365 365
 
366 366
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
367
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
367
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
368 368
 
369
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
369
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
370 370
 
371 371
 		return $spotter_array;
372 372
 	}
@@ -377,16 +377,16 @@  discard block
 block discarded – undo
377 377
 	* @return Array the spotter information
378 378
 	*
379 379
 	*/
380
-	public function getDateLiveMarineDataByIdent($ident,$date)
380
+	public function getDateLiveMarineDataByIdent($ident, $date)
381 381
 	{
382 382
 		$Marine = new Marine($this->db);
383 383
 		date_default_timezone_set('UTC');
384 384
 
385 385
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
386
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
386
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
387 387
 
388
-                $date = date('c',$date);
389
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
388
+                $date = date('c', $date);
389
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
390 390
 
391 391
 		return $spotter_array;
392 392
 	}
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
 		date_default_timezone_set('UTC');
404 404
 
405 405
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
406
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
406
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
407 407
 
408
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
408
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
409 409
 
410 410
 		return $spotter_array;
411 411
 	}
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 	* @return Array the spotter information
417 417
 	*
418 418
 	*/
419
-	public function getDateLiveMarineDataById($id,$date)
419
+	public function getDateLiveMarineDataById($id, $date)
420 420
 	{
421 421
 		$Marine = new Marine($this->db);
422 422
 		date_default_timezone_set('UTC');
423 423
 
424 424
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
425
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
426
-                $date = date('c',$date);
427
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
425
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
426
+                $date = date('c', $date);
427
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
428 428
 
429 429
 		return $spotter_array;
430 430
 	}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	* @return Array the spotter information
437 437
 	*
438 438
 	*/
439
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
439
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
440 440
 	{
441 441
 		global $globalDBdriver, $globalLiveInterval;
442 442
 		date_default_timezone_set('UTC');
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 		try {
456 456
 			$sth = $this->db->prepare($query);
457 457
 			$sth->execute(array(':id' => $id));
458
-		} catch(PDOException $e) {
458
+		} catch (PDOException $e) {
459 459
 			echo $e->getMessage();
460 460
 			die;
461 461
 		}
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 	{
474 474
 		date_default_timezone_set('UTC');
475 475
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
476
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
476
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
477 477
     		try {
478 478
 			
479 479
 			$sth = $this->db->prepare($query);
480 480
 			$sth->execute(array(':ident' => $ident));
481
-		} catch(PDOException $e) {
481
+		} catch (PDOException $e) {
482 482
 			echo $e->getMessage();
483 483
 			die;
484 484
 		}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 			
509 509
 			$sth = $this->db->prepare($query);
510 510
 			$sth->execute();
511
-		} catch(PDOException $e) {
511
+		} catch (PDOException $e) {
512 512
 			return "error";
513 513
 		}
514 514
 
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
 				
532 532
 				$sth = $this->db->prepare($query);
533 533
 				$sth->execute();
534
-			} catch(PDOException $e) {
534
+			} catch (PDOException $e) {
535 535
 				return "error";
536 536
 			}
537 537
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
538 538
                         $i = 0;
539
-                        $j =0;
539
+                        $j = 0;
540 540
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
541
-			foreach($all as $row)
541
+			foreach ($all as $row)
542 542
 			{
543 543
 				$i++;
544 544
 				$j++;
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 					if ($globalDebug) echo ".";
547 547
 				    	try {
548 548
 						
549
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
549
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
550 550
 						$sth->execute();
551
-					} catch(PDOException $e) {
551
+					} catch (PDOException $e) {
552 552
 						return "error";
553 553
 					}
554 554
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 			if ($i > 0) {
560 560
     				try {
561 561
 					
562
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
562
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
563 563
 					$sth->execute();
564
-				} catch(PDOException $e) {
564
+				} catch (PDOException $e) {
565 565
 					return "error";
566 566
 				}
567 567
 			}
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 				
575 575
 				$sth = $this->db->prepare($query);
576 576
 				$sth->execute();
577
-			} catch(PDOException $e) {
577
+			} catch (PDOException $e) {
578 578
 				return "error";
579 579
 			}
580 580
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
 	public function deleteLiveMarineDataByIdent($ident)
623 623
 	{
624 624
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
625
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
625
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
626 626
         
627 627
     		try {
628 628
 			
629 629
 			$sth = $this->db->prepare($query);
630 630
 			$sth->execute(array(':ident' => $ident));
631
-		} catch(PDOException $e) {
631
+		} catch (PDOException $e) {
632 632
 			return "error";
633 633
 		}
634 634
 
@@ -644,13 +644,13 @@  discard block
 block discarded – undo
644 644
 	public function deleteLiveMarineDataById($id)
645 645
 	{
646 646
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
647
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
647
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
648 648
         
649 649
     		try {
650 650
 			
651 651
 			$sth = $this->db->prepare($query);
652 652
 			$sth->execute(array(':id' => $id));
653
-		} catch(PDOException $e) {
653
+		} catch (PDOException $e) {
654 654
 			return "error";
655 655
 		}
656 656
 
@@ -668,13 +668,13 @@  discard block
 block discarded – undo
668 668
 	{
669 669
 		global $globalDBdriver, $globalTimezone;
670 670
 		if ($globalDBdriver == 'mysql') {
671
-			$query  = 'SELECT marine_live.ident FROM marine_live 
671
+			$query = 'SELECT marine_live.ident FROM marine_live 
672 672
 				WHERE marine_live.ident = :ident 
673 673
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
674 674
 				AND marine_live.date < UTC_TIMESTAMP()';
675 675
 			$query_data = array(':ident' => $ident);
676 676
 		} else {
677
-			$query  = "SELECT marine_live.ident FROM marine_live 
677
+			$query = "SELECT marine_live.ident FROM marine_live 
678 678
 				WHERE marine_live.ident = :ident 
679 679
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
680 680
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 		
684 684
 		$sth = $this->db->prepare($query);
685 685
 		$sth->execute($query_data);
686
-		$ident_result='';
687
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
686
+		$ident_result = '';
687
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
688 688
 		{
689 689
 			$ident_result = $row['ident'];
690 690
 		}
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
 	{
702 702
 		global $globalDBdriver, $globalTimezone;
703 703
 		if ($globalDBdriver == 'mysql') {
704
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
704
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
705 705
 				WHERE marine_live.ident = :ident 
706 706
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
707 707
 //				AND marine_live.date < UTC_TIMESTAMP()";
708 708
 			$query_data = array(':ident' => $ident);
709 709
 		} else {
710
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
710
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
711 711
 				WHERE marine_live.ident = :ident 
712 712
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
713 713
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 		
717 717
 		$sth = $this->db->prepare($query);
718 718
 		$sth->execute($query_data);
719
-		$ident_result='';
720
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
719
+		$ident_result = '';
720
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
721 721
 		{
722 722
 			$ident_result = $row['fammarine_id'];
723 723
 		}
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
736 736
 		if ($globalDBdriver == 'mysql') {
737
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
737
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
738 738
 				WHERE marine_live.fammarine_id = :id 
739 739
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
740 740
 //				AND marine_live.date < UTC_TIMESTAMP()";
741 741
 			$query_data = array(':id' => $id);
742 742
 		} else {
743
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
743
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
744 744
 				WHERE marine_live.fammarine_id = :id 
745 745
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
746 746
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-		$ident_result='';
753
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
752
+		$ident_result = '';
753
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['fammarine_id'];
756 756
 		}
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
 	{
768 768
 		global $globalDBdriver, $globalTimezone;
769 769
 		if ($globalDBdriver == 'mysql') {
770
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
770
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
771 771
 				WHERE marine_live.mmsi = :mmsi 
772 772
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
773 773
 //				AND marine_live.date < UTC_TIMESTAMP()";
774 774
 			$query_data = array(':mmsi' => $mmsi);
775 775
 		} else {
776
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
776
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
777 777
 				WHERE marine_live.mmsi = :mmsi 
778 778
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
779 779
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 		
783 783
 		$sth = $this->db->prepare($query);
784 784
 		$sth->execute($query_data);
785
-		$ident_result='';
786
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
785
+		$ident_result = '';
786
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
787 787
 		{
788 788
 			$ident_result = $row['fammarine_id'];
789 789
 		}
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 	* @return String success or false
802 802
 	*
803 803
 	*/
804
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
804
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
805 805
 	{
806 806
 		global $globalURL, $globalArchive, $globalDebug;
807 807
 		$Common = new Common();
@@ -853,26 +853,26 @@  discard block
 block discarded – undo
853 853
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
854 854
 
855 855
         
856
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
857
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
858
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
859
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
860
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
861
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
862
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
863
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
864
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
865
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
866
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
867
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
868
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
869
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
870
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
871
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
856
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
857
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
858
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
859
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
860
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
861
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
862
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
863
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
864
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
865
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
866
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
867
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
868
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
869
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
870
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
871
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
872 872
 		
873 873
 
874
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
875
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
874
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
875
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
876 876
             	if ($arrival_date == '') $arrival_date = NULL;
877 877
             	$query = '';
878 878
 		if ($globalArchive) {
@@ -882,18 +882,18 @@  discard block
 block discarded – undo
882 882
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
883 883
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
884 884
 
885
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
885
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
886 886
 		try {
887 887
 			$sth = $this->db->prepare($query);
888 888
 			$sth->execute($query_values);
889
-		} catch(PDOException $e) {
889
+		} catch (PDOException $e) {
890 890
 			return "error : ".$e->getMessage();
891 891
 		}
892 892
 		
893 893
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
894 894
 			if ($globalDebug) echo '(Add to Marine archive : ';
895 895
 			$MarineArchive = new MarineArchive($this->db);
896
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);
896
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country);
897 897
 			if ($globalDebug) echo $result.')';
898 898
 		}
899 899
 		return "success";
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 
902 902
 	public function getOrderBy()
903 903
 	{
904
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
904
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
905 905
 		return $orderby;
906 906
 	}
907 907
 
Please login to merge, or discard this patch.
require/class.AIS.php 1 patch
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
 
30 30
 	private function make_latf($temp) { // unsigned long 
31 31
 		$flat = 0.0; // float
32
-		$temp = $temp & 0x07FFFFFF;
33
-		if ($temp & 0x04000000) {
34
-			$temp = $temp ^ 0x07FFFFFF;
32
+		$temp = $temp&0x07FFFFFF;
33
+		if ($temp&0x04000000) {
34
+			$temp = $temp^0x07FFFFFF;
35 35
 			$temp += 1;
36
-			$flat = (float)($temp / (60.0 * 10000.0));
36
+			$flat = (float) ($temp/(60.0*10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else $flat = (float) ($temp/(60.0*10000.0));
39 39
 		return $flat; // float
40 40
 	}
41 41
 
42 42
 	private function make_lonf($temp) { // unsigned long
43 43
 		$flon = 0.0; // float
44
-		$temp = $temp & 0x0FFFFFFF;
45
-		if ($temp & 0x08000000) {
46
-			$temp = $temp ^ 0x0FFFFFFF;
44
+		$temp = $temp&0x0FFFFFFF;
45
+		if ($temp&0x08000000) {
46
+			$temp = $temp^0x0FFFFFFF;
47 47
 			$temp += 1;
48
-			$flon = (float)($temp / (60.0 * 10000.0));
48
+			$flon = (float) ($temp/(60.0*10000.0));
49 49
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
50
+		} else $flon = (float) ($temp/(60.0*10000.0));
51 51
 		return $flon;
52 52
 	}
53 53
 
54 54
 	private function ascii_2_dec($chr) {
55
-		$dec=ord($chr);//get decimal ascii code
56
-		$hex=dechex($dec);//convert decimal to hex
55
+		$dec = ord($chr); //get decimal ascii code
56
+		$hex = dechex($dec); //convert decimal to hex
57 57
 		return ($dec);
58 58
 	}
59 59
 	
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 		//only process in the following range: 48-87, 96-119
73 73
 		if ($ascii < 48) { }
74 74
 		else {
75
-			if($ascii>119) { }
75
+			if ($ascii > 119) { }
76 76
 			else {
77
-				if ($ascii>87 && $ascii<96) ;
77
+				if ($ascii > 87 && $ascii < 96);
78 78
 				else {
79
-					$ascii=$ascii+40;
80
-					if ($ascii>128){
81
-						$ascii=$ascii+32;
79
+					$ascii = $ascii + 40;
80
+					if ($ascii > 128) {
81
+						$ascii = $ascii + 32;
82 82
 					} else {
83
-						$ascii=$ascii+40;
83
+						$ascii = $ascii + 40;
84 84
 					}
85 85
 				}
86 86
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	}
90 90
 
91 91
 	private function dec_2_6bit($dec) {
92
-		$bin=decbin($dec);
92
+		$bin = decbin($dec);
93 93
 		return(substr($bin, -6)); 
94 94
 	}
95 95
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 		);
108 108
 		// "
109 109
 		$rv = '';
110
-		if ($_size % 6 == 0) {
111
-			$len = $_size / 6;
112
-			for ($i=0; $i<$len; $i++) {
113
-				$offset = $i * 6;
114
-				$rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ];
110
+		if ($_size%6 == 0) {
111
+			$len = $_size/6;
112
+			for ($i = 0; $i < $len; $i++) {
113
+				$offset = $i*6;
114
+				$rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))];
115 115
 			}
116 116
 		}
117 117
 		return $rv;
@@ -138,93 +138,93 @@  discard block
 block discarded – undo
138 138
 		$ro->eta_hour = '';
139 139
 		$ro->eta_minute = '';
140 140
 		$ro->ts = time();
141
-		$ro->id = bindec(substr($_aisdata,0,6));
142
-		$ro->mmsi = bindec(substr($_aisdata,8,30));
141
+		$ro->id = bindec(substr($_aisdata, 0, 6));
142
+		$ro->mmsi = bindec(substr($_aisdata, 8, 30));
143 143
 		if ($ro->id >= 1 && $ro->id <= 3) {
144
-			$ro->cog = bindec(substr($_aisdata,116,12))/10;
145
-			$ro->sog = bindec(substr($_aisdata,50,10))/10;
146
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
147
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
144
+			$ro->cog = bindec(substr($_aisdata, 116, 12))/10;
145
+			$ro->sog = bindec(substr($_aisdata, 50, 10))/10;
146
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
147
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
148 148
 			$ro->cls = 1; // class A
149 149
 		} else if ($ro->id == 4) {
150
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28)));
151
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27)));
150
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28)));
151
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27)));
152 152
 			$ro->cls = 1; // class A
153 153
 		} else if ($ro->id == 5) {
154
-			$ro->imo = bindec(substr($_aisdata,40,30));
155
-			$ro->callsign = $this->binchar($_aisdata,70,42);
156
-			$ro->name = $this->binchar($_aisdata,112,120);
157
-			$ro->typeid = bindec(substr($_aisdata,232,8));
154
+			$ro->imo = bindec(substr($_aisdata, 40, 30));
155
+			$ro->callsign = $this->binchar($_aisdata, 70, 42);
156
+			$ro->name = $this->binchar($_aisdata, 112, 120);
157
+			$ro->typeid = bindec(substr($_aisdata, 232, 8));
158 158
 			$ro->type = $this->getShipType($ro->typeid);
159 159
 			//$ro->to_bow = bindec(substr($_aisdata,240,9));
160 160
 			//$ro->to_stern = bindec(substr($_aisdata,249,9));
161 161
 			//$ro->to_port = bindec(substr($_aisdata,258,6));
162 162
 			//$ro->to_starboard = bindec(substr($_aisdata,264,6));
163
-			$ro->eta_month = bindec(substr($_aisdata,274,4));
164
-			$ro->eta_day = bindec(substr($_aisdata,278,5));
165
-			$ro->eta_hour = bindec(substr($_aisdata,283,5));
166
-			$ro->eta_minute = bindec(substr($_aisdata,288,6));
163
+			$ro->eta_month = bindec(substr($_aisdata, 274, 4));
164
+			$ro->eta_day = bindec(substr($_aisdata, 278, 5));
165
+			$ro->eta_hour = bindec(substr($_aisdata, 283, 5));
166
+			$ro->eta_minute = bindec(substr($_aisdata, 288, 6));
167 167
 			//$ro->draught = bindec(substr($_aisdata,294,8));
168
-			$ro->destination = $this->binchar($_aisdata,302,120);
168
+			$ro->destination = $this->binchar($_aisdata, 302, 120);
169 169
 			$ro->cls = 1; // class A
170 170
 		} else if ($ro->id == 9) {
171 171
 			// Search and Rescue aircraft position report
172 172
 		} else if ($ro->id == 18) {
173
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
174
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
175
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177
-			$ro->heading = bindec(substr($_aisdata,124,9));
173
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
174
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
175
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28)));
176
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27)));
177
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
178 178
 			if ($ro->heading == 511) $ro->heading = '';
179 179
 			$ro->cls = 2; // class B
180 180
 		} else if ($ro->id == 19) {
181
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
182
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
183
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
184
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
185
-			$ro->name = $this->binchar($_aisdata,143,120);
181
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
182
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
183
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
184
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
185
+			$ro->name = $this->binchar($_aisdata, 143, 120);
186 186
 			$ro->cls = 2; // class B
187
-			$ro->heading = bindec(substr($_aisdata,124,9));
187
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
188 188
 			if ($ro->heading == 511) $ro->heading = '';
189
-			$ro->typeid = bindec(substr($_aisdata,263,8));
189
+			$ro->typeid = bindec(substr($_aisdata, 263, 8));
190 190
 			$ro->type = $this->getShipType($ro->typeid);
191 191
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
192 192
 			//$ro->to_stern = bindec(substr($_aisdata,280,9));
193 193
 			//$ro->to_port = bindec(substr($_aisdata,289,6));
194 194
 			//$ro->to_starboard = bindec(substr($_aisdata,295,6));
195 195
 		} else if ($ro->id == 21) {
196
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28)));
197
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27)));
198
-			$ro->name = $this->binchar($_aisdata,43,120);
196
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28)));
197
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27)));
198
+			$ro->name = $this->binchar($_aisdata, 43, 120);
199 199
 			//$ro->to_bow = bindec(substr($_aisdata,219,9));
200 200
 			//$ro->to_stern = bindec(substr($_aisdata,228,9));
201 201
 			//$ro->to_port = bindec(substr($_aisdata,237,6));
202 202
 			//$ro->to_starboard = bindec(substr($_aisdata,243,6));
203 203
 			$ro->cls = 2; // class B
204 204
 		} else if ($ro->id == 24) {
205
-			$pn = bindec(substr($_aisdata,38,2));
205
+			$pn = bindec(substr($_aisdata, 38, 2));
206 206
 			if ($pn == 0) {
207
-				$ro->name = $this->binchar($_aisdata,40,120);
207
+				$ro->name = $this->binchar($_aisdata, 40, 120);
208 208
 			}
209
-			$ro->typeid = bindec(substr($_aisdata,40,8));
209
+			$ro->typeid = bindec(substr($_aisdata, 40, 8));
210 210
 			$ro->type = $this->getShipType($ro->typeid);
211
-			$ro->callsign = $this->binchar($_aisdata,90,42);
211
+			$ro->callsign = $this->binchar($_aisdata, 90, 42);
212 212
 			//$ro->to_bow = bindec(substr($_aisdata,132,9));
213 213
 			//$ro->to_stern = bindec(substr($_aisdata,141,9));
214 214
 			//$ro->to_port = bindec(substr($_aisdata,150,6));
215 215
 			//$ro->to_starboard = bindec(substr($_aisdata,156,6));
216 216
 			$ro->cls = 2; // class B
217 217
 		} else if ($ro->id == 27) {
218
-			$ro->cog = bindec(substr($_aisdata,85,9));
218
+			$ro->cog = bindec(substr($_aisdata, 85, 9));
219 219
 			if ($ro->cog == 511) $ro->cog = 0.0;
220
-			$ro->sog = bindec(substr($_aisdata,79,6));
220
+			$ro->sog = bindec(substr($_aisdata, 79, 6));
221 221
 			if ($ro->sog == 63) $ro->sog = 0.0;
222
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
222
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10);
223
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10);
224 224
 			$ro->cls = 1; // class A
225 225
 		
226 226
 		}
227
-		$ro->statusid = bindec(substr($_aisdata,38,4));
227
+		$ro->statusid = bindec(substr($_aisdata, 38, 4));
228 228
 		$ro->status = $this->getStatus($ro->statusid);
229 229
 		//var_dump($ro); // dump results here for demo purpose
230 230
 		return $ro;
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 		global $port; // tcpip port...
356 356
 		
357 357
 		static $debug_counter = 0;
358
-		$aisdata168='';//six bit array of ascii characters
358
+		$aisdata168 = ''; //six bit array of ascii characters
359 359
 		$ais_nmea_array = str_split($_itu); // convert to an array
360 360
 		foreach ($ais_nmea_array as $value) {
361 361
 			$dec = $this->ascii_2_dec($value);
362 362
 			$bit8 = $this->asciidec_2_8bit($dec);
363 363
 			$bit6 = $this->dec_2_6bit($bit8);
364 364
 			//echo $value ."-" .$bit6 ."";
365
-			$aisdata168 .=$bit6;
365
+			$aisdata168 .= $bit6;
366 366
 		}
367 367
 		//echo $aisdata168 . "<br/>";
368 368
 		//return $this->decode_ais($aisdata168, $aux);
@@ -385,20 +385,20 @@  discard block
 block discarded – undo
385 385
 		// calculate checksum after ! till *
386 386
 		// assume 1st ! is valid
387 387
 		// find * ensure that it is at correct position
388
-		$end = strrpos ( $rawdata , '*' );
388
+		$end = strrpos($rawdata, '*');
389 389
 		if ($end === FALSE) return -1; // check for NULLS!!!
390
-		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
392
-		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
394
-		if ( $chksum == $dcs ) { // NMEA checksum pass
390
+		$cs = substr($rawdata, $end + 1);
391
+		if (strlen($cs) != 2) return -1; // correct cs length
392
+		$dcs = (int) hexdec($cs);
393
+		for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum
394
+		if ($chksum == $dcs) { // NMEA checksum pass
395 395
 			$pcs = explode(',', $rawdata);
396 396
 			// !AI??? identifier
397
-			$num_seq = (int)$pcs[1]; // number of sequences
398
-			$seq = (int)$pcs[2]; // get sequence
397
+			$num_seq = (int) $pcs[1]; // number of sequences
398
+			$seq = (int) $pcs[2]; // get sequence
399 399
 			// get msg sequence id
400 400
 			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
401
-			else $msg_sid = (int)$pcs[3]; // multipart message
401
+			else $msg_sid = (int) $pcs[3]; // multipart message
402 402
 			$ais_ch = $pcs[4]; // get AIS channel
403 403
 			// message sequence checking
404 404
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 					}
432 432
 				}
433 433
 				$itu = $itu.$pcs[5]; // get itu message
434
-				$filler += (int)$pcs[6][0]; // get filler
434
+				$filler += (int) $pcs[6][0]; // get filler
435 435
 				if ($num_seq == 1 // valid single message
436 436
 				    || $num_seq == $pseq // valid multi-part message
437 437
 				) {
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
 		$cbuf = $cbuf.$ibuf;
452 452
 		$last_pos = 0;
453 453
 		$result = new stdClass();
454
-		while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) {
454
+		while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) {
455 455
 		//while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) {
456 456
 			//DEBUG echo $cbuf;
457
-			if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim?
457
+			if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim?
458 458
 				$tst = substr($cbuf, $start - 3, ($end - $start + 3));
459 459
 				//DEBUG echo "[$start $end $tst]\n";
460
-				$result = $this->process_ais_raw( $tst, "" );
460
+				$result = $this->process_ais_raw($tst, "");
461 461
 				$last_pos = $end + 1;
462 462
 			} else break;
463 463
 		}
@@ -469,41 +469,41 @@  discard block
 block discarded – undo
469 469
 	// incoming data from serial or IP comms
470 470
 	public function process_ais_line($cbuf) {
471 471
 		$result = new stdClass();
472
-		$start = strpos($cbuf,"VDM");
472
+		$start = strpos($cbuf, "VDM");
473 473
 		$tst = substr($cbuf, $start - 3);
474
-		$result = $this->process_ais_raw( $tst, "" );
474
+		$result = $this->process_ais_raw($tst, "");
475 475
 		return $result;
476 476
 	}
477 477
 
478 478
 	/* AIS Encoding
479 479
 	*/
480
-	private function mk_ais_lat( $lat ) {
480
+	private function mk_ais_lat($lat) {
481 481
 		//$lat = 1.2569;
482
-		if ($lat<0.0) {
482
+		if ($lat < 0.0) {
483 483
 			$lat = -$lat;
484
-			$neg=true;
485
-		} else $neg=false;
484
+			$neg = true;
485
+		} else $neg = false;
486 486
 		$latd = 0x00000000;
487
-		$latd = intval ($lat * 600000.0);
488
-		if ($neg==true) {
487
+		$latd = intval($lat*600000.0);
488
+		if ($neg == true) {
489 489
 			$latd = ~$latd;
490
-			$latd+=1;
490
+			$latd += 1;
491 491
 			$latd &= 0x07FFFFFF;
492 492
 		}
493 493
 		return $latd;
494 494
 	}
495 495
 
496
-	private function mk_ais_lon( $lon ) {
496
+	private function mk_ais_lon($lon) {
497 497
 		//$lon = 103.851;
498
-		if ($lon<0.0) {
498
+		if ($lon < 0.0) {
499 499
 			$lon = -$lon;
500
-			$neg=true;
501
-		} else $neg=false;
500
+			$neg = true;
501
+		} else $neg = false;
502 502
 		$lond = 0x00000000;
503
-		$lond = intval ($lon * 600000.0);
504
-		if ($neg==true) {
503
+		$lond = intval($lon*600000.0);
504
+		if ($neg == true) {
505 505
 			$lond = ~$lond;
506
-			$lond+=1;
506
+			$lond += 1;
507 507
 			$lond &= 0x0FFFFFFF;
508 508
 		}
509 509
 		return $lond;
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 
512 512
 	private function char2bin($name, $max_len) {
513 513
 		$len = strlen($name);
514
-		if ($len > $max_len) $name = substr($name,0,$max_len);
515
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
514
+		if ($len > $max_len) $name = substr($name, 0, $max_len);
515
+		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6);
516 516
 		else $pad = '';
517 517
 		$rv = '';
518 518
 		$ais_chars = array(
@@ -529,26 +529,26 @@  discard block
 block discarded – undo
529 529
 		if ($_a) foreach ($_a as $_1) {
530 530
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
531 531
 			else $dec = 0;
532
-			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
532
+			$bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT);
533 533
 			$rv .= $bin;
534 534
 			//echo "$_1 $dec ($bin)<br/>";
535 535
 		}
536 536
 		return $rv.$pad;
537 537
 	}
538 538
 
539
-	private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') {
539
+	private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') {
540 540
 		$len_bit = strlen($_enc);
541
-		$rem6 = $len_bit % 6;
541
+		$rem6 = $len_bit%6;
542 542
 		$pad6_len = 0;
543 543
 		if ($rem6) $pad6_len = 6 - $rem6;
544 544
 		//echo  $pad6_len.'<br>';
545 545
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
546
-		$len_enc = strlen($_enc) / 6;
546
+		$len_enc = strlen($_enc)/6;
547 547
 		//echo $_enc.' '.$len_enc.'<br/>';
548 548
 		$itu = '';
549
-		for ($i=0; $i<$len_enc; $i++) {
550
-			$offset = $i * 6;
551
-			$dec = bindec(substr($_enc,$offset,6));
549
+		for ($i = 0; $i < $len_enc; $i++) {
550
+			$offset = $i*6;
551
+			$dec = bindec(substr($_enc, $offset, 6));
552 552
 			if ($dec < 40) $dec += 48;
553 553
 			else $dec += 56;
554 554
 			//echo chr($dec)." $dec<br/>";
@@ -558,15 +558,15 @@  discard block
 block discarded – undo
558 558
 		$chksum = 0;
559 559
 		$itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0";
560 560
 		$len_itu = strlen($itu);
561
-		for ($i=0; $i<$len_itu; $i++) {
562
-			$chksum ^= ord( $itu[$i] );
561
+		for ($i = 0; $i < $len_itu; $i++) {
562
+			$chksum ^= ord($itu[$i]);
563 563
 		}
564
-		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
565
-		$lsb = $chksum & 0x0F;
566
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
564
+		$hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
565
+		$lsb = $chksum&0x0F;
566
+		if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb];
567 567
 		else $lsbc = '0';
568
-		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
569
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
568
+		$msb = (($chksum&0xF0) >> 4)&0x0F;
569
+		if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb];
570 570
 		else $msbc = '0';
571 571
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
572 572
 		return $itu;
@@ -591,14 +591,14 @@  discard block
 block discarded – undo
591 591
 
592 592
 	public function mmsitype($mmsi) {
593 593
 		if (strlen($mmsi) == 9) {
594
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
595
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
596
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
597
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
598
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
599
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
600
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
601
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
594
+			if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
595
+			elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device';
596
+			elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
597
+			elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft';
598
+			elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship';
599
+			elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation';
600
+			elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations';
601
+			elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships';
602 602
 			else return 'Ship';
603 603
 		}
604 604
 
@@ -609,19 +609,19 @@  discard block
 block discarded – undo
609 609
 		global $globalDebug;
610 610
 		$result = array();
611 611
 		$data = new stdClass();
612
-		$start = strpos($buffer,"VDM");
612
+		$start = strpos($buffer, "VDM");
613 613
 		$tst = substr($buffer, $start - 3);
614
-		$data = $this->process_ais_raw( $tst, "" );
614
+		$data = $this->process_ais_raw($tst, "");
615 615
 		if (!is_object($data)) {
616 616
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
617 617
 			return array();
618 618
 		}
619 619
 		if ($data->lon != 0) $result['longitude'] = $data->lon;
620 620
 		if ($data->lat != 0) $result['latitude'] = $data->lat;
621
-		$result['ident'] = trim(str_replace('@','',$data->name));
621
+		$result['ident'] = trim(str_replace('@', '', $data->name));
622 622
 		$result['timestamp'] = $data->ts;
623 623
 		$result['mmsi'] = $data->mmsi;
624
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
624
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
625 625
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
626 626
 		if ($data->sog != -1.0) $result['speed'] = $data->sog;
627 627
 		if ($data->heading !== '') $result['heading'] = $data->heading;
@@ -631,16 +631,16 @@  discard block
 block discarded – undo
631 631
 		if ($data->type !== '') $result['type'] = $data->type;
632 632
 		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
633 633
 		if ($data->imo !== '') $result['imo'] = $data->imo;
634
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
634
+		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign));
635 635
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
636
-			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
636
+			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
637 637
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
638 638
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
639
-			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
639
+			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
640 640
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
641 641
 		}
642 642
 		if ($data->destination != '') {
643
-			$dest = trim(str_replace('@','',$data->destination));
643
+			$dest = trim(str_replace('@', '', $data->destination));
644 644
 			if ($dest != '') $result['destination'] = $dest;
645 645
 		}
646 646
 		$result['all'] = (array) $data;
Please login to merge, or discard this patch.
ident.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $ident = '';
4
-if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
5
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
4
+if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST, 'ident', FILTER_SANITIZE_STRING);
5
+if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
6 6
 if ($ident != '')
7 7
 {
8 8
 	if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident);
Please login to merge, or discard this patch.
currently.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,21 +4,21 @@  discard block
 block discarded – undo
4 4
 
5 5
 $type = '';
6 6
 if (isset($_GET['marine'])) {
7
-	require_once('require/class.Marine.php');;
7
+	require_once('require/class.Marine.php'); ;
8 8
 	require_once('require/class.MarineLive.php');
9
-	$MarineLive=new MarineLive();
9
+	$MarineLive = new MarineLive();
10 10
 	$type = 'marine';
11 11
 	$page_url = $globalURL.'/marine/currently';
12 12
 } elseif (isset($_GET['tracker'])) {
13
-	require_once('require/class.Tracker.php');;
13
+	require_once('require/class.Tracker.php'); ;
14 14
 	require_once('require/class.TrackerLive.php');
15
-	$TrackerLive=new TrackerLive();
15
+	$TrackerLive = new TrackerLive();
16 16
 	$type = 'tracker';
17 17
 	$page_url = $globalURL.'/tracker/currently';
18 18
 } else {
19
-	require_once('require/class.Spotter.php');;
19
+	require_once('require/class.Spotter.php'); ;
20 20
 	require_once('require/class.SpotterLive.php');
21
-	$SpotterLive=new SpotterLive();
21
+	$SpotterLive = new SpotterLive();
22 22
 	$type = 'aircraft';
23 23
 	$page_url = $globalURL.'/currently';
24 24
 }
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 $title = "Current Activity";
27 27
 require_once('header.php');
28 28
 //calculuation for the pagination
29
-if(!isset($_GET['limit']))
29
+if (!isset($_GET['limit']))
30 30
 {
31 31
 	$limit_start = 0;
32 32
 	$limit_end = 25;
33 33
 	$absolute_difference = 25;
34
-}  else {
34
+} else {
35 35
 	$limit_explode = explode(",", $_GET['limit']);
36 36
 	$limit_start = $limit_explode[0];
37 37
 	$limit_end = $limit_explode[1];
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
55 55
 elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
56 56
 
57
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
57
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
58 58
 if ($sort != '') {
59 59
 	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
60 60
 	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
Please login to merge, or discard this patch.
date.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 $type = 'aircraft';
4 4
 if (isset($_GET['marine'])) $type = 'marine';
5 5
 elseif (isset($_GET['tracker'])) $type = 'tracker';
6
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
6
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
7 7
 if ($date == '') $date = date('Y-m-d');
8 8
 if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date);
9 9
 elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date);
Please login to merge, or discard this patch.
date-detailed.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,34 +2,34 @@  discard block
 block discarded – undo
2 2
 require_once('require/class.Connection.php');
3 3
 require_once('require/class.Language.php');
4 4
 $type = '';
5
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
5
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
6 6
 if (isset($_GET['marine'])) {
7
-	require_once('require/class.Marine.php');;
7
+	require_once('require/class.Marine.php'); ;
8 8
 	$Marine = new Marine();
9 9
 	$type = 'marine';
10 10
 	$page_url = $globalURL.'/marine/date/'.$date;
11 11
 } elseif (isset($_GET['tracker'])) {
12
-	require_once('require/class.Tracker.php');;
12
+	require_once('require/class.Tracker.php'); ;
13 13
 	$Tracker = new Tracker();
14 14
 	$type = 'tracker';
15 15
 	$page_url = $globalURL.'/tracker/date/'.$date;
16 16
 } else {
17
-	require_once('require/class.Spotter.php');;
17
+	require_once('require/class.Spotter.php'); ;
18 18
 	$Spotter = new Spotter();
19 19
 	$type = 'aircraft';
20 20
 	$page_url = $globalURL.'/date/'.$date;
21 21
 }
22 22
 
23
-if (!isset($_GET['date'])){
23
+if (!isset($_GET['date'])) {
24 24
 	header('Location: '.$globalURL.'');
25 25
 } else {
26 26
 	//calculuation for the pagination
27
-	if(!isset($_GET['limit']))
27
+	if (!isset($_GET['limit']))
28 28
 	{
29 29
 		$limit_start = 0;
30 30
 		$limit_end = 25;
31 31
 		$absolute_difference = 25;
32
-	}  else {
32
+	} else {
33 33
 		$limit_explode = explode(",", $_GET['limit']);
34 34
 		$limit_start = $limit_explode[0];
35 35
 		$limit_end = $limit_explode[1];
@@ -43,24 +43,24 @@  discard block
 block discarded – undo
43 43
 	$limit_previous_1 = $limit_start - $absolute_difference;
44 44
 	$limit_previous_2 = $limit_end - $absolute_difference;
45 45
 	
46
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
46
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
47 47
 	if ($sort != '') 
48 48
 	{
49
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
50
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
49
+		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference, $sort);
50
+		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference, $sort);
51
+		else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference, $sort);
52 52
 	} else {
53
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
54
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
55
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
53
+		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference);
54
+		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference);
55
+		else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference);
56 56
 	}
57 57
 	
58 58
 	if (!empty($spotter_array))
59 59
 	{
60 60
 		date_default_timezone_set($globalTimezone);
61
-		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
-		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
-		else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
61
+		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
+		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
+		else $title = sprintf(_("Detailed View for flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
64 64
 
65 65
 		require_once('header.php');
66 66
 		print '<div class="select-item">';
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 		print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
79 79
 		print '<br />';
80 80
 		print '<div class="info column">';
81
-		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
-		else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
81
+		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
+		else print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
83 83
 		print '</div>';
84 84
 
85 85
 		if ($type == 'aircraft') include('date-sub-menu.php');
86 86
 		print '<div class="table column">';
87
-		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
-		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
87
+		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
+		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
+		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
90 90
  
91 91
 		include('table-output.php');
92 92
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
latest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
 require_once('header.php');
24 24
 
25 25
 //calculuation for the pagination
26
-if(!isset($_GET['limit']))
26
+if (!isset($_GET['limit']))
27 27
 {
28 28
 	$limit_start = 0;
29 29
 	$limit_end = 25;
30 30
 	$absolute_difference = 25;
31
-}  else {
31
+} else {
32 32
 	$limit_explode = explode(",", $_GET['limit']);
33 33
 	$limit_start = $limit_explode[0];
34 34
 	$limit_end = $limit_explode[1];
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
52 52
 else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
53 53
 
54
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
54
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
55 55
 $sql_begin = microtime(true);
56 56
 if ($type == 'marine') {
57 57
 	$spotter_array = $Marine->getLatestMarineData($limit_start.",".$absolute_difference, $sort);
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 } else {
61 61
 	$spotter_array = $Spotter->getLatestSpotterData($limit_start.",".$absolute_difference, $sort);
62 62
 }
63
-$sql_time = microtime(true)-$sql_begin;
63
+$sql_time = microtime(true) - $sql_begin;
64 64
 $page_begin = microtime(true);
65 65
 if (!empty($spotter_array))
66 66
 {
@@ -77,6 +77,6 @@  discard block
 block discarded – undo
77 77
 	print '</div>';
78 78
 	print '</div>';
79 79
 }
80
-$page_time = microtime(true)-$page_begin;
80
+$page_time = microtime(true) - $page_begin;
81 81
 require_once('footer.php');
82 82
 ?>
83 83
\ No newline at end of file
Please login to merge, or discard this patch.
header.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,31 +8,31 @@  discard block
 block discarded – undo
8 8
 if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9 9
 else $MapType = $globalMapProvider;
10 10
 if (isset($_GET['3d'])) {
11
-	setcookie('MapFormat','3d');
11
+	setcookie('MapFormat', '3d');
12 12
 } else if (isset($_GET['2d'])) {
13
-	setcookie('MapFormat','2d');
13
+	setcookie('MapFormat', '2d');
14 14
 }
15 15
 
16 16
 if (isset($_POST['archive'])) {
17
-	setcookie('archive','true');
18
-	setcookie('archive_begin',strtotime($_POST['start_date']));
19
-	setcookie('archive_end',strtotime($_POST['end_date']));
20
-	setcookie('archive_speed',$_POST['archivespeed']);
17
+	setcookie('archive', 'true');
18
+	setcookie('archive_begin', strtotime($_POST['start_date']));
19
+	setcookie('archive_end', strtotime($_POST['end_date']));
20
+	setcookie('archive_speed', $_POST['archivespeed']);
21 21
 }
22 22
 if (isset($_POST['noarchive'])) {
23
-	setcookie('archive','false',-1);
24
-	setcookie('archive_begin','',-1);
25
-	setcookie('archive_end','',-1);
26
-	setcookie('archive_speed','',-1);
23
+	setcookie('archive', 'false', -1);
24
+	setcookie('archive_begin', '', -1);
25
+	setcookie('archive_end', '', -1);
26
+	setcookie('archive_speed', '', -1);
27 27
 }
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30
-	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
30
+	$allfilters = array_filter(array_keys($_COOKIE), function($key) {
31
+	    return strpos($key, 'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
35
-		setcookie($filt,null,-1);
35
+		setcookie($filt, null, -1);
36 36
 	}
37 37
 }
38 38
 ?>
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
241 241
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
242 242
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
243
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
243
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
244 244
 <?php
245 245
 		if (!isset($type) || $type == 'aircraft') {
246 246
 ?>
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
311 311
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
312 312
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
313
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
313
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
314 314
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
315 315
 <?php
316 316
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 ?>
590 590
       <div class="search">
591 591
       <form action="<?php print $globalURL; ?>/search" method="get">
592
-		<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
592
+		<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
593 593
 	</form>
594 594
 	</div>
595 595
   	<div class="social">
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	print '</div>';
608 608
 }
609 609
 
610
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
610
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
611 611
 ?>
612 612
     <div class="top-header clear" role="main">
613 613
 <?php
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
     </div>
621 621
 <?php
622 622
 }
623
-if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
623
+if ((strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) || (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false))
624 624
 {
625 625
     ?>
626 626
     <div class="top-header clear" role="main">
@@ -633,15 +633,15 @@  discard block
 block discarded – undo
633 633
         var zoom = 13;
634 634
 //create the map
635 635
 <?php
636
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
636
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
637 637
 ?>
638 638
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
639 639
 <?php
640
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
640
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
641 641
 ?>
642 642
   map = L.map('map', { zoomControl:true });
643 643
 <?php
644
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
644
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
645 645
 ?>
646 646
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
647 647
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
650 650
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
651 651
 <?php
652
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
652
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
653 653
 ?>
654 654
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
655 655
 <?php
Please login to merge, or discard this patch.