Completed
Push — master ( 6f7c12...384f31 )
by Yannick
07:57
created
js/map-aircraft.3d.js.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -662,9 +662,9 @@
 block discarded – undo
662 662
 //	var timeline = new Cesium.Timeline(viewer);
663 663
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
664 664
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
665
-	//this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
666
-	$(".archivebox").html('<h4><?php echo str_replace("'","\'",_("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
667
-	//		this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
665
+	//this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
666
+	$(".archivebox").html('<h4><?php echo str_replace("'", "\'", _("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
667
+	//		this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
668 668
 
669 669
 }
670 670
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -4 removed lines patch added patch discarded remove patch
@@ -156,7 +156,12 @@  discard block
 block discarded – undo
156 156
 //				viewer.dataSources.get(dsn).entities.remove(entity);
157 157
 //			}
158 158
 			//console.log(entity.lastupdate);
159
-			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
159
+			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
160
+	print $globalMapRefresh*2000;
161
+} else {
162
+	print '60000';
163
+}
164
+?>)) {
160 165
 //				console.log('Remove an entity date');
161 166
 				viewer.dataSources.get(dsn).entities.remove(entity);
162 167
 			} else {
@@ -230,7 +235,12 @@  discard block
 block discarded – undo
230 235
 	} else {
231 236
 		for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) {
232 237
 			var entity = viewer.dataSources.get(dsn).entities.values[i];
233
-			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
238
+			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
239
+	print $globalMapRefresh*2000;
240
+} else {
241
+	print '60000';
242
+}
243
+?>)) {
234 244
 				viewer.dataSources.get(dsn).entities.remove(entity);
235 245
 			}
236 246
 		}
@@ -560,7 +570,12 @@  discard block
 block discarded – undo
560 570
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
561 571
 ?>
562 572
 update_polarLayer();
563
-setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
573
+setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) {
574
+	print $globalMapRefresh*1000*2;
575
+} else {
576
+	print '60000';
577
+}
578
+?>);
564 579
 <?php
565 580
 		}
566 581
 ?>
@@ -656,7 +671,12 @@  discard block
 block discarded – undo
656 671
 				}
657 672
 			}
658 673
 		}
659
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
674
+	,<?php if (isset($globalMapRefresh)) {
675
+	print $globalMapRefresh*1000;
676
+} else {
677
+	print '30000';
678
+}
679
+?>);
660 680
 } else {
661 681
 	//var widget = new Cesium.CesiumWidget('archivebox');
662 682
 //	var timeline = new Cesium.Timeline(viewer);
Please login to merge, or discard this patch.
js/map.2d.js.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 	});
353 353
 update_locationsLayer();
354 354
 <?php
355
-    // Add support for custom json via $globalMapJson
356
-    if (isset($globalMapJson) && is_array($globalMapJson)) {
355
+	// Add support for custom json via $globalMapJson
356
+	if (isset($globalMapJson) && is_array($globalMapJson)) {
357 357
 	foreach ($globalMapJson as $json) {
358
-	    if (isset($json['url'])) {
358
+		if (isset($json['url'])) {
359 359
 ?>
360 360
 update_genLayer('<?php print $json['url']; ?>');
361 361
 <?php
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 setInterval(function(){update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>);
365 365
 <?php
366 366
 		}
367
-	    }
367
+		}
368
+	}
368 369
 	}
369
-    }
370 370
 
371 371
 ?>
372 372
 //adds the bootstrap tooltip to the map icons
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once('../require/settings.php');
3 3
 require_once('../require/class.Language.php'); 
4 4
 
5
-setcookie("MapFormat",'2d');
5
+setcookie("MapFormat", '2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8 8
 if (!isset($globalJsonCompress)) $compress = true;
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
20 20
 	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
21 21
 	else $enddate = time();
22
-	setcookie("archive_begin",$begindate);
23
-	setcookie("archive_end",$enddate);
24
-	setcookie("archive_update",$lastupd);
25
-	setcookie("archive_speed",$archivespeed);
22
+	setcookie("archive_begin", $begindate);
23
+	setcookie("archive_end", $enddate);
24
+	setcookie("archive_update", $lastupd);
25
+	setcookie("archive_speed", $archivespeed);
26 26
 ?>
27 27
 document.cookie =  'archive_begin=<?php print $begindate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
28 28
 document.cookie =  'archive_end=<?php print $enddate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 <?php
74 74
 	}
75 75
 	if (isset($_GET['ident'])) {
76
-		$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
76
+		$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
77 77
 	}
78 78
 	if (isset($_GET['flightaware_id'])) {
79
-		$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
79
+		$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
80 80
 	}
81 81
 	if (isset($_GET['latitude'])) {
82
-		$latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING);
82
+		$latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING);
83 83
 	}
84 84
 	if (isset($_GET['longitude'])) {
85
-		$longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING);
85
+		$longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING);
86 86
 	}
87 87
 ?>
88 88
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	     || navigator.userAgent.match(/BlackBerry/i)
119 119
 	     || navigator.userAgent.match(/Windows Phone/i))
120 120
 	{
121
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
121
+		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom - 1; else print '8'; ?>;
122 122
 	} else {
123 123
 		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
124 124
 	}
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 	map.addLayer(yandexLayer);
213 213
 <?php
214 214
 	} elseif ($MapType == 'Bing-Aerial') {
215
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
215
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
216 216
 ?>
217 217
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
218 218
 	map.addLayer(bingLayer);
219 219
 <?php
220 220
 	} elseif ($MapType == 'Bing-Hybrid') {
221
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
221
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
222 222
 ?>
223 223
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
224 224
 	map.addLayer(bingLayer);
225 225
 <?php
226 226
 	} elseif ($MapType == 'Bing-Road') {
227
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
227
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
228 228
 ?>
229 229
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
230 230
 	map.addLayer(bingLayer);
Please login to merge, or discard this patch.
Braces   +74 added lines, -21 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
10 13
 if (isset($_GET['archive'])) {
11 14
 	$archive = true;
12 15
 	//$archiveupdatetime = 50;
@@ -17,8 +20,11 @@  discard block
 block discarded – undo
17 20
 	//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
18 21
 	//$lastupd = 20;
19 22
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
20
-	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
21
-	else $enddate = time();
23
+	if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
24
+		$enddate = $_GET['enddate'];
25
+	} else {
26
+		$enddate = time();
27
+	}
22 28
 	setcookie("archive_begin",$begindate);
23 29
 	setcookie("archive_end",$enddate);
24 30
 	setcookie("archive_update",$lastupd);
@@ -105,7 +111,17 @@  discard block
 block discarded – undo
105 111
 	}
106 112
 
107 113
 	//create the map
108
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
114
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
115
+	print $latitude;
116
+} else {
117
+	print $globalCenterLatitude;
118
+}
119
+?>,<?php if (isset($longitude)) {
120
+	print $longitude;
121
+} else {
122
+	print $globalCenterLongitude;
123
+}
124
+?>], zoom);
109 125
 <?php
110 126
 	} else {
111 127
 ?>
@@ -118,9 +134,19 @@  discard block
 block discarded – undo
118 134
 	     || navigator.userAgent.match(/BlackBerry/i)
119 135
 	     || navigator.userAgent.match(/Windows Phone/i))
120 136
 	{
121
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
137
+		var zoom = <?php if (isset($globalLiveZoom)) {
138
+	print $globalLiveZoom-1;
139
+} else {
140
+	print '8';
141
+}
142
+?>;
122 143
 	} else {
123
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
144
+		var zoom = <?php if (isset($globalLiveZoom)) {
145
+	print $globalLiveZoom;
146
+} else {
147
+	print '9';
148
+}
149
+?>;
124 150
 	}
125 151
 
126 152
 	//create the map
@@ -145,16 +171,27 @@  discard block
 block discarded – undo
145 171
 	bounds = L.latLngBounds(southWest,northEast);
146 172
 	//a few title layers
147 173
 <?php
148
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
149
-	else $MapType = $globalMapProvider;
174
+	if (isset($_COOKIE['MapType'])) {
175
+		$MapType = $_COOKIE['MapType'];
176
+	} else {
177
+		$MapType = $globalMapProvider;
178
+	}
150 179
 
151 180
 	if ($MapType == 'Mapbox') {
152
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
153
-		else $MapBoxId = $_COOKIE['MapTypeId'];
154
-?>
181
+		if ($_COOKIE['MapTypeId'] == 'default') {
182
+			$MapBoxId = $globalMapboxId;
183
+		} else {
184
+			$MapBoxId = $_COOKIE['MapTypeId'];
185
+		}
186
+		?>
155 187
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
156 188
 	    maxZoom: 18,
157
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
189
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
190
+	print 'false';
191
+} else {
192
+	print 'true';
193
+}
194
+?>,
158 195
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
159 196
 	      '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
160 197
 	      'Imagery © <a href="http://mapbox.com">Mapbox</a>',
@@ -166,7 +203,12 @@  discard block
 block discarded – undo
166 203
 ?>
167 204
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
168 205
 	    maxZoom: 18,
169
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
206
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
207
+	print 'false';
208
+} else {
209
+	print 'true';
210
+}
211
+?>,
170 212
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
171 213
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
172 214
 	}).addTo(map);
@@ -212,20 +254,26 @@  discard block
 block discarded – undo
212 254
 	map.addLayer(yandexLayer);
213 255
 <?php
214 256
 	} elseif ($MapType == 'Bing-Aerial') {
215
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
216
-?>
257
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
258
+			setcookie('MapType','OpenStreetMap');
259
+		}
260
+		?>
217 261
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
218 262
 	map.addLayer(bingLayer);
219 263
 <?php
220 264
 	} elseif ($MapType == 'Bing-Hybrid') {
221
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
222
-?>
265
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
266
+			setcookie('MapType','OpenStreetMap');
267
+		}
268
+		?>
223 269
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
224 270
 	map.addLayer(bingLayer);
225 271
 <?php
226 272
 	} elseif ($MapType == 'Bing-Road') {
227
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
228
-?>
273
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
274
+			setcookie('MapType','OpenStreetMap');
275
+		}
276
+		?>
229 277
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
230 278
 	map.addLayer(bingLayer);
231 279
 <?php
@@ -273,7 +321,12 @@  discard block
 block discarded – undo
273 321
 		}
274 322
 	} elseif ($globalBounding == 'circle') {
275 323
 ?>
276
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
324
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
325
+	print $globalBoundingCircleSize;
326
+} else {
327
+	print '70000';
328
+}
329
+?>,{
277 330
 	    color: '#92C7D1',
278 331
 	    fillColor: '#92C7D1',
279 332
 	    fillOpacity: 0.3,
Please login to merge, or discard this patch.
live-czml.php 3 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -34,30 +34,30 @@  discard block
 block discarded – undo
34 34
 
35 35
 
36 36
 function quaternionrotate($heading, $attitude = 0, $bank = 0) {
37
-    // Assuming the angles are in radians.
38
-    $c1 = cos($heading/2);
39
-    $s1 = sin($heading/2);
40
-    $c2 = cos($attitude/2);
41
-    $s2 = sin($attitude/2);
42
-    $c3 = cos($bank/2);
43
-    $s3 = sin($bank/2);
44
-    $c1c2 = $c1*$c2;
45
-    $s1s2 = $s1*$s2;
46
-    $w =$c1c2*$c3 - $s1s2*$s3;
47
-    $x =$c1c2*$s3 + $s1s2*$c3;
48
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
49
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
50
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
37
+	// Assuming the angles are in radians.
38
+	$c1 = cos($heading/2);
39
+	$s1 = sin($heading/2);
40
+	$c2 = cos($attitude/2);
41
+	$s2 = sin($attitude/2);
42
+	$c3 = cos($bank/2);
43
+	$s3 = sin($bank/2);
44
+	$c1c2 = $c1*$c2;
45
+	$s1s2 = $s1*$s2;
46
+	$w =$c1c2*$c3 - $s1s2*$s3;
47
+	$x =$c1c2*$s3 + $s1s2*$c3;
48
+	$y =$s1*$c2*$c3 + $c1*$s2*$s3;
49
+	$z =$c1*$s2*$c3 - $s1*$c2*$s3;
50
+	return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
51 51
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
52 52
 
53 53
 }
54 54
 
55 55
 
56 56
 if (isset($_GET['download'])) {
57
-    if ($_GET['download'] == "true")
58
-    {
57
+	if ($_GET['download'] == "true")
58
+	{
59 59
 	header('Content-disposition: attachment; filename="flightairmap.json"');
60
-    }
60
+	}
61 61
 }
62 62
 header('Content-Type: text/javascript');
63 63
 
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 			$image = "images/placeholder_thumb.png";
221 221
 		}
222 222
 
223
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
224
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
225
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
226
-                if ($prev_flightaware_id != $id) {
223
+				if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
224
+				elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
225
+				elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
226
+				if ($prev_flightaware_id != $id) {
227 227
 			if ($prev_flightaware_id != '') {
228 228
 				$output .= ']';
229 229
 				$output .= '}';
Please login to merge, or discard this patch.
Braces   +89 added lines, -31 removed lines patch added patch discarded remove patch
@@ -3,8 +3,12 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Common.php');
4 4
 $tracker = false;
5 5
 $marine = false;
6
-if (isset($_GET['tracker'])) $tracker = true;
7
-if (isset($_GET['marine'])) $marine = true;
6
+if (isset($_GET['tracker'])) {
7
+	$tracker = true;
8
+}
9
+if (isset($_GET['marine'])) {
10
+	$marine = true;
11
+}
8 12
 if ($tracker) {
9 13
 	require_once('require/class.Tracker.php');
10 14
 	require_once('require/class.TrackerLive.php');
@@ -61,23 +65,46 @@  discard block
 block discarded – undo
61 65
 }
62 66
 header('Content-Type: text/javascript');
63 67
 
64
-if (!isset($globalJsonCompress)) $compress = true;
65
-else $compress = $globalJsonCompress;
68
+if (!isset($globalJsonCompress)) {
69
+	$compress = true;
70
+} else {
71
+	$compress = $globalJsonCompress;
72
+}
66 73
 
67 74
 $from_archive = false;
68 75
 $min = false;
69 76
 $allhistory = false;
70 77
 $filter['source'] = array();
71
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
72
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
73
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
74
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
75
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
76
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
79
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
80
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
80
+}
81
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
83
+}
84
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
86
+}
87
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
88
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
89
+}
90
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
91
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
92
+}
93
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
94
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
97
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
100
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
103
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
104
+}
105
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
106
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
107
+}
81 108
 /*
82 109
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
83 110
 	$min = true;
@@ -162,8 +189,12 @@  discard block
 block discarded – undo
162 189
 	} else {
163 190
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
164 191
 	}
165
-	if ($flightcnt == '') $flightcnt = 0;
166
-} else $flightcnt = 0;
192
+	if ($flightcnt == '') {
193
+		$flightcnt = 0;
194
+	}
195
+	} else {
196
+	$flightcnt = 0;
197
+}
167 198
 
168 199
 $sqltime = round(microtime(true)-$begintime,2);
169 200
 $minitime = time();
@@ -186,7 +217,9 @@  discard block
 block discarded – undo
186 217
 $j = 0;
187 218
 $prev_flightaware_id = '';
188 219
 $speed = 1;
189
-if (isset($archivespeed)) $speed = $archivespeed;
220
+if (isset($archivespeed)) {
221
+	$speed = $archivespeed;
222
+}
190 223
 $output = '[';
191 224
 if ($tracker) {
192 225
 	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
@@ -220,9 +253,13 @@  discard block
 block discarded – undo
220 253
 			$image = "images/placeholder_thumb.png";
221 254
 		}
222 255
 
223
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
224
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
225
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
256
+                if (isset($spotter_item['flightaware_id'])) {
257
+                	$id = $spotter_item['flightaware_id'];
258
+                } elseif (isset($spotter_item['famtrackid'])) {
259
+                	$id = $spotter_item['famtrackid'];
260
+                } elseif (isset($spotter_item['fammarine_id'])) {
261
+                	$id = $spotter_item['fammarine_id'];
262
+                }
226 263
                 if ($prev_flightaware_id != $id) {
227 264
 			if ($prev_flightaware_id != '') {
228 265
 				$output .= ']';
@@ -268,7 +305,9 @@  discard block
 block discarded – undo
268 305
 						$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
269 306
 						$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
270 307
 						$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
271
-					} else $aircraft_shadow = '';
308
+					} else {
309
+						$aircraft_shadow = '';
310
+					}
272 311
 					if ($aircraft_shadow != '') {
273 312
 						if (isset($modelsdb[$aircraft_shadow])) {
274 313
 							$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
@@ -405,7 +444,9 @@  discard block
 block discarded – undo
405 444
 							}
406 445
 							$output .= '},';
407 446
 								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
408
-							if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
447
+							if ($spotter_item['aircraft_icao'] != '') {
448
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
449
+							}
409 450
 							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
410 451
 						}
411 452
 					} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -427,7 +468,9 @@  discard block
 block discarded – undo
427 468
 						}
428 469
 						$output .= '},';
429 470
 						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
430
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
471
+						if ($spotter_item['aircraft_icao'] != '') {
472
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
473
+						}
431 474
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
432 475
 					}
433 476
 				} else {
@@ -440,7 +483,9 @@  discard block
 block discarded – undo
440 483
 					}
441 484
 					$output .= '},';
442 485
 					//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
443
-					if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
486
+					if ($spotter_item['aircraft_icao'] != '') {
487
+						$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
488
+					}
444 489
 					$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
445 490
 				}
446 491
 			} elseif ($tracker && isset($spotter_item['type'])) {
@@ -495,8 +540,12 @@  discard block
 block discarded – undo
495 540
 	//		$output .= '"interpolationDegree" : 5,';
496 541
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
497 542
 			$output .= '"cartographicDegrees": [';
498
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
499
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
543
+			if ($minitime > strtotime($spotter_item['date'])) {
544
+				$minitime = strtotime($spotter_item['date']);
545
+			}
546
+			if ($maxitime < strtotime($spotter_item['date'])) {
547
+				$maxitime = strtotime($spotter_item['date']);
548
+			}
500 549
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
501 550
 			$output .= $spotter_item['longitude'].', ';
502 551
 			$output .= $spotter_item['latitude'];
@@ -505,19 +554,26 @@  discard block
 block discarded – undo
505 554
 			if (!$tracker && !$marine) {
506 555
 				$output .= ', '.round($spotter_item['altitude']*30.48);
507 556
 				$prevalt = round($spotter_item['altitude']*30.48);
508
-			} else $output .= ', 0';
557
+			} else {
558
+				$output .= ', 0';
559
+			}
509 560
 			//$orientation = '"orientation" : { ';
510 561
 			//$orientation .= '"unitQuaternion": [';
511 562
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
512 563
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
513 564
 		} else {
514 565
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
515
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
566
+			if ($maxitime < strtotime($spotter_item['date'])) {
567
+				$maxitime = strtotime($spotter_item['date']);
568
+			}
516 569
 			if ($spotter_item['ground_speed'] == 0) {
517 570
 				$output .= $prevlong.', ';
518 571
 				$output .= $prevlat;
519
-				if (!$tracker && !$marine) $output .= ', '.$prevalt;
520
-				else $output .= ', 0';
572
+				if (!$tracker && !$marine) {
573
+					$output .= ', '.$prevalt;
574
+				} else {
575
+					$output .= ', 0';
576
+				}
521 577
 			} else {
522 578
 				$output .= $spotter_item['longitude'].', ';
523 579
 				$output .= $spotter_item['latitude'];
@@ -531,7 +587,9 @@  discard block
 block discarded – undo
531 587
 					} else {
532 588
 						$output .= ', '.round($spotter_item['altitude']*30.48);
533 589
 					}
534
-				} else $output .= ', 0';
590
+				} else {
591
+					$output .= ', 0';
592
+				}
535 593
 			}
536 594
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
537 595
 			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     $s3 = sin($bank/2);
44 44
     $c1c2 = $c1*$c2;
45 45
     $s1s2 = $s1*$s2;
46
-    $w =$c1c2*$c3 - $s1s2*$s3;
47
-    $x =$c1c2*$s3 + $s1s2*$c3;
48
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
49
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
50
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
46
+    $w = $c1c2*$c3 - $s1s2*$s3;
47
+    $x = $c1c2*$s3 + $s1s2*$c3;
48
+    $y = $s1*$c2*$c3 + $c1*$s2*$s3;
49
+    $z = $c1*$s2*$c3 - $s1*$c2*$s3;
50
+    return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w);
51 51
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
52 52
 
53 53
 }
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
 $min = false;
69 69
 $allhistory = false;
70 70
 $filter['source'] = array();
71
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
72
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
73
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
74
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
75
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
76
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
79
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
80
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
71
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
73
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
74
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
75
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
77
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
78
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
79
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
80
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
81 81
 /*
82 82
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
83 83
 	$min = true;
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 	$from_archive = true;
125 125
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
126 126
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
127
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
128
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
129
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
130
-	$begindate = date('Y-m-d H:i:s',$begindate);
131
-	$enddate = date('Y-m-d H:i:s',$enddate);
132
-	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
127
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
128
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
129
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
130
+	$begindate = date('Y-m-d H:i:s', $begindate);
131
+	$enddate = date('Y-m-d H:i:s', $enddate);
132
+	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
133 133
 } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
134 134
 	$from_archive = true;
135 135
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	$begindate = $_COOKIE['archive_begin'];
140 140
 	$enddate = $_COOKIE['archive_end'];
141 141
 
142
-	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
143
-	$begindate = date('Y-m-d H:i:s',$begindate);
144
-	$enddate = date('Y-m-d H:i:s',$enddate);
142
+	$archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT);
143
+	$begindate = date('Y-m-d H:i:s', $begindate);
144
+	$enddate = date('Y-m-d H:i:s', $enddate);
145 145
 //	echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
146
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
146
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
147 147
 } elseif ($tracker) {
148 148
 	$spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter);
149 149
 } elseif ($marine) {
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 if (!empty($spotter_array)) {
156 156
 	if (isset($_GET['archive'])) {
157
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
157
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
158 158
 	} elseif ($tracker) {
159 159
 		$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
160 160
 	} elseif ($marine) {
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
 	if ($flightcnt == '') $flightcnt = 0;
166 166
 } else $flightcnt = 0;
167 167
 
168
-$sqltime = round(microtime(true)-$begintime,2);
168
+$sqltime = round(microtime(true) - $begintime, 2);
169 169
 $minitime = time();
170 170
 $maxitime = 0;
171 171
 
172 172
 
173 173
 $modelsdb = array();
174 174
 if (file_exists('models/modelsdb')) {
175
-	if (($handle = fopen('models/modelsdb','r')) !== FALSE) {
176
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
177
-			if (isset($row[1]) ){
175
+	if (($handle = fopen('models/modelsdb', 'r')) !== FALSE) {
176
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
177
+			if (isset($row[1])) {
178 178
 				$model = $row[0];
179 179
 				$modelsdb[$model] = $row[1];
180 180
 			}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER","interval": "%minitime%/%maxitime%"}';
204 204
 } else {
205 205
 	if (isset($globalArchive) && $globalArchive === TRUE) {
206
-		$output .= ',"clock": {"currentTime" : "'.date("c",time()-$globalLiveInterval).'","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
206
+		$output .= ',"clock": {"currentTime" : "'.date("c", time() - $globalLiveInterval).'","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
207 207
 	} else {
208 208
 		$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
209 209
 	}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 $output .= '},';
214 214
 if (!empty($spotter_array) && is_array($spotter_array))
215 215
 {
216
-	foreach($spotter_array as $spotter_item)
216
+	foreach ($spotter_array as $spotter_item)
217 217
 	{
218 218
 		$j++;
219 219
 		date_default_timezone_set('UTC');
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 			$output .= '"cartographicDegrees": [';
502 502
 			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
503 503
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
504
-			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
504
+			$output .= '"'.date("c", strtotime($spotter_item['date'])).'", ';
505 505
 			$output .= $spotter_item['longitude'].', ';
506 506
 			$output .= $spotter_item['latitude'];
507 507
 			$prevlong = $spotter_item['longitude'];
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
516 516
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
517 517
 		} else {
518
-			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
518
+			$output .= ',"'.date("c", strtotime($spotter_item['date'])).'", ';
519 519
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
520 520
 			if ($spotter_item['ground_speed'] == 0) {
521 521
 				$output .= $prevlong.', ';
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	$output  = substr($output, 0, -1);
548 548
 }
549 549
 $output .= ']';
550
-$output = str_replace('%minitime%',date("c",$minitime),$output);
551
-$output = str_replace('%maxitime%',date("c",$maxitime),$output);
550
+$output = str_replace('%minitime%', date("c", $minitime), $output);
551
+$output = str_replace('%maxitime%', date("c", $maxitime), $output);
552 552
 print $output;
553 553
 ?>
Please login to merge, or discard this patch.
header.php 3 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30 30
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
31
+		return strpos($key,'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
 	}
169 169
 ?>
170 170
 <?php 
171
-    if (isset($_POST['archive'])) {
171
+	if (isset($_POST['archive'])) {
172 172
 ?>
173 173
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
174 174
 <?php 
175
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
175
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
176 176
 ?>
177 177
 
178 178
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
179 179
 <?php    
180
-	    }
181
-    } else {
180
+		}
181
+	} else {
182 182
 ?>
183 183
 <?php
184 184
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 */
191 191
 ?>
192 192
 <?php 
193
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
193
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
194 194
 ?>
195 195
 <?php
196 196
 //		if (isset($globalBeta) && $globalBeta) {
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 <script src="<?php print $globalURL; ?>/js/map-marine.2d.js.php?<?php print time(); ?>"></script>
218 218
 <?php
219 219
 		}
220
-	    }
220
+		}
221 221
 ?>
222 222
 <?php
223 223
 //	}
224 224
 ?>
225 225
 <?php
226
-    }
226
+	}
227 227
 }
228 228
 ?>
229 229
 <?php
@@ -380,15 +380,15 @@  discard block
 block discarded – undo
380 380
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
381 381
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
382 382
 <?php
383
-    if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
383
+	if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
384 384
 ?>
385 385
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
386 386
 <?php
387
-    } else {
387
+	} else {
388 388
 ?>
389 389
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
390 390
 <?php
391
-    }
391
+	}
392 392
 ?>
393 393
 			<li><hr /></li>
394 394
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -396,34 +396,34 @@  discard block
 block discarded – undo
396 396
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
397 397
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
398 398
             <?php
399
-        	if ($globalACARS) {
400
-        	    if (isset($globalDemo) && $globalDemo) {
401
-    	    ?>
399
+			if ($globalACARS) {
400
+				if (isset($globalDemo) && $globalDemo) {
401
+			?>
402 402
             <li><hr /></li>
403 403
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
404 404
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
405 405
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
406 406
             <?php
407
-        	    } else {
408
-    	    ?>
407
+				} else {
408
+			?>
409 409
             <li><hr /></li>
410 410
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
411 411
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
412 412
             <?php
413
-        	    }
414
-        	}
415
-    	    ?>
413
+				}
414
+			}
415
+			?>
416 416
     	    <?php
417
-    	        if (isset($globalAccidents) && $globalAccidents) {
418
-    	    ?>
417
+				if (isset($globalAccidents) && $globalAccidents) {
418
+			?>
419 419
             <li><hr /></li>
420 420
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
421 421
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
422 422
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
423 423
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
424 424
             <?php
425
-        	}
426
-    	    ?>
425
+			}
426
+			?>
427 427
             <li><hr /></li>
428 428
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
429 429
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
@@ -465,14 +465,14 @@  discard block
 block discarded – undo
465 465
   	    <form>
466 466
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
467 467
   		    <?php
468
-  		        $Language = new Language();
469
-  		        $alllang = $Language->getLanguages();
470
-  		        foreach ($alllang as $key => $lang) {
471
-  		            print '<option value="'.$key.'"';
472
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
473
-  		            print '>'.$lang[0].'</option>';
474
-  		        }
475
-  		    ?>
468
+  				$Language = new Language();
469
+  				$alllang = $Language->getLanguages();
470
+  				foreach ($alllang as $key => $lang) {
471
+  					print '<option value="'.$key.'"';
472
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
473
+  					print '>'.$lang[0].'</option>';
474
+  				}
475
+  			?>
476 476
   		</select>
477 477
   	    </form>
478 478
   	</div>
@@ -503,18 +503,18 @@  discard block
 block discarded – undo
503 503
 ?>
504 504
     <div class="top-header clear" role="main">
505 505
 <?php
506
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
506
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
507 507
 ?>
508 508
     <div id="archive-map"></div>
509 509
 <?php
510
-    }
510
+	}
511 511
 ?>
512 512
     </div>
513 513
 <?php
514 514
 }
515 515
 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))
516 516
 {
517
-    ?>
517
+	?>
518 518
     <div class="top-header clear" role="main">
519 519
         <div id="map"></div>
520 520
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -525,15 +525,15 @@  discard block
 block discarded – undo
525 525
         var zoom = 13;
526 526
 //create the map
527 527
 <?php
528
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
528
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
529 529
 ?>
530 530
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
531 531
 <?php
532
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
532
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
533 533
 ?>
534 534
   map = L.map('map', { zoomControl:true });
535 535
 <?php
536
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
536
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
537 537
 ?>
538 538
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
539 539
     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);
@@ -541,22 +541,22 @@  discard block
 block discarded – undo
541 541
     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);
542 542
     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);
543 543
 <?php
544
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
544
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
545 545
 ?>
546 546
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
547 547
 <?php
548
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
548
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
549 549
 ?>
550 550
   map = L.map('map', { zoomControl:true });
551 551
 <?php
552
-    }
552
+	}
553 553
 ?>
554 554
   //initialize the layer group for the aircrft markers
555 555
   var layer_data = L.layerGroup();
556 556
 
557 557
   //a few title layers
558 558
 <?php
559
-    if ($globalMapProvider == 'Mapbox') {
559
+	if ($globalMapProvider == 'Mapbox') {
560 560
 ?>
561 561
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
562 562
     maxZoom: 18,
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
     token : '<?php print $globalMapboxToken; ?>'
568 568
   }).addTo(map);
569 569
 <?php
570
-    } elseif ($globalMapProvider == 'OpenStreetMap') {
570
+	} elseif ($globalMapProvider == 'OpenStreetMap') {
571 571
 ?>
572 572
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
573 573
     maxZoom: 18,
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
       '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>'
576 576
   }).addTo(map);
577 577
 <?php
578
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
578
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
579 579
 ?>
580 580
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
581 581
     maxZoom: 18,
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
585 585
   }).addTo(map);
586 586
 <?php
587
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
587
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
588 588
 ?>
589 589
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
590 590
     maxZoom: 18,
@@ -593,27 +593,27 @@  discard block
 block discarded – undo
593 593
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
594 594
   }).addTo(map);
595 595
 <?php
596
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
596
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
597 597
 ?>
598 598
     var googleLayer = new L.Google('ROADMAP');
599 599
     map.addLayer(googleLayer);
600 600
 <?php
601
-    } elseif ($globalMapProvider == 'Google-Satellite') {
601
+	} elseif ($globalMapProvider == 'Google-Satellite') {
602 602
 ?>
603 603
     var googleLayer = new L.Google('SATELLITE');
604 604
     map.addLayer(googleLayer);
605 605
 <?php
606
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
606
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
607 607
 ?>
608 608
     var googleLayer = new L.Google('HYBRID');
609 609
     map.addLayer(googleLayer);
610 610
 <?php
611
-    } elseif ($globalMapProvider == 'Google-Terrain') {
611
+	} elseif ($globalMapProvider == 'Google-Terrain') {
612 612
 ?>
613 613
     var googleLayer = new L.Google('Terrain');
614 614
     map.addLayer(googleLayer);
615 615
 <?php
616
-    }
616
+	}
617 617
 ?>
618 618
         </script>
619 619
     </div>
Please login to merge, or discard this 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
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
242 242
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
243 243
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
244
-<script src="<?php print $globalURL; ?>/js/map.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
+<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
245 245
 <?php
246 246
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
247 247
 ?>
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
297 297
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
298 298
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
299
-<script src="<?php print $globalURL; ?>/js/map.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>
299
+<script src="<?php print $globalURL; ?>/js/map.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>
300 300
 <?php
301 301
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
302 302
 ?>
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 ?>
482 482
       <div class="search">
483 483
       <form action="<?php print $globalURL; ?>/search" method="get">
484
-		<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>
484
+		<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>
485 485
 	</form>
486 486
 	</div>
487 487
   	<div class="social">
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	print '</div>';
500 500
 }
501 501
 
502
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
502
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
503 503
 ?>
504 504
     <div class="top-header clear" role="main">
505 505
 <?php
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
     </div>
513 513
 <?php
514 514
 }
515
-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))
515
+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))
516 516
 {
517 517
     ?>
518 518
     <div class="top-header clear" role="main">
@@ -525,15 +525,15 @@  discard block
 block discarded – undo
525 525
         var zoom = 13;
526 526
 //create the map
527 527
 <?php
528
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
528
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
529 529
 ?>
530 530
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
531 531
 <?php
532
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
532
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
533 533
 ?>
534 534
   map = L.map('map', { zoomControl:true });
535 535
 <?php
536
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
536
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
537 537
 ?>
538 538
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
539 539
     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);
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
     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);
542 542
     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);
543 543
 <?php
544
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
544
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
545 545
 ?>
546 546
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
547 547
 <?php
Please login to merge, or discard this patch.
Braces   +32 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
6 6
 $current_page = $file_path['filename'];
7 7
 date_default_timezone_set($globalTimezone);
8
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9
-else $MapType = $globalMapProvider;
8
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
9
+	$MapType = $_COOKIE['MapType'];
10
+} else {
11
+	$MapType = $globalMapProvider;
12
+}
10 13
 if (isset($_GET['3d'])) {
11 14
 	setcookie('MapFormat','3d');
12 15
 } else if (isset($_GET['2d'])) {
@@ -241,7 +244,13 @@  discard block
 block discarded – undo
241 244
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
242 245
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
243 246
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
244
-<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
247
+<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
248
+	print '&latitude='.$latitude;
249
+}
250
+?><?php if(isset($longitude)) {
251
+	print '&longitude='.$longitude;
252
+}
253
+?>&<?php print time(); ?>"></script>
245 254
 <?php
246 255
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
247 256
 ?>
@@ -296,7 +305,13 @@  discard block
 block discarded – undo
296 305
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
297 306
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
298 307
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
299
-<script src="<?php print $globalURL; ?>/js/map.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>
308
+<script src="<?php print $globalURL; ?>/js/map.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
309
+	print '&latitude='.$latitude;
310
+}
311
+?><?php if(isset($longitude)) {
312
+	print '&longitude='.$longitude;
313
+}
314
+?>&<?php print time(); ?>"></script>
300 315
 <?php
301 316
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
302 317
 ?>
@@ -369,7 +384,12 @@  discard block
 block discarded – undo
369 384
         <span class="icon-bar"></span>
370 385
       </button>
371 386
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle navbar-toggle-search"><i class="fa fa-search"></i></a>
372
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
387
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
388
+	print '/';
389
+} else {
390
+	print $globalURL;
391
+}
392
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
373 393
     </div>
374 394
     <div class="collapse navbar-collapse">
375 395
       <ul class="nav navbar-nav">
@@ -469,7 +489,9 @@  discard block
 block discarded – undo
469 489
   		        $alllang = $Language->getLanguages();
470 490
   		        foreach ($alllang as $key => $lang) {
471 491
   		            print '<option value="'.$key.'"';
472
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
492
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
493
+  		            	print ' selected ';
494
+  		            }
473 495
   		            print '>'.$lang[0].'</option>';
474 496
   		        }
475 497
   		    ?>
@@ -622,4 +644,7 @@  discard block
 block discarded – undo
622 644
 
623 645
 ?>
624 646
 
625
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
647
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
648
+	print 'index ';
649
+}
650
+?>clear">
Please login to merge, or discard this patch.
marine-data.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  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;
@@ -31,11 +31,11 @@  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;
@@ -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
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
tracker-data.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  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 = $TrackerLive->getDateLiveTrackerDataByIdent($ident,$currenttime);
16
+		$spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident, $currenttime);
17 17
 		/*
18 18
 		if (empty($spotter_array)) {
19 19
 			$from_archive = true;
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 	}
32 32
 }
33 33
 if (isset($_GET['famtrackid'])) {
34
-	$famtrackid = filter_input(INPUT_GET,'famtrackid',FILTER_SANITIZE_STRING);
34
+	$famtrackid = filter_input(INPUT_GET, 'famtrackid', 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 = $TrackerLive->getDateLiveTrackerDataById($famtrackid,$currenttime);
38
+		$spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid, $currenttime);
39 39
 		/*
40 40
 		if (empty($spotter_array)) {
41 41
 			$from_archive = true;
@@ -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
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
require/class.AIS.php 4 patches
Doc Comments   +25 added lines patch added patch discarded remove patch
@@ -68,6 +68,10 @@  discard block
 block discarded – undo
68 68
        't', 'u', 'v', 'w' // 119
69 69
     ); // char 64
70 70
     */
71
+
72
+	/**
73
+	 * @param integer $ascii
74
+	 */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73 77
 		if ($ascii < 48) { }
@@ -93,6 +97,10 @@  discard block
 block discarded – undo
93 97
 		return(substr($bin, -6)); 
94 98
 	}
95 99
 
100
+	/**
101
+	 * @param integer $_start
102
+	 * @param integer $_size
103
+	 */
96 104
 	private function binchar($_str, $_start, $_size) {
97 105
 		//  ' ' --- '?', // 0x20 - 0x3F
98 106
 		//  '@' --- '_', // 0x40 - 0x5F
@@ -118,6 +126,10 @@  discard block
 block discarded – undo
118 126
 	}
119 127
 
120 128
 	// function for decoding the AIS Message ITU Payload
129
+
130
+	/**
131
+	 * @param string $_aisdata
132
+	 */
121 133
 	private function decode_ais($_aisdata) {
122 134
 		$ro = new stdClass(); // return object
123 135
 		$ro->cls = 0; // AIS class undefined, also indicate unparsed msg
@@ -351,6 +363,12 @@  discard block
 block discarded – undo
351 363
 		elseif ($code == 99) return 'Other Type, no additional information';
352 364
 	}
353 365
 
366
+	/**
367
+	 * @param string $_itu
368
+	 * @param integer $_len
369
+	 * @param integer $_filler
370
+	 * @param string $aux
371
+	 */
354 372
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
355 373
 		global $port; // tcpip port...
356 374
 		
@@ -371,6 +389,10 @@  discard block
 block discarded – undo
371 389
 
372 390
 	// char* - AIS \r terminated string
373 391
 	// TCP based streams which send messages in full can use this instead of calling process_ais_buf
392
+
393
+	/**
394
+	 * @param string $rawdata
395
+	 */
374 396
 	public function process_ais_raw($rawdata, $aux = '') { // return int
375 397
 		static $num_seq; // 1 to 9
376 398
 		static $seq; // 1 to 9
@@ -589,6 +611,9 @@  discard block
 block discarded – undo
589 611
 		return $result;
590 612
 	}
591 613
 
614
+	/**
615
+	 * @param string $mmsi
616
+	 */
592 617
 	public function mmsitype($mmsi) {
593 618
 		if (strlen($mmsi) == 9) {
594 619
 			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		return ($dec);
58 58
 	}
59 59
 	
60
-    /*
60
+	/*
61 61
     $ais_map64 = array(
62 62
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48
63 63
        ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C',
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 		//  ' ' --- '?', // 0x20 - 0x3F
98 98
 		//  '@' --- '_', // 0x40 - 0x5F
99 99
 		$ais_chars = array(
100
-		    '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
-		    'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
-		    'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
-		    '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
-		    '(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
-		    '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
-		    '<', '=', '>', '?'
100
+			'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
+			'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
+			'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
+			'^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
+			'(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
+			'2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
+			'<', '=', '>', '?'
107 107
 		);
108 108
 		// "
109 109
 		$rv = '';
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 				}
420 420
 				if ($num_seq > 1) { // for multipart messages
421 421
 					if ($cmsg_sid != $msg_sid // different msg_sid
422
-					    || $msg_sid == -1 // invalid initial msg_sid
423
-					    || ($seq - $pseq) != 1 // not insequence
422
+						|| $msg_sid == -1 // invalid initial msg_sid
423
+						|| ($seq - $pseq) != 1 // not insequence
424 424
 					) {  // invalid for multipart message
425 425
 						$msg_sid = -1;
426 426
 						$cmsg_sid = -1;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 				$itu = $itu.$pcs[5]; // get itu message
434 434
 				$filler += (int)$pcs[6][0]; // get filler
435 435
 				if ($num_seq == 1 // valid single message
436
-				    || $num_seq == $pseq // valid multi-part message
436
+					|| $num_seq == $pseq // valid multi-part message
437 437
 				) {
438 438
 					if ($num_seq != 1) { // test
439 439
 						//echo $rawdata;
@@ -516,13 +516,13 @@  discard block
 block discarded – undo
516 516
 		else $pad = '';
517 517
 		$rv = '';
518 518
 		$ais_chars = array(
519
-		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
520
-		    'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
521
-		    'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
522
-		    '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
523
-		    '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
524
-		    '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
525
-		    '<'=>60, '='=>61, '>'=>62, '?'=>63
519
+			'@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
520
+			'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
521
+			'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
522
+			'^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
523
+			'('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
524
+			'2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
525
+			'<'=>60, '='=>61, '>'=>62, '?'=>63
526 526
 		);
527 527
 		// "
528 528
 		$_a = str_split($name);
Please login to merge, or discard this patch.
Spacing   +124 added lines, -124 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;
Please login to merge, or discard this patch.
Braces   +322 added lines, -140 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 			$temp += 1;
36 36
 			$flat = (float)($temp / (60.0 * 10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else {
39
+			$flat = (float)($temp / (60.0 * 10000.0));
40
+		}
39 41
 		return $flat; // float
40 42
 	}
41 43
 
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 			$temp += 1;
48 50
 			$flon = (float)($temp / (60.0 * 10000.0));
49 51
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
52
+		} else {
53
+			$flon = (float)($temp / (60.0 * 10000.0));
54
+		}
51 55
 		return $flon;
52 56
 	}
53 57
 
@@ -70,10 +74,8 @@  discard block
 block discarded – undo
70 74
     */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73
-		if ($ascii < 48) { }
74
-		else {
75
-			if($ascii>119) { }
76
-			else {
77
+		if ($ascii < 48) { } else {
78
+			if($ascii>119) { } else {
77 79
 				if ($ascii>87 && $ascii<96) ;
78 80
 				else {
79 81
 					$ascii=$ascii+40;
@@ -175,7 +177,9 @@  discard block
 block discarded – undo
175 177
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176 178
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177 179
 			$ro->heading = bindec(substr($_aisdata,124,9));
178
-			if ($ro->heading == 511) $ro->heading = '';
180
+			if ($ro->heading == 511) {
181
+				$ro->heading = '';
182
+			}
179 183
 			$ro->cls = 2; // class B
180 184
 		} else if ($ro->id == 19) {
181 185
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -185,7 +189,9 @@  discard block
 block discarded – undo
185 189
 			$ro->name = $this->binchar($_aisdata,143,120);
186 190
 			$ro->cls = 2; // class B
187 191
 			$ro->heading = bindec(substr($_aisdata,124,9));
188
-			if ($ro->heading == 511) $ro->heading = '';
192
+			if ($ro->heading == 511) {
193
+				$ro->heading = '';
194
+			}
189 195
 			$ro->typeid = bindec(substr($_aisdata,263,8));
190 196
 			$ro->type = $this->getShipType($ro->typeid);
191 197
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -216,9 +222,13 @@  discard block
 block discarded – undo
216 222
 			$ro->cls = 2; // class B
217 223
 		} else if ($ro->id == 27) {
218 224
 			$ro->cog = bindec(substr($_aisdata,85,9));
219
-			if ($ro->cog == 511) $ro->cog = 0.0;
225
+			if ($ro->cog == 511) {
226
+				$ro->cog = 0.0;
227
+			}
220 228
 			$ro->sog = bindec(substr($_aisdata,79,6));
221
-			if ($ro->sog == 63) $ro->sog = 0.0;
229
+			if ($ro->sog == 63) {
230
+				$ro->sog = 0.0;
231
+			}
222 232
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223 233
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
224 234
 			$ro->cls = 1; // class A
@@ -267,88 +277,171 @@  discard block
 block discarded – undo
267 277
 	}
268 278
 	
269 279
 	public function getShipType($code) {
270
-		if ($code == 0) return 'Not available (default)';
271
-		elseif ($code >= 1 && $code <= 19) return 'Reserved for future use';
272
-		elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type';
273
-		elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A';
274
-		elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B';
275
-		elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C';
276
-		elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D';
277
-		elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use';
278
-		elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use';
279
-		elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use';
280
-		elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use';
281
-		elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use';
282
-		elseif ($code == 30) return 'Fishing';
283
-		elseif ($code == 31) return 'Towing';
284
-		elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m';
285
-		elseif ($code == 33) return 'Dredging or underwater ops';
286
-		elseif ($code == 34) return 'Diving ops';
287
-		elseif ($code == 35) return 'Military ops';
288
-		elseif ($code == 36) return 'Sailing';
289
-		elseif ($code == 37) return 'Pleasure Craft';
290
-		elseif ($code == 38) return 'Reserved';
291
-		elseif ($code == 39) return 'Reserved';
292
-		elseif ($code == 40) return 'High speed craft (HSC), all ships of this type';
293
-		elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A';
294
-		elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B';
295
-		elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C';
296
-		elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D';
297
-		elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use';
298
-		elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use';
299
-		elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use';
300
-		elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use';
301
-		elseif ($code == 49) return 'High speed craft (HSC), No additional information';
302
-		elseif ($code == 50) return 'Pilot Vessel';
303
-		elseif ($code == 51) return 'Search and Rescue vessel';
304
-		elseif ($code == 52) return 'Tug';
305
-		elseif ($code == 53) return 'Port Tender';
306
-		elseif ($code == 54) return 'Anti-pollution equipment';
307
-		elseif ($code == 55) return 'Law Enforcement';
308
-		elseif ($code == 56) return 'Spare - Local Vessel';
309
-		elseif ($code == 57) return 'Spare - Local Vessel';
310
-		elseif ($code == 58) return 'Medical Transport';
311
-		elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18';
312
-		elseif ($code == 60) return 'Passenger, all ships of this type';
313
-		elseif ($code == 61) return 'Passenger, Hazardous category A';
314
-		elseif ($code == 62) return 'Passenger, Hazardous category B';
315
-		elseif ($code == 63) return 'Passenger, Hazardous category C';
316
-		elseif ($code == 64) return 'Passenger, Hazardous category D';
317
-		elseif ($code == 65) return 'Passenger, Reserved for future use';
318
-		elseif ($code == 66) return 'Passenger, Reserved for future use';
319
-		elseif ($code == 67) return 'Passenger, Reserved for future use';
320
-		elseif ($code == 68) return 'Passenger, Reserved for future use';
321
-		elseif ($code == 69) return 'Passenger, No additional information';
322
-		elseif ($code == 70) return 'Cargo, all ships of this type';
323
-		elseif ($code == 71) return 'Cargo, Hazardous category A';
324
-		elseif ($code == 72) return 'Cargo, Hazardous category B';
325
-		elseif ($code == 73) return 'Cargo, Hazardous category C';
326
-		elseif ($code == 74) return 'Cargo, Hazardous category D';
327
-		elseif ($code == 75) return 'Cargo, Reserved for future use';
328
-		elseif ($code == 76) return 'Cargo, Reserved for future use';
329
-		elseif ($code == 77) return 'Cargo, Reserved for future use';
330
-		elseif ($code == 78) return 'Cargo, Reserved for future use';
331
-		elseif ($code == 79) return 'Cargo, No additional information';
332
-		elseif ($code == 80) return 'Tanker, all ships of this type';
333
-		elseif ($code == 81) return 'Tanker, Hazardous category A';
334
-		elseif ($code == 82) return 'Tanker, Hazardous category B';
335
-		elseif ($code == 83) return 'Tanker, Hazardous category C';
336
-		elseif ($code == 84) return 'Tanker, Hazardous category D';
337
-		elseif ($code == 85) return 'Tanker, Reserved for future use';
338
-		elseif ($code == 86) return 'Tanker, Reserved for future use';
339
-		elseif ($code == 87) return 'Tanker, Reserved for future use';
340
-		elseif ($code == 88) return 'Tanker, Reserved for future use';
341
-		elseif ($code == 89) return 'Tanker, No additional information';
342
-		elseif ($code == 90) return 'Other Type, all ships of this type';
343
-		elseif ($code == 91) return 'Other Type, Hazardous category A';
344
-		elseif ($code == 92) return 'Other Type, Hazardous category B';
345
-		elseif ($code == 93) return 'Other Type, Hazardous category C';
346
-		elseif ($code == 94) return 'Other Type, Hazardous category D';
347
-		elseif ($code == 95) return 'Other Type, Reserved for future use';
348
-		elseif ($code == 96) return 'Other Type, Reserved for future use';
349
-		elseif ($code == 97) return 'Other Type, Reserved for future use';
350
-		elseif ($code == 98) return 'Other Type, Reserved for future use';
351
-		elseif ($code == 99) return 'Other Type, no additional information';
280
+		if ($code == 0) {
281
+			return 'Not available (default)';
282
+		} elseif ($code >= 1 && $code <= 19) {
283
+			return 'Reserved for future use';
284
+		} elseif ($code == 20) {
285
+			return 'Wing in ground (WIG), all ships of this type';
286
+		} elseif ($code == 21) {
287
+			return 'Wing in ground (WIG), Hazardous category A';
288
+		} elseif ($code == 22) {
289
+			return 'Wing in ground (WIG), Hazardous category B';
290
+		} elseif ($code == 23) {
291
+			return 'Wing in ground (WIG), Hazardous category C';
292
+		} elseif ($code == 24) {
293
+			return 'Wing in ground (WIG), Hazardous category D';
294
+		} elseif ($code == 25) {
295
+			return 'Wing in ground (WIG), Reserved for future use';
296
+		} elseif ($code == 26) {
297
+			return 'Wing in ground (WIG), Reserved for future use';
298
+		} elseif ($code == 27) {
299
+			return 'Wing in ground (WIG), Reserved for future use';
300
+		} elseif ($code == 28) {
301
+			return 'Wing in ground (WIG), Reserved for future use';
302
+		} elseif ($code == 29) {
303
+			return 'Wing in ground (WIG), Reserved for future use';
304
+		} elseif ($code == 30) {
305
+			return 'Fishing';
306
+		} elseif ($code == 31) {
307
+			return 'Towing';
308
+		} elseif ($code == 32) {
309
+			return 'Towing: length exceeds 200m or breadth exceeds 25m';
310
+		} elseif ($code == 33) {
311
+			return 'Dredging or underwater ops';
312
+		} elseif ($code == 34) {
313
+			return 'Diving ops';
314
+		} elseif ($code == 35) {
315
+			return 'Military ops';
316
+		} elseif ($code == 36) {
317
+			return 'Sailing';
318
+		} elseif ($code == 37) {
319
+			return 'Pleasure Craft';
320
+		} elseif ($code == 38) {
321
+			return 'Reserved';
322
+		} elseif ($code == 39) {
323
+			return 'Reserved';
324
+		} elseif ($code == 40) {
325
+			return 'High speed craft (HSC), all ships of this type';
326
+		} elseif ($code == 41) {
327
+			return 'High speed craft (HSC), Hazardous category A';
328
+		} elseif ($code == 42) {
329
+			return 'High speed craft (HSC), Hazardous category B';
330
+		} elseif ($code == 43) {
331
+			return 'High speed craft (HSC), Hazardous category C';
332
+		} elseif ($code == 44) {
333
+			return 'High speed craft (HSC), Hazardous category D';
334
+		} elseif ($code == 45) {
335
+			return 'High speed craft (HSC), Reserved for future use';
336
+		} elseif ($code == 46) {
337
+			return 'High speed craft (HSC), Reserved for future use';
338
+		} elseif ($code == 47) {
339
+			return 'High speed craft (HSC), Reserved for future use';
340
+		} elseif ($code == 48) {
341
+			return 'High speed craft (HSC), Reserved for future use';
342
+		} elseif ($code == 49) {
343
+			return 'High speed craft (HSC), No additional information';
344
+		} elseif ($code == 50) {
345
+			return 'Pilot Vessel';
346
+		} elseif ($code == 51) {
347
+			return 'Search and Rescue vessel';
348
+		} elseif ($code == 52) {
349
+			return 'Tug';
350
+		} elseif ($code == 53) {
351
+			return 'Port Tender';
352
+		} elseif ($code == 54) {
353
+			return 'Anti-pollution equipment';
354
+		} elseif ($code == 55) {
355
+			return 'Law Enforcement';
356
+		} elseif ($code == 56) {
357
+			return 'Spare - Local Vessel';
358
+		} elseif ($code == 57) {
359
+			return 'Spare - Local Vessel';
360
+		} elseif ($code == 58) {
361
+			return 'Medical Transport';
362
+		} elseif ($code == 59) {
363
+			return 'Noncombatant ship according to RR Resolution No. 18';
364
+		} elseif ($code == 60) {
365
+			return 'Passenger, all ships of this type';
366
+		} elseif ($code == 61) {
367
+			return 'Passenger, Hazardous category A';
368
+		} elseif ($code == 62) {
369
+			return 'Passenger, Hazardous category B';
370
+		} elseif ($code == 63) {
371
+			return 'Passenger, Hazardous category C';
372
+		} elseif ($code == 64) {
373
+			return 'Passenger, Hazardous category D';
374
+		} elseif ($code == 65) {
375
+			return 'Passenger, Reserved for future use';
376
+		} elseif ($code == 66) {
377
+			return 'Passenger, Reserved for future use';
378
+		} elseif ($code == 67) {
379
+			return 'Passenger, Reserved for future use';
380
+		} elseif ($code == 68) {
381
+			return 'Passenger, Reserved for future use';
382
+		} elseif ($code == 69) {
383
+			return 'Passenger, No additional information';
384
+		} elseif ($code == 70) {
385
+			return 'Cargo, all ships of this type';
386
+		} elseif ($code == 71) {
387
+			return 'Cargo, Hazardous category A';
388
+		} elseif ($code == 72) {
389
+			return 'Cargo, Hazardous category B';
390
+		} elseif ($code == 73) {
391
+			return 'Cargo, Hazardous category C';
392
+		} elseif ($code == 74) {
393
+			return 'Cargo, Hazardous category D';
394
+		} elseif ($code == 75) {
395
+			return 'Cargo, Reserved for future use';
396
+		} elseif ($code == 76) {
397
+			return 'Cargo, Reserved for future use';
398
+		} elseif ($code == 77) {
399
+			return 'Cargo, Reserved for future use';
400
+		} elseif ($code == 78) {
401
+			return 'Cargo, Reserved for future use';
402
+		} elseif ($code == 79) {
403
+			return 'Cargo, No additional information';
404
+		} elseif ($code == 80) {
405
+			return 'Tanker, all ships of this type';
406
+		} elseif ($code == 81) {
407
+			return 'Tanker, Hazardous category A';
408
+		} elseif ($code == 82) {
409
+			return 'Tanker, Hazardous category B';
410
+		} elseif ($code == 83) {
411
+			return 'Tanker, Hazardous category C';
412
+		} elseif ($code == 84) {
413
+			return 'Tanker, Hazardous category D';
414
+		} elseif ($code == 85) {
415
+			return 'Tanker, Reserved for future use';
416
+		} elseif ($code == 86) {
417
+			return 'Tanker, Reserved for future use';
418
+		} elseif ($code == 87) {
419
+			return 'Tanker, Reserved for future use';
420
+		} elseif ($code == 88) {
421
+			return 'Tanker, Reserved for future use';
422
+		} elseif ($code == 89) {
423
+			return 'Tanker, No additional information';
424
+		} elseif ($code == 90) {
425
+			return 'Other Type, all ships of this type';
426
+		} elseif ($code == 91) {
427
+			return 'Other Type, Hazardous category A';
428
+		} elseif ($code == 92) {
429
+			return 'Other Type, Hazardous category B';
430
+		} elseif ($code == 93) {
431
+			return 'Other Type, Hazardous category C';
432
+		} elseif ($code == 94) {
433
+			return 'Other Type, Hazardous category D';
434
+		} elseif ($code == 95) {
435
+			return 'Other Type, Reserved for future use';
436
+		} elseif ($code == 96) {
437
+			return 'Other Type, Reserved for future use';
438
+		} elseif ($code == 97) {
439
+			return 'Other Type, Reserved for future use';
440
+		} elseif ($code == 98) {
441
+			return 'Other Type, Reserved for future use';
442
+		} elseif ($code == 99) {
443
+			return 'Other Type, no additional information';
444
+		}
352 445
 	}
353 446
 
354 447
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -386,19 +479,34 @@  discard block
 block discarded – undo
386 479
 		// assume 1st ! is valid
387 480
 		// find * ensure that it is at correct position
388 481
 		$end = strrpos ( $rawdata , '*' );
389
-		if ($end === FALSE) return -1; // check for NULLS!!!
482
+		if ($end === FALSE) {
483
+			return -1;
484
+		}
485
+		// check for NULLS!!!
390 486
 		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
487
+		if ( strlen($cs) != 2 ) {
488
+			return -1;
489
+		}
490
+		// correct cs length
392 491
 		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
492
+		for ( $alias=1; $alias<$end; $alias++) {
493
+			$chksum ^= ord( $rawdata[$alias] );
494
+		}
495
+		// perform XOR for NMEA checksum
394 496
 		if ( $chksum == $dcs ) { // NMEA checksum pass
395 497
 			$pcs = explode(',', $rawdata);
396 498
 			// !AI??? identifier
397 499
 			$num_seq = (int)$pcs[1]; // number of sequences
398 500
 			$seq = (int)$pcs[2]; // get sequence
399 501
 			// get msg sequence id
400
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
401
-			else $msg_sid = (int)$pcs[3]; // multipart message
502
+			if ($pcs[3] == '') {
503
+				$msg_sid = -1;
504
+			}
505
+			// non-multipart message, set to -1
506
+			else {
507
+				$msg_sid = (int)$pcs[3];
508
+			}
509
+			// multipart message
402 510
 			$ais_ch = $pcs[4]; // get AIS channel
403 511
 			// message sequence checking
404 512
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -459,10 +567,18 @@  discard block
 block discarded – undo
459 567
 				//DEBUG echo "[$start $end $tst]\n";
460 568
 				$result = $this->process_ais_raw( $tst, "" );
461 569
 				$last_pos = $end + 1;
462
-			} else break;
570
+			} else {
571
+				break;
572
+			}
573
+		}
574
+		if ($last_pos > 0) {
575
+			$cbuf = substr($cbuf, $last_pos);
463 576
 		}
464
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
465
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
577
+		// move...
578
+		if (strlen($cbuf) > 1024) {
579
+			$cbuf = "";
580
+		}
581
+		// prevent overflow simple mode...
466 582
 		return $result;
467 583
 	}
468 584
 
@@ -482,7 +598,9 @@  discard block
 block discarded – undo
482 598
 		if ($lat<0.0) {
483 599
 			$lat = -$lat;
484 600
 			$neg=true;
485
-		} else $neg=false;
601
+		} else {
602
+			$neg=false;
603
+		}
486 604
 		$latd = 0x00000000;
487 605
 		$latd = intval ($lat * 600000.0);
488 606
 		if ($neg==true) {
@@ -498,7 +616,9 @@  discard block
 block discarded – undo
498 616
 		if ($lon<0.0) {
499 617
 			$lon = -$lon;
500 618
 			$neg=true;
501
-		} else $neg=false;
619
+		} else {
620
+			$neg=false;
621
+		}
502 622
 		$lond = 0x00000000;
503 623
 		$lond = intval ($lon * 600000.0);
504 624
 		if ($neg==true) {
@@ -511,9 +631,14 @@  discard block
 block discarded – undo
511 631
 
512 632
 	private function char2bin($name, $max_len) {
513 633
 		$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);
516
-		else $pad = '';
634
+		if ($len > $max_len) {
635
+			$name = substr($name,0,$max_len);
636
+		}
637
+		if ($len < $max_len) {
638
+			$pad = str_repeat('0', ($max_len - $len) * 6);
639
+		} else {
640
+			$pad = '';
641
+		}
517 642
 		$rv = '';
518 643
 		$ais_chars = array(
519 644
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -526,9 +651,12 @@  discard block
 block discarded – undo
526 651
 		);
527 652
 		// "
528 653
 		$_a = str_split($name);
529
-		if ($_a) foreach ($_a as $_1) {
654
+		if ($_a) {
655
+			foreach ($_a as $_1) {
530 656
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
531
-			else $dec = 0;
657
+		} else {
658
+				$dec = 0;
659
+			}
532 660
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
533 661
 			$rv .= $bin;
534 662
 			//echo "$_1 $dec ($bin)<br/>";
@@ -540,7 +668,9 @@  discard block
 block discarded – undo
540 668
 		$len_bit = strlen($_enc);
541 669
 		$rem6 = $len_bit % 6;
542 670
 		$pad6_len = 0;
543
-		if ($rem6) $pad6_len = 6 - $rem6;
671
+		if ($rem6) {
672
+			$pad6_len = 6 - $rem6;
673
+		}
544 674
 		//echo  $pad6_len.'<br>';
545 675
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
546 676
 		$len_enc = strlen($_enc) / 6;
@@ -549,8 +679,11 @@  discard block
 block discarded – undo
549 679
 		for ($i=0; $i<$len_enc; $i++) {
550 680
 			$offset = $i * 6;
551 681
 			$dec = bindec(substr($_enc,$offset,6));
552
-			if ($dec < 40) $dec += 48;
553
-			else $dec += 56;
682
+			if ($dec < 40) {
683
+				$dec += 48;
684
+			} else {
685
+				$dec += 56;
686
+			}
554 687
 			//echo chr($dec)." $dec<br/>";
555 688
 			$itu .= chr($dec);
556 689
 		}
@@ -563,25 +696,41 @@  discard block
 block discarded – undo
563 696
 		}
564 697
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
565 698
 		$lsb = $chksum & 0x0F;
566
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
567
-		else $lsbc = '0';
699
+		if ($lsb >=0 && $lsb <= 15 ) {
700
+			$lsbc = $hex_arr[$lsb];
701
+		} else {
702
+			$lsbc = '0';
703
+		}
568 704
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
569
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
570
-		else $msbc = '0';
705
+		if ($msb >=0 && $msb <= 15 ) {
706
+			$msbc = $hex_arr[$msb];
707
+		} else {
708
+			$msbc = '0';
709
+		}
571 710
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
572 711
 		return $itu;
573 712
 	}
574 713
 
575 714
 	public function parse($buffer) {
576 715
 		$data = $this->process_ais_buf($buffer);
577
-		if (!is_object($data)) return array();
578
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
579
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
716
+		if (!is_object($data)) {
717
+			return array();
718
+		}
719
+		if ($data->lon != 0) {
720
+			$result['longitude'] = $data->lon;
721
+		}
722
+		if ($data->lat != 0) {
723
+			$result['latitude'] = $data->lat;
724
+		}
580 725
 		$result['ident'] = trim($data->name);
581 726
 		$result['timestamp'] = $data->ts;
582 727
 		$result['mmsi'] = $data->mmsi;
583
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
584
-		if ($data->cog != 0) $result['heading'] = $data->cog;
728
+		if ($data->sog != -1.0) {
729
+			$result['speed'] = $data->sog;
730
+		}
731
+		if ($data->cog != 0) {
732
+			$result['heading'] = $data->cog;
733
+		}
585 734
 		/*
586 735
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
587 736
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -591,15 +740,25 @@  discard block
 block discarded – undo
591 740
 
592 741
 	public function mmsitype($mmsi) {
593 742
 		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';
602
-			else return 'Ship';
743
+			if (substr($mmsi,0,3) == '974') {
744
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
745
+			} elseif (substr($mmsi,0,3) == '972') {
746
+				return 'MOB (Man Overboard) device';
747
+			} elseif (substr($mmsi,0,3) == '970') {
748
+				return 'AIS SART (Search and Rescue Transmitter)';
749
+			} elseif (substr($mmsi,0,3) == '111') {
750
+				return 'SAR (Search and Rescue) aircraft';
751
+			} elseif (substr($mmsi,0,2) == '98') {
752
+				return 'Auxiliary craft associated with a parent ship';
753
+			} elseif (substr($mmsi,0,2) == '99') {
754
+				return 'Aids to Navigation';
755
+			} elseif (substr($mmsi,0,2) == '00') {
756
+				return 'Coastal stations';
757
+			} elseif (substr($mmsi,0,1) == '0') {
758
+				return 'Group of ships';
759
+			} else {
760
+				return 'Ship';
761
+			}
603 762
 		}
604 763
 
605 764
 	
@@ -616,25 +775,48 @@  discard block
 block discarded – undo
616 775
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
617 776
 			return array();
618 777
 		}
619
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
620
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
778
+		if ($data->lon != 0) {
779
+			$result['longitude'] = $data->lon;
780
+		}
781
+		if ($data->lat != 0) {
782
+			$result['latitude'] = $data->lat;
783
+		}
621 784
 		$result['ident'] = trim(str_replace('@','',$data->name));
622 785
 		$result['timestamp'] = $data->ts;
623 786
 		$result['mmsi'] = $data->mmsi;
624
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
787
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
788
+			$result['mmsi'] = '3'.$result['mmsi'];
789
+		}
625 790
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
626
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
627
-		if ($data->heading != '') $result['heading'] = $data->heading;
628
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
629
-		if ($data->status != '') $result['status'] = $data->status;
630
-		if ($data->type != '') $result['type'] = $data->type;
631
-		if ($data->typeid != '') $result['typeid'] = $data->typeid;
632
-		if ($data->imo != '') $result['imo'] = $data->imo;
633
-		if ($data->callsign != '') $result['callsign'] = $data->callsign;
791
+		if ($data->sog != -1.0) {
792
+			$result['speed'] = $data->sog;
793
+		}
794
+		if ($data->heading != '') {
795
+			$result['heading'] = $data->heading;
796
+		} elseif ($data->cog != 0) {
797
+			$result['heading'] = $data->cog;
798
+		}
799
+		if ($data->status != '') {
800
+			$result['status'] = $data->status;
801
+		}
802
+		if ($data->type != '') {
803
+			$result['type'] = $data->type;
804
+		}
805
+		if ($data->typeid != '') {
806
+			$result['typeid'] = $data->typeid;
807
+		}
808
+		if ($data->imo != '') {
809
+			$result['imo'] = $data->imo;
810
+		}
811
+		if ($data->callsign != '') {
812
+			$result['callsign'] = $data->callsign;
813
+		}
634 814
 		if ($data->eta_month != '' && $data->eta_day != '' && $data->eta_hour != '' && $data->eta_minute != '') {
635 815
 			$result['eta_ts'] = strtotime(date('Y').'-'.$data->eta_month.'-'.$data->eta_day.' '.$data->eta_hour.':'.$data->eta_minute.':00');
636 816
 		}
637
-		if ($data->destination != '') $result['destination'] = $data->destination;
817
+		if ($data->destination != '') {
818
+			$result['destination'] = $data->destination;
819
+		}
638 820
 		$result['all'] = (array) $data;
639 821
 		/*
640 822
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
Please login to merge, or discard this patch.
require/class.Common.php 4 patches
Doc Comments   +12 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,6 +90,10 @@  discard block
 block discarded – undo
90 90
 		return strlen($headerLine); // Needed by curl
91 91
 	}
92 92
 
93
+	/**
94
+	 * @param string $url
95
+	 * @param string $file
96
+	 */
93 97
 	public static function download($url, $file, $referer = '') {
94 98
 		global $globalDebug;
95 99
 		$fp = fopen($file, 'w');
@@ -190,7 +194,7 @@  discard block
 block discarded – undo
190 194
 	* Check is distance realistic
191 195
 	* @param int $timeDifference the time between the reception of both messages
192 196
 	* @param float $distance distance covered
193
-	* @return whether distance is realistic
197
+	* @return boolean distance is realistic
194 198
 	*/
195 199
 	public function withinThreshold ($timeDifference, $distance) {
196 200
 		$x = abs($timeDifference);
@@ -213,6 +217,9 @@  discard block
 block discarded – undo
213 217
 	}
214 218
 
215 219
 
220
+	/**
221
+	 * @param string $latlong
222
+	 */
216 223
 	public function convertDec($dms,$latlong) {
217 224
 		if ($latlong == 'latitude') {
218 225
 			$deg = substr($dms, 0, 2);
@@ -224,6 +231,9 @@  discard block
 block discarded – undo
224 231
 		return $deg+(($min*60)/3600);
225 232
 	}
226 233
 	
234
+	/**
235
+	 * @param string $latlong
236
+	 */
227 237
 	public function convertDM($coord,$latlong) {
228 238
 		if ($latlong == 'latitude') {
229 239
 			if ($coord < 0) $NSEW = 'S';
@@ -352,7 +362,7 @@  discard block
 block discarded – undo
352 362
 	/**
353 363
 	* Returns list of available locales
354 364
 	*
355
-	* @return array
365
+	* @return string[]
356 366
 	 */
357 367
 	public function listLocaleDir()
358 368
 	{
Please login to merge, or discard this patch.
Braces   +73 added lines, -30 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
 	private function curlResponseHeaderCallback($ch, $headerLine) {
86 89
 		//global $cookies;
87 90
 		$cookies = array();
88
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
89
-			$cookies[] = $cookie;
91
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
92
+					$cookies[] = $cookie;
93
+		}
90 94
 		return strlen($headerLine); // Needed by curl
91 95
 	}
92 96
 
@@ -97,11 +101,15 @@  discard block
 block discarded – undo
97 101
 		curl_setopt($ch, CURLOPT_URL, $url);
98 102
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
99 103
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
100
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
104
+		if ($referer != '') {
105
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
106
+		}
101 107
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
102 108
 		curl_setopt($ch, CURLOPT_FILE, $fp);
103 109
 		curl_exec($ch);
104
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
110
+		if (curl_errno($ch) && $globalDebug) {
111
+			echo 'Download error: '.curl_error($ch);
112
+		}
105 113
 		curl_close($ch);
106 114
 		fclose($fp);
107 115
 	}
@@ -112,10 +120,16 @@  discard block
 block discarded – undo
112 120
 	* @return Array array of the tables in HTML page
113 121
 	*/
114 122
 	public function table2array($data) {
115
-		if (!is_string($data)) return array();
116
-		if ($data == '') return array();
123
+		if (!is_string($data)) {
124
+			return array();
125
+		}
126
+		if ($data == '') {
127
+			return array();
128
+		}
117 129
 		$html = str_get_html($data);
118
-		if ($html === false) return array();
130
+		if ($html === false) {
131
+			return array();
132
+		}
119 133
 		$tabledata=array();
120 134
 		foreach($html->find('tr') as $element)
121 135
 		{
@@ -150,7 +164,9 @@  discard block
 block discarded – undo
150 164
 	*/
151 165
 	public function text2array($data) {
152 166
 		$html = str_get_html($data);
153
-		if ($html === false) return array();
167
+		if ($html === false) {
168
+			return array();
169
+		}
154 170
 		$tabledata=array();
155 171
 		foreach($html->find('p') as $element)
156 172
 		{
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 	* @return Float Distance in $unit
172 188
 	*/
173 189
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174
-		if ($lat == $latc && $lon == $lonc) return 0;
190
+		if ($lat == $latc && $lon == $lonc) {
191
+			return 0;
192
+		}
175 193
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
176 194
 		if ($unit == "km") {
177 195
 			return round($dist * 1.609344);
@@ -195,10 +213,16 @@  discard block
 block discarded – undo
195 213
 	public function withinThreshold ($timeDifference, $distance) {
196 214
 		$x = abs($timeDifference);
197 215
 		$d = abs($distance);
198
-		if ($x == 0 || $d == 0) return true;
216
+		if ($x == 0 || $d == 0) {
217
+			return true;
218
+		}
199 219
 		// may be due to Internet jitter; distance is realistic
200
-		if ($x < 0.7 && $d < 2000) return true;
201
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
220
+		if ($x < 0.7 && $d < 2000) {
221
+			return true;
222
+		} else {
223
+			return $d/$x < 1500*0.27778;
224
+		}
225
+		// 1500 km/h max
202 226
 	}
203 227
 
204 228
 
@@ -226,11 +250,17 @@  discard block
 block discarded – undo
226 250
 	
227 251
 	public function convertDM($coord,$latlong) {
228 252
 		if ($latlong == 'latitude') {
229
-			if ($coord < 0) $NSEW = 'S';
230
-			else $NSEW = 'N';
253
+			if ($coord < 0) {
254
+				$NSEW = 'S';
255
+			} else {
256
+				$NSEW = 'N';
257
+			}
231 258
 		} elseif ($latlong == 'longitude') {
232
-			if ($coord < 0) $NSEW = 'W';
233
-			else $NSEW = 'E';
259
+			if ($coord < 0) {
260
+				$NSEW = 'W';
261
+			} else {
262
+				$NSEW = 'E';
263
+			}
234 264
 		}
235 265
 		$coord = abs($coord);
236 266
 		$deg = floor($coord);
@@ -273,7 +303,9 @@  discard block
 block discarded – undo
273 303
 	public function hex2str($hex) {
274 304
 		$str = '';
275 305
 		$hexln = strlen($hex);
276
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
306
+		for($i=0;$i<$hexln;$i+=2) {
307
+			$str .= chr(hexdec(substr($hex,$i,2)));
308
+		}
277 309
 		return $str;
278 310
 	}
279 311
 	
@@ -301,8 +333,11 @@  discard block
 block discarded – undo
301 333
 		$b = $lat2 - $lat1;
302 334
 		$c = -($a*$lat1+$b*$lon1);
303 335
 		$d = $a*$lat3+$b*$lon3+$c;
304
-		if ($d > -$approx && $d < $approx) return true;
305
-		else return false;
336
+		if ($d > -$approx && $d < $approx) {
337
+			return true;
338
+		} else {
339
+			return false;
340
+		}
306 341
 	}
307 342
 	
308 343
 	public function array_merge_noappend() {
@@ -361,7 +396,9 @@  discard block
 block discarded – undo
361 396
 			return $result;
362 397
 		}
363 398
 		$handle = @opendir('./locale');
364
-		if ($handle === false) return $result;
399
+		if ($handle === false) {
400
+			return $result;
401
+		}
365 402
 		while (false !== ($file = readdir($handle))) {
366 403
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
367 404
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -428,8 +465,9 @@  discard block
 block discarded – undo
428 465
 		$error = false; 
429 466
 		if ($fp_out = gzopen($dest, $mode)) { 
430 467
 			if ($fp_in = fopen($source,'rb')) { 
431
-				while (!feof($fp_in)) 
432
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
468
+				while (!feof($fp_in)) {
469
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
470
+				}
433 471
 				fclose($fp_in); 
434 472
 			} else {
435 473
 				$error = true; 
@@ -438,14 +476,17 @@  discard block
 block discarded – undo
438 476
 		} else {
439 477
 			$error = true; 
440 478
 		}
441
-		if ($error)
442
-			return false; 
443
-		else
444
-			return $dest; 
479
+		if ($error) {
480
+					return false;
481
+		} else {
482
+					return $dest;
483
+		}
445 484
 	} 
446 485
 	
447 486
 	public function remove_accents($string) {
448
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
487
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
488
+			return $string;
489
+		}
449 490
 		$chars = array(
450 491
 		    // Decompositions for Latin-1 Supplement
451 492
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -569,7 +610,9 @@  discard block
 block discarded – undo
569 610
 		$ip = gethostbyname($host);
570 611
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
571 612
 		$r = @socket_connect($s, $ip, $port);
572
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
613
+		if (!socket_set_nonblock($s)) {
614
+			echo "Unable to set nonblock on socket\n";
615
+		}
573 616
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
574 617
 			return $s;
575 618
 		}
Please login to merge, or discard this patch.
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 	//protected $cookies = array();
8 8
 	
9 9
 	/**
10
-	* Get data from form result
11
-	* @param String $url form URL
12
-	* @param String $type type of submit form method (get or post)
13
-	* @param String|Array $data values form post method
14
-	* @param Array $headers header to submit with the form
15
-	* @return String the result
16
-	*/
10
+	 * Get data from form result
11
+	 * @param String $url form URL
12
+	 * @param String $type type of submit form method (get or post)
13
+	 * @param String|Array $data values form post method
14
+	 * @param Array $headers header to submit with the form
15
+	 * @return String the result
16
+	 */
17 17
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 	}
108 108
 	
109 109
 	/**
110
-	* Convert a HTML table to an array
111
-	* @param String $data HTML page
112
-	* @return Array array of the tables in HTML page
113
-	*/
110
+	 * Convert a HTML table to an array
111
+	 * @param String $data HTML page
112
+	 * @return Array array of the tables in HTML page
113
+	 */
114 114
 	public function table2array($data) {
115 115
 		if (!is_string($data)) return array();
116 116
 		if ($data == '') return array();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 	
146 146
 	/**
147
-	* Convert <p> part of a HTML page to an array
148
-	* @param String $data HTML page
149
-	* @return Array array of the <p> in HTML page
150
-	*/
147
+	 * Convert <p> part of a HTML page to an array
148
+	 * @param String $data HTML page
149
+	 * @return Array array of the <p> in HTML page
150
+	 */
151 151
 	public function text2array($data) {
152 152
 		$html = str_get_html($data);
153 153
 		if ($html === false) return array();
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 	}
163 163
 
164 164
 	/**
165
-	* Give distance between 2 coordonnates
166
-	* @param Float $lat latitude of first point
167
-	* @param Float $lon longitude of first point
168
-	* @param Float $latc latitude of second point
169
-	* @param Float $lonc longitude of second point
170
-	* @param String $unit km else no unit used
171
-	* @return Float Distance in $unit
172
-	*/
165
+	 * Give distance between 2 coordonnates
166
+	 * @param Float $lat latitude of first point
167
+	 * @param Float $lon longitude of first point
168
+	 * @param Float $latc latitude of second point
169
+	 * @param Float $lonc longitude of second point
170
+	 * @param String $unit km else no unit used
171
+	 * @return Float Distance in $unit
172
+	 */
173 173
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174 174
 		if ($lat == $latc && $lon == $lonc) return 0;
175 175
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 	}
188 188
 
189 189
 	/**
190
-	* Check is distance realistic
191
-	* @param int $timeDifference the time between the reception of both messages
192
-	* @param float $distance distance covered
193
-	* @return whether distance is realistic
194
-	*/
190
+	 * Check is distance realistic
191
+	 * @param int $timeDifference the time between the reception of both messages
192
+	 * @param float $distance distance covered
193
+	 * @return whether distance is realistic
194
+	 */
195 195
 	public function withinThreshold ($timeDifference, $distance) {
196 196
 		$x = abs($timeDifference);
197 197
 		$d = abs($distance);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 	public function isInteger($input){
212
-	    return(ctype_digit(strval($input)));
212
+		return(ctype_digit(strval($input)));
213 213
 	}
214 214
 
215 215
 
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 	
242 242
 	/**
243
-	* Copy folder contents
244
-	* @param       string   $source    Source path
245
-	* @param       string   $dest      Destination path
246
-	* @return      bool     Returns true on success, false on failure
247
-	*/
243
+	 * Copy folder contents
244
+	 * @param       string   $source    Source path
245
+	 * @param       string   $dest      Destination path
246
+	 * @return      bool     Returns true on success, false on failure
247
+	 */
248 248
 	public function xcopy($source, $dest)
249 249
 	{
250 250
 		$files = glob($source.'*.*');
@@ -256,20 +256,20 @@  discard block
 block discarded – undo
256 256
 	}
257 257
 	
258 258
 	/**
259
-	* Check if an url exist
260
-	* @param	String $url url to check
261
-	* @return	bool Return true on succes false on failure
262
-	*/
259
+	 * Check if an url exist
260
+	 * @param	String $url url to check
261
+	 * @return	bool Return true on succes false on failure
262
+	 */
263 263
 	public function urlexist($url){
264 264
 		$headers=get_headers($url);
265 265
 		return stripos($headers[0],"200 OK")?true:false;
266 266
 	}
267 267
 	
268 268
 	/**
269
-	* Convert hexa to string
270
-	* @param	String $hex data in hexa
271
-	* @return	String Return result
272
-	*/
269
+	 * Convert hexa to string
270
+	 * @param	String $hex data in hexa
271
+	 * @return	String Return result
272
+	 */
273 273
 	public function hex2str($hex) {
274 274
 		$str = '';
275 275
 		$hexln = strlen($hex);
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 	}
279 279
 	
280 280
 	/**
281
-	* Convert hexa color to rgb
282
-	* @param	String $hex data in hexa
283
-	* @return	String Return result
284
-	*/
281
+	 * Convert hexa color to rgb
282
+	 * @param	String $hex data in hexa
283
+	 * @return	String Return result
284
+	 */
285 285
 	public function hex2rgb($hex) {
286 286
 		$hex = str_replace('#','',$hex);
287 287
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 	
361 361
 	/**
362
-	* Returns list of available locales
363
-	*
364
-	* @return array
362
+	 * Returns list of available locales
363
+	 *
364
+	 * @return array
365 365
 	 */
366 366
 	public function listLocaleDir()
367 367
 	{
@@ -456,100 +456,100 @@  discard block
 block discarded – undo
456 456
 	public function remove_accents($string) {
457 457
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
458 458
 		$chars = array(
459
-		    // Decompositions for Latin-1 Supplement
460
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
461
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
462
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
463
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
464
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
465
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
466
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
467
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
468
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
469
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
470
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
471
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
472
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
473
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
474
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
475
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
476
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
477
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
478
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
479
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
480
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
481
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
482
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
483
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
484
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
485
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
486
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
487
-		    chr(195).chr(191) => 'y',
488
-		    // Decompositions for Latin Extended-A
489
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
490
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
491
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
492
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
493
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
494
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
495
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
496
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
497
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
498
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
499
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
500
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
501
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
502
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
503
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
504
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
505
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
506
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
507
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
508
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
509
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
510
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
511
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
512
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
513
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
514
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
515
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
516
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
517
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
518
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
519
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
520
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
521
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
522
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
523
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
524
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
525
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
526
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
527
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
528
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
529
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
530
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
531
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
532
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
533
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
534
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
535
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
536
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
537
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
538
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
539
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
540
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
541
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
542
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
543
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
544
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
545
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
546
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
547
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
548
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
549
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
550
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
551
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
552
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
459
+			// Decompositions for Latin-1 Supplement
460
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
461
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
462
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
463
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
464
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
465
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
466
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
467
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
468
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
469
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
470
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
471
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
472
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
473
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
474
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
475
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
476
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
477
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
478
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
479
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
480
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
481
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
482
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
483
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
484
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
485
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
486
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
487
+			chr(195).chr(191) => 'y',
488
+			// Decompositions for Latin Extended-A
489
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
490
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
491
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
492
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
493
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
494
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
495
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
496
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
497
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
498
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
499
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
500
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
501
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
502
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
503
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
504
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
505
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
506
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
507
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
508
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
509
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
510
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
511
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
512
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
513
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
514
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
515
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
516
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
517
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
518
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
519
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
520
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
521
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
522
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
523
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
524
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
525
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
526
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
527
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
528
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
529
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
530
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
531
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
532
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
533
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
534
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
535
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
536
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
537
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
538
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
539
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
540
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
541
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
542
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
543
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
544
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
545
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
546
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
547
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
548
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
549
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
550
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
551
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
552
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
553 553
 		);
554 554
 		$string = strtr($string, $chars);
555 555
 		return $string;
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 		$info = curl_getinfo($ch);
70 70
 		//var_dump($info);
71 71
 		curl_close($ch);
72
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
72
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
73 73
 			echo "Cloudflare Detected\n";
74 74
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
75 75
 			$useragent = UAgent::random();
76 76
 			cloudflare::useUserAgent($useragent);
77 77
 			if ($clearanceCookie = cloudflare::bypass($url)) {
78
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
78
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
79 79
 			}
80 80
 		} else {
81 81
 			return $result;
@@ -116,27 +116,27 @@  discard block
 block discarded – undo
116 116
 		if ($data == '') return array();
117 117
 		$html = str_get_html($data);
118 118
 		if ($html === false) return array();
119
-		$tabledata=array();
120
-		foreach($html->find('tr') as $element)
119
+		$tabledata = array();
120
+		foreach ($html->find('tr') as $element)
121 121
 		{
122 122
 			$td = array();
123
-			foreach( $element->find('th') as $row)
123
+			foreach ($element->find('th') as $row)
124 124
 			{
125 125
 				$td [] = trim($row->plaintext);
126 126
 			}
127
-			$td=array_filter($td);
127
+			$td = array_filter($td);
128 128
 			$tabledata[] = $td;
129 129
 
130 130
 			$td = array();
131 131
 			$tdi = array();
132
-			foreach( $element->find('td') as $row)
132
+			foreach ($element->find('td') as $row)
133 133
 			{
134 134
 				$td [] = trim($row->plaintext);
135 135
 				$tdi [] = trim($row->innertext);
136 136
 			}
137
-			$td=array_filter($td);
138
-			$tdi=array_filter($tdi);
139
-			$tabledata[]=array_merge($td,$tdi);
137
+			$td = array_filter($td);
138
+			$tdi = array_filter($tdi);
139
+			$tabledata[] = array_merge($td, $tdi);
140 140
 		}
141 141
 		$html->clear();
142 142
 		unset($html);
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	public function text2array($data) {
152 152
 		$html = str_get_html($data);
153 153
 		if ($html === false) return array();
154
-		$tabledata=array();
155
-		foreach($html->find('p') as $element)
154
+		$tabledata = array();
155
+		foreach ($html->find('p') as $element)
156 156
 		{
157 157
 			$tabledata [] = trim($element->plaintext);
158 158
 		}
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	*/
173 173
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174 174
 		if ($lat == $latc && $lon == $lonc) return 0;
175
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
175
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
176 176
 		if ($unit == "km") {
177
-			return round($dist * 1.609344);
177
+			return round($dist*1.609344);
178 178
 		} elseif ($unit == "m") {
179
-			return round($dist * 1.609344 * 1000);
179
+			return round($dist*1.609344*1000);
180 180
 		} elseif ($unit == "mile" || $unit == "mi") {
181 181
 			return round($dist);
182 182
 		} elseif ($unit == "nm") {
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	* @param float $distance distance covered
193 193
 	* @return whether distance is realistic
194 194
 	*/
195
-	public function withinThreshold ($timeDifference, $distance) {
195
+	public function withinThreshold($timeDifference, $distance) {
196 196
 		$x = abs($timeDifference);
197 197
 		$d = abs($distance);
198 198
 		if ($x == 0 || $d == 0) return true;
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
 		return ($array !== array_values($array));
209 209
 	}
210 210
 
211
-	public function isInteger($input){
211
+	public function isInteger($input) {
212 212
 	    return(ctype_digit(strval($input)));
213 213
 	}
214 214
 
215 215
 
216
-	public function convertDec($dms,$latlong) {
216
+	public function convertDec($dms, $latlong) {
217 217
 		if ($latlong == 'latitude') {
218 218
 			$deg = substr($dms, 0, 2);
219 219
 			$min = substr($dms, 2, 4);
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 			$deg = substr($dms, 0, 3);
222 222
 			$min = substr($dms, 3, 5);
223 223
 		}
224
-		return $deg+(($min*60)/3600);
224
+		return $deg + (($min*60)/3600);
225 225
 	}
226 226
 	
227
-	public function convertDM($coord,$latlong) {
227
+	public function convertDM($coord, $latlong) {
228 228
 		if ($latlong == 'latitude') {
229 229
 			if ($coord < 0) $NSEW = 'S';
230 230
 			else $NSEW = 'N';
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 		}
235 235
 		$coord = abs($coord);
236 236
 		$deg = floor($coord);
237
-		$coord = ($coord-$deg)*60;
237
+		$coord = ($coord - $deg)*60;
238 238
 		$min = $coord;
239
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
239
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
240 240
 	}
241 241
 	
242 242
 	/**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	public function xcopy($source, $dest)
249 249
 	{
250 250
 		$files = glob($source.'*.*');
251
-		foreach($files as $file){
252
-			$file_to_go = str_replace($source,$dest,$file);
251
+		foreach ($files as $file) {
252
+			$file_to_go = str_replace($source, $dest, $file);
253 253
 			copy($file, $file_to_go);
254 254
 		}
255 255
 		return true;
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	* @param	String $url url to check
261 261
 	* @return	bool Return true on succes false on failure
262 262
 	*/
263
-	public function urlexist($url){
264
-		$headers=get_headers($url);
265
-		return stripos($headers[0],"200 OK")?true:false;
263
+	public function urlexist($url) {
264
+		$headers = get_headers($url);
265
+		return stripos($headers[0], "200 OK") ? true : false;
266 266
 	}
267 267
 	
268 268
 	/**
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	public function hex2str($hex) {
274 274
 		$str = '';
275 275
 		$hexln = strlen($hex);
276
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
276
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
277 277
 		return $str;
278 278
 	}
279 279
 	
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	* @return	String Return result
284 284
 	*/
285 285
 	public function hex2rgb($hex) {
286
-		$hex = str_replace('#','',$hex);
286
+		$hex = str_replace('#', '', $hex);
287 287
 		return sscanf($hex, "%02x%02x%02x"); 
288 288
 	}
289 289
 	
@@ -291,33 +291,33 @@  discard block
 block discarded – undo
291 291
 		//difference in longitudinal coordinates
292 292
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
293 293
 		//difference in the phi of latitudinal coordinates
294
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
294
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
295 295
 		//we need to recalculate $dLon if it is greater than pi
296
-		if(abs($dLon) > pi()) {
297
-			if($dLon > 0) {
298
-				$dLon = (2 * pi() - $dLon) * -1;
296
+		if (abs($dLon) > pi()) {
297
+			if ($dLon > 0) {
298
+				$dLon = (2*pi() - $dLon)*-1;
299 299
 			} else {
300
-				$dLon = 2 * pi() + $dLon;
300
+				$dLon = 2*pi() + $dLon;
301 301
 			}
302 302
 		}
303 303
 		//return the angle, normalized
304
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
304
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
305 305
 	}
306 306
 	
307
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) {
307
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) {
308 308
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
309
-		$a = -($lon2-$lon1);
309
+		$a = -($lon2 - $lon1);
310 310
 		$b = $lat2 - $lat1;
311
-		$c = -($a*$lat1+$b*$lon1);
312
-		$d = $a*$lat3+$b*$lon3+$c;
311
+		$c = -($a*$lat1 + $b*$lon1);
312
+		$d = $a*$lat3 + $b*$lon3 + $c;
313 313
 		if ($d > -$approx && $d < $approx) return true;
314 314
 		else return false;
315 315
 	}
316 316
 	
317 317
 	public function array_merge_noappend() {
318 318
 		$output = array();
319
-		foreach(func_get_args() as $array) {
320
-			foreach($array as $key => $value) {
319
+		foreach (func_get_args() as $array) {
320
+			foreach ($array as $key => $value) {
321 321
 				$output[$key] = isset($output[$key]) ?
322 322
 				array_merge($output[$key], $value) : $value;
323 323
 			}
@@ -381,34 +381,34 @@  discard block
 block discarded – undo
381 381
 		return $result;
382 382
 	}
383 383
 
384
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){
384
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) {
385 385
 		global $globalMapRefresh;
386 386
 		$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
387 387
 		$r = 6378;
388 388
 		$latitude = deg2rad($latitude);
389 389
 		$longitude = deg2rad($longitude);
390 390
 		$bearing = deg2rad($heading); 
391
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
392
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
393
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
391
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
392
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
393
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
394 394
 	}
395 395
 	
396
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
396
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
397 397
 		// distance in meter
398 398
 		$R = 6378.14;
399
-		$latitude1 = $latitude * (M_PI/180);
400
-		$longitude1 = $longitude * (M_PI/180);
401
-		$brng = $bearing * (M_PI/180);
399
+		$latitude1 = $latitude*(M_PI/180);
400
+		$longitude1 = $longitude*(M_PI/180);
401
+		$brng = $bearing*(M_PI/180);
402 402
 		$d = $distance;
403 403
 
404 404
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
405
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
405
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
406 406
 
407
-		$latitude2 = $latitude2 * (180/M_PI);
408
-		$longitude2 = $longitude2 * (180/M_PI);
407
+		$latitude2 = $latitude2*(180/M_PI);
408
+		$longitude2 = $longitude2*(180/M_PI);
409 409
 
410
-		$flat = round ($latitude2,6);
411
-		$flong = round ($longitude2,6);
410
+		$flat = round($latitude2, 6);
411
+		$flong = round($longitude2, 6);
412 412
 /*
413 413
 		$dx = $distance*cos($bearing);
414 414
 		$dy = $distance*sin($bearing);
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 		$flong = $longitude + $dlong;
418 418
 		$flat = $latitude + $dlat;
419 419
 */
420
-		return array('latitude' => $flat,'longitude' => $flong);
420
+		return array('latitude' => $flat, 'longitude' => $flong);
421 421
 	}
422 422
 
423 423
 	/**
@@ -431,14 +431,14 @@  discard block
 block discarded – undo
431 431
 	 * @param integer $level GZIP compression level (default: 9)
432 432
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
433 433
 	 */
434
-	public function gzCompressFile($source, $level = 9){ 
435
-		$dest = $source . '.gz'; 
436
-		$mode = 'wb' . $level; 
434
+	public function gzCompressFile($source, $level = 9) { 
435
+		$dest = $source.'.gz'; 
436
+		$mode = 'wb'.$level; 
437 437
 		$error = false; 
438 438
 		if ($fp_out = gzopen($dest, $mode)) { 
439
-			if ($fp_in = fopen($source,'rb')) { 
439
+			if ($fp_in = fopen($source, 'rb')) { 
440 440
 				while (!feof($fp_in)) 
441
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
441
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
442 442
 				fclose($fp_in); 
443 443
 			} else {
444 444
 				$error = true; 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	} 
455 455
 	
456 456
 	public function remove_accents($string) {
457
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
457
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
458 458
 		$chars = array(
459 459
 		    // Decompositions for Latin-1 Supplement
460 460
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
512 512
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
513 513
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
514
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
514
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
515 515
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
516 516
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
517 517
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
528 528
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
529 529
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
530
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
531
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
532
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
533
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
534
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
535
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
536
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
530
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
531
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
532
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
533
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
534
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
535
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
536
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
537 537
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
538 538
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
539 539
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
568 568
 			if (is_numeric($string[$i]) && $concat_flag) {
569 569
 				$int .= $string[$i];
570
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
570
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
571 571
 				$concat_flag = false;
572 572
 			}
573 573
 		}
Please login to merge, or discard this patch.
require/class.Marine.php 4 patches
Doc Comments   +2 added lines, -21 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	* Get SQL query part for filter used
17 17
 	* @param Array $filter the filter
18
-	* @return Array the SQL part
18
+	* @return string the SQL part
19 19
 	*/
20 20
 	
21 21
 	public function getFilter($filter = array(),$where = false,$and = false) {
@@ -552,25 +552,6 @@  discard block
 block discarded – undo
552 552
 	*
553 553
 	* @param String $fammarine_id the ID
554 554
 	* @param String $ident the marine ident
555
-	* @param String $departure_airport_icao the departure airport
556
-	* @param String $arrival_airport_icao the arrival airport
557
-	* @param String $latitude latitude of flight
558
-	* @param String $longitude latitude of flight
559
-	* @param String $waypoints waypoints of flight
560
-	* @param String $heading heading of flight
561
-	* @param String $groundspeed speed of flight
562
-	* @param String $date date of flight
563
-	* @param String $departure_airport_time departure time of flight
564
-	* @param String $arrival_airport_time arrival time of flight
565
-	* @param String $squawk squawk code of flight
566
-	* @param String $route_stop route stop of flight
567
-	* @param String $highlight highlight or not
568
-	* @param String $ModeS ModesS code of flight
569
-	* @param String $registration registration code of flight
570
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
571
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
572
-	* @param String $verticalrate vertival rate of flight
573
-	* @return String success or false
574 555
 	*/
575 556
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '')
576 557
 	{
@@ -1444,7 +1425,7 @@  discard block
 block discarded – undo
1444 1425
 	/**
1445 1426
 	* Parses the direction degrees to working
1446 1427
 	*
1447
-	* @param Float $direction the direction in degrees
1428
+	* @param integer $direction the direction in degrees
1448 1429
 	* @return Array the direction information
1449 1430
 	*
1450 1431
 	*/
Please login to merge, or discard this patch.
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	/**
14
-	* Get SQL query part for filter used
15
-	* @param Array $filter the filter
16
-	* @return Array the SQL part
17
-	*/
14
+	 * Get SQL query part for filter used
15
+	 * @param Array $filter the filter
16
+	 * @return Array the SQL part
17
+	 */
18 18
 	
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	}
79 79
 
80 80
 	/**
81
-	* Executes the SQL statements to get the spotter information
82
-	*
83
-	* @param String $query the SQL query
84
-	* @param Array $params parameter of the query
85
-	* @param String $limitQuery the limit query
86
-	* @return Array the spotter information
87
-	*
88
-	*/
81
+	 * Executes the SQL statements to get the spotter information
82
+	 *
83
+	 * @param String $query the SQL query
84
+	 * @param Array $params parameter of the query
85
+	 * @param String $limitQuery the limit query
86
+	 * @return Array the spotter information
87
+	 *
88
+	 */
89 89
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 	
213 213
 	
214 214
 	/**
215
-	* Gets all the spotter information based on the latest data entry
216
-	*
217
-	* @return Array the spotter information
218
-	*
219
-	*/
215
+	 * Gets all the spotter information based on the latest data entry
216
+	 *
217
+	 * @return Array the spotter information
218
+	 *
219
+	 */
220 220
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
221 221
 	{
222 222
 		global $global_query;
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 
276 276
 	/**
277
-	* Gets all the spotter information based on the callsign
278
-	*
279
-	* @return Array the spotter information
280
-	*
281
-	*/
277
+	 * Gets all the spotter information based on the callsign
278
+	 *
279
+	 * @return Array the spotter information
280
+	 *
281
+	 */
282 282
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
283 283
 	{
284 284
 		global $global_query;
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 
390 390
 
391 391
 	/**
392
-	* Gets all source name
393
-	*
394
-	* @param String type format of source
395
-	* @return Array list of source name
396
-	*
397
-	*/
392
+	 * Gets all source name
393
+	 *
394
+	 * @param String type format of source
395
+	 * @return Array list of source name
396
+	 *
397
+	 */
398 398
 	public function getAllSourceName($type = '',$filters = array())
399 399
 	{
400 400
 		$filter_query = $this->getFilter($filters,true,true);
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
 
425 425
 
426 426
 	/**
427
-	* Gets a list of all idents/callsigns
428
-	*
429
-	* @return Array list of ident/callsign names
430
-	*
431
-	*/
427
+	 * Gets a list of all idents/callsigns
428
+	 *
429
+	 * @return Array list of ident/callsign names
430
+	 *
431
+	 */
432 432
 	public function getAllIdents($filters = array())
433 433
 	{
434 434
 		$filter_query = $this->getFilter($filters,true,true);
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
 	}
453 453
 
454 454
 	/**
455
-	* Gets all info from a mmsi
456
-	*
457
-	* @return Array list of mmsi info
458
-	*
459
-	*/
455
+	 * Gets all info from a mmsi
456
+	 *
457
+	 * @return Array list of mmsi info
458
+	 *
459
+	 */
460 460
 	public function getIdentity($mmsi)
461 461
 	{
462 462
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -513,18 +513,18 @@  discard block
 block discarded – undo
513 513
 	
514 514
 	
515 515
 	/**
516
-	* Update ident tracker data
517
-	*
518
-	* @param String $fammarine_id the ID
519
-	* @param String $ident the marine ident
520
-	* @return String success or false
521
-	*
522
-	*/	
516
+	 * Update ident tracker data
517
+	 *
518
+	 * @param String $fammarine_id the ID
519
+	 * @param String $ident the marine ident
520
+	 * @return String success or false
521
+	 *
522
+	 */	
523 523
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
524 524
 	{
525 525
 
526 526
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
527
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
527
+				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
528 528
 
529 529
 		try {
530 530
 			$sth = $this->db->prepare($query);
@@ -537,17 +537,17 @@  discard block
 block discarded – undo
537 537
 
538 538
 	}
539 539
 	/**
540
-	* Update latest marine data
541
-	*
542
-	* @param String $fammarine_id the ID
543
-	* @param String $ident the marine ident
544
-	* @return String success or false
545
-	*
546
-	*/	
540
+	 * Update latest marine data
541
+	 *
542
+	 * @param String $fammarine_id the ID
543
+	 * @param String $ident the marine ident
544
+	 * @return String success or false
545
+	 *
546
+	 */	
547 547
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
548 548
 	{
549 549
 		$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';
550
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
550
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
551 551
 
552 552
 		try {
553 553
 			$sth = $this->db->prepare($query);
@@ -561,30 +561,30 @@  discard block
 block discarded – undo
561 561
 	}
562 562
 
563 563
 	/**
564
-	* Adds a new spotter data
565
-	*
566
-	* @param String $fammarine_id the ID
567
-	* @param String $ident the marine ident
568
-	* @param String $departure_airport_icao the departure airport
569
-	* @param String $arrival_airport_icao the arrival airport
570
-	* @param String $latitude latitude of flight
571
-	* @param String $longitude latitude of flight
572
-	* @param String $waypoints waypoints of flight
573
-	* @param String $heading heading of flight
574
-	* @param String $groundspeed speed of flight
575
-	* @param String $date date of flight
576
-	* @param String $departure_airport_time departure time of flight
577
-	* @param String $arrival_airport_time arrival time of flight
578
-	* @param String $squawk squawk code of flight
579
-	* @param String $route_stop route stop of flight
580
-	* @param String $highlight highlight or not
581
-	* @param String $ModeS ModesS code of flight
582
-	* @param String $registration registration code of flight
583
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
584
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
585
-	* @param String $verticalrate vertival rate of flight
586
-	* @return String success or false
587
-	*/
564
+	 * Adds a new spotter data
565
+	 *
566
+	 * @param String $fammarine_id the ID
567
+	 * @param String $ident the marine ident
568
+	 * @param String $departure_airport_icao the departure airport
569
+	 * @param String $arrival_airport_icao the arrival airport
570
+	 * @param String $latitude latitude of flight
571
+	 * @param String $longitude latitude of flight
572
+	 * @param String $waypoints waypoints of flight
573
+	 * @param String $heading heading of flight
574
+	 * @param String $groundspeed speed of flight
575
+	 * @param String $date date of flight
576
+	 * @param String $departure_airport_time departure time of flight
577
+	 * @param String $arrival_airport_time arrival time of flight
578
+	 * @param String $squawk squawk code of flight
579
+	 * @param String $route_stop route stop of flight
580
+	 * @param String $highlight highlight or not
581
+	 * @param String $ModeS ModesS code of flight
582
+	 * @param String $registration registration code of flight
583
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
584
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
585
+	 * @param String $verticalrate vertival rate of flight
586
+	 * @return String success or false
587
+	 */
588 588
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '')
589 589
 	{
590 590
 		global $globalURL, $globalMarineImageFetch;
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
 			unset($Image);
682 682
 		}
683 683
 		
684
-                if ($latitude == '' && $longitude == '') {
685
-            		$latitude = 0;
686
-            		$longitude = 0;
687
-            	}
688
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
689
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
690
-                if ($arrival_date == '') $arrival_date = NULL;
684
+				if ($latitude == '' && $longitude == '') {
685
+					$latitude = 0;
686
+					$longitude = 0;
687
+				}
688
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
689
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
690
+				if ($arrival_date == '') $arrival_date = NULL;
691 691
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
692 692
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
693 693
 
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 			$sth->execute($query_values);
699 699
 			$this->db = null;
700 700
 		} catch (PDOException $e) {
701
-		    return "error : ".$e->getMessage();
701
+			return "error : ".$e->getMessage();
702 702
 		}
703 703
 		
704 704
 		return "success";
@@ -707,11 +707,11 @@  discard block
 block discarded – undo
707 707
 	
708 708
   
709 709
 	/**
710
-	* Gets the aircraft ident within the last hour
711
-	*
712
-	* @return String the ident
713
-	*
714
-	*/
710
+	 * Gets the aircraft ident within the last hour
711
+	 *
712
+	 * @return String the ident
713
+	 *
714
+	 */
715 715
 	public function getIdentFromLastHour($ident)
716 716
 	{
717 717
 		global $globalDBdriver, $globalTimezone;
@@ -727,11 +727,11 @@  discard block
 block discarded – undo
727 727
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
728 728
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
729 729
 			$query_data = array(':ident' => $ident);
730
-    		}
730
+			}
731 731
 		
732 732
 		$sth = $this->db->prepare($query);
733 733
 		$sth->execute($query_data);
734
-    		$ident_result='';
734
+			$ident_result='';
735 735
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
736 736
 		{
737 737
 			$ident_result = $row['ident'];
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
 	
743 743
 	
744 744
 	/**
745
-	* Gets the aircraft data from the last 20 seconds
746
-	*
747
-	* @return Array the spotter data
748
-	*
749
-	*/
745
+	 * Gets the aircraft data from the last 20 seconds
746
+	 *
747
+	 * @return Array the spotter data
748
+	 *
749
+	 */
750 750
 	public function getRealTimeData($q = '')
751 751
 	{
752 752
 		global $globalDBdriver;
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
 	
785 785
 
786 786
 	/**
787
-	* Gets all number of flight over countries
788
-	*
789
-	* @return Array the airline country list
790
-	*
791
-	*/
787
+	 * Gets all number of flight over countries
788
+	 *
789
+	 * @return Array the airline country list
790
+	 *
791
+	 */
792 792
 /*
793 793
 	public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
794 794
 	{
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
 	
840 840
 	
841 841
 	/**
842
-	* Gets all callsigns that have flown over
843
-	*
844
-	* @return Array the callsign list
845
-	*
846
-	*/
842
+	 * Gets all callsigns that have flown over
843
+	 *
844
+	 * @return Array the callsign list
845
+	 *
846
+	 */
847 847
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
848 848
 	{
849 849
 		global $globalDBdriver;
@@ -910,11 +910,11 @@  discard block
 block discarded – undo
910 910
 
911 911
 
912 912
 	/**
913
-	* Counts all dates
914
-	*
915
-	* @return Array the date list
916
-	*
917
-	*/
913
+	 * Counts all dates
914
+	 *
915
+	 * @return Array the date list
916
+	 *
917
+	 */
918 918
 	public function countAllDates($filters = array())
919 919
 	{
920 920
 		global $globalTimezone, $globalDBdriver;
@@ -960,11 +960,11 @@  discard block
 block discarded – undo
960 960
 	
961 961
 	
962 962
 	/**
963
-	* Counts all dates during the last 7 days
964
-	*
965
-	* @return Array the date list
966
-	*
967
-	*/
963
+	 * Counts all dates during the last 7 days
964
+	 *
965
+	 * @return Array the date list
966
+	 *
967
+	 */
968 968
 	public function countAllDatesLast7Days($filters = array())
969 969
 	{
970 970
 		global $globalTimezone, $globalDBdriver;
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 			$query .= " GROUP BY date_name 
987 987
 								ORDER BY date_name ASC";
988 988
 			$query_data = array(':offset' => $offset);
989
-    		}
989
+			}
990 990
 		
991 991
 		$sth = $this->db->prepare($query);
992 992
 		$sth->execute($query_data);
@@ -1006,11 +1006,11 @@  discard block
 block discarded – undo
1006 1006
 	}
1007 1007
 
1008 1008
 	/**
1009
-	* Counts all dates during the last month
1010
-	*
1011
-	* @return Array the date list
1012
-	*
1013
-	*/
1009
+	 * Counts all dates during the last month
1010
+	 *
1011
+	 * @return Array the date list
1012
+	 *
1013
+	 */
1014 1014
 	public function countAllDatesLastMonth($filters = array())
1015 1015
 	{
1016 1016
 		global $globalTimezone, $globalDBdriver;
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 			$query .= " GROUP BY date_name 
1033 1033
 								ORDER BY date_name ASC";
1034 1034
 			$query_data = array(':offset' => $offset);
1035
-    		}
1035
+			}
1036 1036
 		
1037 1037
 		$sth = $this->db->prepare($query);
1038 1038
 		$sth->execute($query_data);
@@ -1054,11 +1054,11 @@  discard block
 block discarded – undo
1054 1054
 
1055 1055
 
1056 1056
 	/**
1057
-	* Counts all month
1058
-	*
1059
-	* @return Array the month list
1060
-	*
1061
-	*/
1057
+	 * Counts all month
1058
+	 *
1059
+	 * @return Array the month list
1060
+	 *
1061
+	 */
1062 1062
 	public function countAllMonths($filters = array())
1063 1063
 	{
1064 1064
 		global $globalTimezone, $globalDBdriver;
@@ -1103,11 +1103,11 @@  discard block
 block discarded – undo
1103 1103
 	
1104 1104
 
1105 1105
 	/**
1106
-	* Counts all dates during the last year
1107
-	*
1108
-	* @return Array the date list
1109
-	*
1110
-	*/
1106
+	 * Counts all dates during the last year
1107
+	 *
1108
+	 * @return Array the date list
1109
+	 *
1110
+	 */
1111 1111
 	public function countAllMonthsLastYear($filters)
1112 1112
 	{
1113 1113
 		global $globalTimezone, $globalDBdriver;
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 			$query .= " GROUP BY year_name, month_name
1130 1130
 								ORDER BY year_name, month_name ASC";
1131 1131
 			$query_data = array(':offset' => $offset);
1132
-    		}
1132
+			}
1133 1133
 		
1134 1134
 		$sth = $this->db->prepare($query);
1135 1135
 		$sth->execute($query_data);
@@ -1152,11 +1152,11 @@  discard block
 block discarded – undo
1152 1152
 	
1153 1153
 	
1154 1154
 	/**
1155
-	* Counts all hours
1156
-	*
1157
-	* @return Array the hour list
1158
-	*
1159
-	*/
1155
+	 * Counts all hours
1156
+	 *
1157
+	 * @return Array the hour list
1158
+	 *
1159
+	 */
1160 1160
 	public function countAllHours($orderby,$filters = array())
1161 1161
 	{
1162 1162
 		global $globalTimezone, $globalDBdriver;
@@ -1219,11 +1219,11 @@  discard block
 block discarded – undo
1219 1219
 	
1220 1220
 	
1221 1221
 	/**
1222
-	* Counts all hours by date
1223
-	*
1224
-	* @return Array the hour list
1225
-	*
1226
-	*/
1222
+	 * Counts all hours by date
1223
+	 *
1224
+	 * @return Array the hour list
1225
+	 *
1226
+	 */
1227 1227
 	public function countAllHoursByDate($date, $filters = array())
1228 1228
 	{
1229 1229
 		global $globalTimezone, $globalDBdriver;
@@ -1267,11 +1267,11 @@  discard block
 block discarded – undo
1267 1267
 	
1268 1268
 	
1269 1269
 	/**
1270
-	* Counts all hours by a ident/callsign
1271
-	*
1272
-	* @return Array the hour list
1273
-	*
1274
-	*/
1270
+	 * Counts all hours by a ident/callsign
1271
+	 *
1272
+	 * @return Array the hour list
1273
+	 *
1274
+	 */
1275 1275
 	public function countAllHoursByIdent($ident, $filters = array())
1276 1276
 	{
1277 1277
 		global $globalTimezone, $globalDBdriver;
@@ -1316,11 +1316,11 @@  discard block
 block discarded – undo
1316 1316
 	
1317 1317
 	
1318 1318
 	/**
1319
-	* Counts all flights that have flown over
1320
-	*
1321
-	* @return Integer the number of flights
1322
-	*
1323
-	*/
1319
+	 * Counts all flights that have flown over
1320
+	 *
1321
+	 * @return Integer the number of flights
1322
+	 *
1323
+	 */
1324 1324
 	public function countOverallTracked($filters = array(),$year = '',$month = '')
1325 1325
 	{
1326 1326
 		global $globalDBdriver;
@@ -1355,11 +1355,11 @@  discard block
 block discarded – undo
1355 1355
 	
1356 1356
   
1357 1357
 	/**
1358
-	* Counts all hours of today
1359
-	*
1360
-	* @return Array the hour list
1361
-	*
1362
-	*/
1358
+	 * Counts all hours of today
1359
+	 *
1360
+	 * @return Array the hour list
1361
+	 *
1362
+	 */
1363 1363
 	public function countAllHoursFromToday($filters = array())
1364 1364
 	{
1365 1365
 		global $globalTimezone, $globalDBdriver;
@@ -1399,12 +1399,12 @@  discard block
 block discarded – undo
1399 1399
 	}
1400 1400
     
1401 1401
     
1402
-     /**
1403
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1404
-	*
1405
-	* @return Integer the Barrie Spotter ID
1402
+	 /**
1403
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1404
+	  *
1405
+	  * @return Integer the Barrie Spotter ID
1406 1406
 q	*
1407
-	*/
1407
+	  */
1408 1408
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1409 1409
 	{
1410 1410
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1425,13 +1425,13 @@  discard block
 block discarded – undo
1425 1425
   
1426 1426
  
1427 1427
 	/**
1428
-	* Parses a date string
1429
-	*
1430
-	* @param String $dateString the date string
1431
-	* @param String $timezone the timezone of a user
1432
-	* @return Array the time information
1433
-	*
1434
-	*/
1428
+	 * Parses a date string
1429
+	 *
1430
+	 * @param String $dateString the date string
1431
+	 * @param String $timezone the timezone of a user
1432
+	 * @return Array the time information
1433
+	 *
1434
+	 */
1435 1435
 	public function parseDateString($dateString, $timezone = '')
1436 1436
 	{
1437 1437
 		$time_array = array();
@@ -1464,12 +1464,12 @@  discard block
 block discarded – undo
1464 1464
 	}
1465 1465
 	
1466 1466
 	/**
1467
-	* Parses the direction degrees to working
1468
-	*
1469
-	* @param Float $direction the direction in degrees
1470
-	* @return Array the direction information
1471
-	*
1472
-	*/
1467
+	 * Parses the direction degrees to working
1468
+	 *
1469
+	 * @param Float $direction the direction in degrees
1470
+	 * @return Array the direction information
1471
+	 *
1472
+	 */
1473 1473
 	public function parseDirection($direction = 0)
1474 1474
 	{
1475 1475
 		if ($direction == '') $direction = 0;
@@ -1548,12 +1548,12 @@  discard block
 block discarded – undo
1548 1548
 	
1549 1549
 	
1550 1550
 	/**
1551
-	* Gets Country from latitude/longitude
1552
-	*
1553
-	* @param Float $latitude latitute of the flight
1554
-	* @param Float $longitude longitute of the flight
1555
-	* @return String the countrie
1556
-	*/
1551
+	 * Gets Country from latitude/longitude
1552
+	 *
1553
+	 * @param Float $latitude latitute of the flight
1554
+	 * @param Float $longitude longitute of the flight
1555
+	 * @return String the countrie
1556
+	 */
1557 1557
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1558 1558
 	{
1559 1559
 		global $globalDBdriver, $globalDebug;
@@ -1590,11 +1590,11 @@  discard block
 block discarded – undo
1590 1590
 	}
1591 1591
 
1592 1592
 	/**
1593
-	* Gets Country from iso2
1594
-	*
1595
-	* @param String $iso2 ISO2 country code
1596
-	* @return String the countrie
1597
-	*/
1593
+	 * Gets Country from iso2
1594
+	 *
1595
+	 * @param String $iso2 ISO2 country code
1596
+	 * @return String the countrie
1597
+	 */
1598 1598
 	public function getCountryFromISO2($iso2)
1599 1599
 	{
1600 1600
 		global $globalDBdriver, $globalDebug;
@@ -1623,12 +1623,12 @@  discard block
 block discarded – undo
1623 1623
 
1624 1624
 	
1625 1625
 	/**
1626
-	* Gets the short url from bit.ly
1627
-	*
1628
-	* @param String $url the full url
1629
-	* @return String the bit.ly url
1630
-	*
1631
-	*/
1626
+	 * Gets the short url from bit.ly
1627
+	 *
1628
+	 * @param String $url the full url
1629
+	 * @return String the bit.ly url
1630
+	 *
1631
+	 */
1632 1632
 	public function getBitlyURL($url)
1633 1633
 	{
1634 1634
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 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) {
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @return Array the SQL part
17 17
 	*/
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 spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
38
+					$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 39
 				} else {
40
-					$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";
40
+					$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 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,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72 72
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73 73
 		if ($filter_query_where != '') {
74
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
74
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
75 75
 		}
76 76
 		$filter_query = $filter_query_join.$filter_query_where;
77 77
 		return $filter_query;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	* @return Array the spotter information
87 87
 	*
88 88
 	*/
89
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
89
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
92 92
 		if (!is_string($query))
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 			$sth = $this->db->prepare($query.$limitQuery);
107 107
 			$sth->execute($params);
108 108
 		} catch (PDOException $e) {
109
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
109
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
110 110
 			exit();
111 111
 		}
112 112
 		
113 113
 		$num_rows = 0;
114 114
 		$spotter_array = array();
115
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
115
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
116 116
 		{
117 117
 			$num_rows++;
118 118
 			$temp_array = array();
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 			}
144 144
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
145 145
 
146
-			if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE)
146
+			if ($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE)
147 147
 			{
148 148
 				$Image = new Image($this->db);
149
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
149
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
150 150
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
151 151
 				unset($Image);
152 152
 				if (count($image_array) > 0) {
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
 				{
183 183
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
184 184
 				} else {
185
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
185
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
186 186
 				}
187 187
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
188
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
189
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
188
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
189
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
190 190
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
191 191
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
192 192
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
193 193
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
194
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
195
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
194
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
195
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
196 196
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
197 197
 					}
198 198
 				}
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 		{
230 230
 			$limit_array = explode(",", $limit);
231 231
 			
232
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
233
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
232
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
233
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
234 234
 			
235 235
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
236 236
 			{
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 			$orderby_query = " ORDER BY marine_output.date DESC";
248 248
 		}
249 249
 
250
-		$query  = $global_query.$filter_query." ".$orderby_query;
250
+		$query = $global_query.$filter_query." ".$orderby_query;
251 251
 
252
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
252
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
253 253
 
254 254
 		return $spotter_array;
255 255
 	}
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 		if ($id == '') return array();
269 269
 		$additional_query = "marine_output.fammarine_id = :id";
270 270
 		$query_values = array(':id' => $id);
271
-		$query  = $global_query." WHERE ".$additional_query." ";
272
-		$spotter_array = $this->getDataFromDB($query,$query_values);
271
+		$query = $global_query." WHERE ".$additional_query." ";
272
+		$spotter_array = $this->getDataFromDB($query, $query_values);
273 273
 		return $spotter_array;
274 274
 	}
275 275
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 		$query_values = array();
289 289
 		$limit_query = '';
290 290
 		$additional_query = '';
291
-		$filter_query = $this->getFilter($filter,true,true);
291
+		$filter_query = $this->getFilter($filter, true, true);
292 292
 		if ($ident != "")
293 293
 		{
294 294
 			if (!is_string($ident))
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 		{
305 305
 			$limit_array = explode(",", $limit);
306 306
 			
307
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
308
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
307
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
308
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
309 309
 			
310 310
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
311 311
 			{
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		return $spotter_array;
330 330
 	}
331 331
 	
332
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
332
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
333 333
 	{
334 334
 		global $global_query, $globalTimezone, $globalDBdriver;
335 335
 		
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		$limit_query = '';
338 338
 		$additional_query = '';
339 339
 
340
-		$filter_query = $this->getFilter($filter,true,true);
340
+		$filter_query = $this->getFilter($filter, true, true);
341 341
 		
342 342
 		if ($date != "")
343 343
 		{
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 		{
364 364
 			$limit_array = explode(",", $limit);
365 365
 			
366
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
367
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
366
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
367
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
368 368
 			
369 369
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
370 370
 			{
@@ -395,11 +395,11 @@  discard block
 block discarded – undo
395 395
 	* @return Array list of source name
396 396
 	*
397 397
 	*/
398
-	public function getAllSourceName($type = '',$filters = array())
398
+	public function getAllSourceName($type = '', $filters = array())
399 399
 	{
400
-		$filter_query = $this->getFilter($filters,true,true);
400
+		$filter_query = $this->getFilter($filters, true, true);
401 401
 		$query_values = array();
402
-		$query  = "SELECT DISTINCT marine_output.source_name 
402
+		$query = "SELECT DISTINCT marine_output.source_name 
403 403
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
404 404
 		if ($type != '') {
405 405
 			$query_values = array(':type' => $type);
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 		$source_array = array();
415 415
 		$temp_array = array();
416 416
 		
417
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
417
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
418 418
 		{
419 419
 			$temp_array['source_name'] = $row['source_name'];
420 420
 			$source_array[] = $temp_array;
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	*/
432 432
 	public function getAllIdents($filters = array())
433 433
 	{
434
-		$filter_query = $this->getFilter($filters,true,true);
435
-		$query  = "SELECT DISTINCT marine_output.ident
434
+		$filter_query = $this->getFilter($filters, true, true);
435
+		$query = "SELECT DISTINCT marine_output.ident
436 436
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
437 437
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
438 438
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		$ident_array = array();
443 443
 		$temp_array = array();
444 444
 		
445
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
445
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
446 446
 		{
447 447
 			$temp_array['ident'] = $row['ident'];
448 448
 			$ident_array[] = $temp_array;
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	*/
460 460
 	public function getIdentity($mmsi)
461 461
 	{
462
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
462
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
463 463
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
464 464
 		$sth = $this->db->prepare($query);
465 465
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -484,12 +484,12 @@  discard block
 block discarded – undo
484 484
 		} else $offset = '+00:00';
485 485
 
486 486
 		if ($globalDBdriver == 'mysql') {
487
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
487
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
488 488
 								FROM marine_output
489 489
 								WHERE marine_output.date <> '' 
490 490
 								ORDER BY marine_output.date ASC LIMIT 0,200";
491 491
 		} else {
492
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
492
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
493 493
 								FROM marine_output
494 494
 								WHERE marine_output.date <> '' 
495 495
 								ORDER BY marine_output.date ASC LIMIT 0,200";
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 		$date_array = array();
502 502
 		$temp_array = array();
503 503
 		
504
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
504
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
505 505
 		{
506 506
 			$temp_array['date'] = $row['date'];
507 507
 
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
 	* @return String success or false
521 521
 	*
522 522
 	*/	
523
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
523
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
524 524
 	{
525 525
 
526 526
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
527
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
527
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
528 528
 
529 529
 		try {
530 530
 			$sth = $this->db->prepare($query);
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
548 548
 	{
549 549
 		$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';
550
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
550
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
551 551
 
552 552
 		try {
553 553
 			$sth = $this->db->prepare($query);
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 	* @param String $verticalrate vertival rate of flight
586 586
 	* @return String success or false
587 587
 	*/
588
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '')
588
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $format_source = '', $source_name = '')
589 589
 	{
590 590
 		global $globalURL, $globalMarineImageFetch;
591 591
 		
@@ -652,31 +652,31 @@  discard block
 block discarded – undo
652 652
 		}
653 653
 
654 654
     
655
-		if ($date == "" || strtotime($date) < time()-20*60)
655
+		if ($date == "" || strtotime($date) < time() - 20*60)
656 656
 		{
657 657
 			$date = date("Y-m-d H:i:s", time());
658 658
 		}
659 659
 
660
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
661
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
662
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
663
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
664
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
665
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
666
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
667
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
668
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
669
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
670
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
671
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
672
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
673
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
660
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
661
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
662
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
663
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
664
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
665
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
666
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
667
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
668
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
669
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
670
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
671
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
672
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
673
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
674 674
 	
675 675
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
676 676
 			$Image = new Image($this->db);
677
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
677
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
678 678
 			if (!isset($image_array[0]['mmsi'])) {
679
-				$Image->addMarineImage($mmsi,$imo,$ident);
679
+				$Image->addMarineImage($mmsi, $imo, $ident);
680 680
 			}
681 681
 			unset($Image);
682 682
 		}
@@ -688,10 +688,10 @@  discard block
 block discarded – undo
688 688
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
689 689
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
690 690
                 if ($arrival_date == '') $arrival_date = NULL;
691
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
691
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
692 692
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
693 693
 
694
-		$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,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
694
+		$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, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
695 695
 		try {
696 696
 		        
697 697
 			$sth = $this->db->prepare($query);
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 	{
717 717
 		global $globalDBdriver, $globalTimezone;
718 718
 		if ($globalDBdriver == 'mysql') {
719
-			$query  = "SELECT marine_output.ident FROM marine_output 
719
+			$query = "SELECT marine_output.ident FROM marine_output 
720 720
 								WHERE marine_output.ident = :ident 
721 721
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
722 722
 								AND marine_output.date < UTC_TIMESTAMP()";
723 723
 			$query_data = array(':ident' => $ident);
724 724
 		} else {
725
-			$query  = "SELECT marine_output.ident FROM marine_output 
725
+			$query = "SELECT marine_output.ident FROM marine_output 
726 726
 								WHERE marine_output.ident = :ident 
727 727
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
728 728
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -731,8 +731,8 @@  discard block
 block discarded – undo
731 731
 		
732 732
 		$sth = $this->db->prepare($query);
733 733
 		$sth->execute($query_data);
734
-    		$ident_result='';
735
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
734
+    		$ident_result = '';
735
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
736 736
 		{
737 737
 			$ident_result = $row['ident'];
738 738
 		}
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 				return false;
759 759
 			} else {
760 760
 				$q_array = explode(" ", $q);
761
-				foreach ($q_array as $q_item){
762
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
761
+				foreach ($q_array as $q_item) {
762
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
763 763
 					$additional_query .= " AND (";
764 764
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
765 765
 					$additional_query .= ")";
@@ -767,11 +767,11 @@  discard block
 block discarded – undo
767 767
 			}
768 768
 		}
769 769
 		if ($globalDBdriver == 'mysql') {
770
-			$query  = "SELECT marine_output.* FROM marine_output 
770
+			$query = "SELECT marine_output.* FROM marine_output 
771 771
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
772 772
 				AND marine_output.date < UTC_TIMESTAMP()";
773 773
 		} else {
774
-			$query  = "SELECT marine_output.* FROM marine_output 
774
+			$query = "SELECT marine_output.* FROM marine_output 
775 775
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
776 776
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
777 777
 		}
@@ -844,11 +844,11 @@  discard block
 block discarded – undo
844 844
 	* @return Array the callsign list
845 845
 	*
846 846
 	*/
847
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
847
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
848 848
 	{
849 849
 		global $globalDBdriver;
850
-		$filter_query = $this->getFilter($filters,true,true);
851
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
850
+		$filter_query = $this->getFilter($filters, true, true);
851
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
852 852
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
853 853
 		 if ($olderthanmonths > 0) {
854 854
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -862,28 +862,28 @@  discard block
 block discarded – undo
862 862
 		if ($year != '') {
863 863
 			if ($globalDBdriver == 'mysql') {
864 864
 				$query .= " AND YEAR(marine_output.date) = :year";
865
-				$query_values = array_merge($query_values,array(':year' => $year));
865
+				$query_values = array_merge($query_values, array(':year' => $year));
866 866
 			} else {
867 867
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
868
-				$query_values = array_merge($query_values,array(':year' => $year));
868
+				$query_values = array_merge($query_values, array(':year' => $year));
869 869
 			}
870 870
 		}
871 871
 		if ($month != '') {
872 872
 			if ($globalDBdriver == 'mysql') {
873 873
 				$query .= " AND MONTH(marine_output.date) = :month";
874
-				$query_values = array_merge($query_values,array(':month' => $month));
874
+				$query_values = array_merge($query_values, array(':month' => $month));
875 875
 			} else {
876 876
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
877
-				$query_values = array_merge($query_values,array(':month' => $month));
877
+				$query_values = array_merge($query_values, array(':month' => $month));
878 878
 			}
879 879
 		}
880 880
 		if ($day != '') {
881 881
 			if ($globalDBdriver == 'mysql') {
882 882
 				$query .= " AND DAY(marine_output.date) = :day";
883
-				$query_values = array_merge($query_values,array(':day' => $day));
883
+				$query_values = array_merge($query_values, array(':day' => $day));
884 884
 			} else {
885 885
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
886
-				$query_values = array_merge($query_values,array(':day' => $day));
886
+				$query_values = array_merge($query_values, array(':day' => $day));
887 887
 			}
888 888
 		}
889 889
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 		$callsign_array = array();
896 896
 		$temp_array = array();
897 897
         
898
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
898
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
899 899
 		{
900 900
 			$temp_array['callsign_icao'] = $row['ident'];
901 901
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 		$date_array = array();
948 948
 		$temp_array = array();
949 949
         
950
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
950
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
951 951
 		{
952 952
 			$temp_array['date_name'] = $row['date_name'];
953 953
 			$temp_array['date_count'] = $row['date_count'];
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 			$datetime = new DateTime();
974 974
 			$offset = $datetime->format('P');
975 975
 		} else $offset = '+00:00';
976
-		$filter_query = $this->getFilter($filters,true,true);
976
+		$filter_query = $this->getFilter($filters, true, true);
977 977
 		if ($globalDBdriver == 'mysql') {
978 978
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
979 979
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 		$date_array = array();
995 995
 		$temp_array = array();
996 996
         
997
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
997
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
998 998
 		{
999 999
 			$temp_array['date_name'] = $row['date_name'];
1000 1000
 			$temp_array['date_count'] = $row['date_count'];
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 			$datetime = new DateTime();
1020 1020
 			$offset = $datetime->format('P');
1021 1021
 		} else $offset = '+00:00';
1022
-		$filter_query = $this->getFilter($filters,true,true);
1022
+		$filter_query = $this->getFilter($filters, true, true);
1023 1023
 		if ($globalDBdriver == 'mysql') {
1024 1024
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1025 1025
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		$date_array = array();
1041 1041
 		$temp_array = array();
1042 1042
         
1043
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1043
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1044 1044
 		{
1045 1045
 			$temp_array['date_name'] = $row['date_name'];
1046 1046
 			$temp_array['date_count'] = $row['date_count'];
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 		$date_array = array();
1088 1088
 		$temp_array = array();
1089 1089
         
1090
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1090
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1091 1091
 		{
1092 1092
 			$temp_array['month_name'] = $row['month_name'];
1093 1093
 			$temp_array['year_name'] = $row['year_name'];
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 			$datetime = new DateTime();
1117 1117
 			$offset = $datetime->format('P');
1118 1118
 		} else $offset = '+00:00';
1119
-		$filter_query = $this->getFilter($filters,true,true);
1119
+		$filter_query = $this->getFilter($filters, true, true);
1120 1120
 		if ($globalDBdriver == 'mysql') {
1121 1121
 			$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
1122 1122
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 		$date_array = array();
1138 1138
 		$temp_array = array();
1139 1139
         
1140
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1140
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1141 1141
 		{
1142 1142
 			$temp_array['year_name'] = $row['year_name'];
1143 1143
 			$temp_array['month_name'] = $row['month_name'];
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 	* @return Array the hour list
1158 1158
 	*
1159 1159
 	*/
1160
-	public function countAllHours($orderby,$filters = array())
1160
+	public function countAllHours($orderby, $filters = array())
1161 1161
 	{
1162 1162
 		global $globalTimezone, $globalDBdriver;
1163 1163
 		if ($globalTimezone != '') {
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 		$hour_array = array();
1206 1206
 		$temp_array = array();
1207 1207
         
1208
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1208
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1209 1209
 		{
1210 1210
 			$temp_array['hour_name'] = $row['hour_name'];
1211 1211
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1227,8 +1227,8 @@  discard block
 block discarded – undo
1227 1227
 	public function countAllHoursByDate($date, $filters = array())
1228 1228
 	{
1229 1229
 		global $globalTimezone, $globalDBdriver;
1230
-		$filter_query = $this->getFilter($filters,true,true);
1231
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1230
+		$filter_query = $this->getFilter($filters, true, true);
1231
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1232 1232
 		if ($globalTimezone != '') {
1233 1233
 			date_default_timezone_set($globalTimezone);
1234 1234
 			$datetime = new DateTime($date);
@@ -1236,12 +1236,12 @@  discard block
 block discarded – undo
1236 1236
 		} else $offset = '+00:00';
1237 1237
 
1238 1238
 		if ($globalDBdriver == 'mysql') {
1239
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1239
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1240 1240
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1241 1241
 								GROUP BY hour_name 
1242 1242
 								ORDER BY hour_name ASC";
1243 1243
 		} else {
1244
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1244
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1245 1245
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1246 1246
 								GROUP BY hour_name 
1247 1247
 								ORDER BY hour_name ASC";
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 		$hour_array = array();
1254 1254
 		$temp_array = array();
1255 1255
         
1256
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1256
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1257 1257
 		{
1258 1258
 			$temp_array['hour_name'] = $row['hour_name'];
1259 1259
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1275,8 +1275,8 @@  discard block
 block discarded – undo
1275 1275
 	public function countAllHoursByIdent($ident, $filters = array())
1276 1276
 	{
1277 1277
 		global $globalTimezone, $globalDBdriver;
1278
-		$filter_query = $this->getFilter($filters,true,true);
1279
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1278
+		$filter_query = $this->getFilter($filters, true, true);
1279
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1280 1280
 		if ($globalTimezone != '') {
1281 1281
 			date_default_timezone_set($globalTimezone);
1282 1282
 			$datetime = new DateTime();
@@ -1284,12 +1284,12 @@  discard block
 block discarded – undo
1284 1284
 		} else $offset = '+00:00';
1285 1285
 
1286 1286
 		if ($globalDBdriver == 'mysql') {
1287
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1287
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1288 1288
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1289 1289
 								GROUP BY hour_name 
1290 1290
 								ORDER BY hour_name ASC";
1291 1291
 		} else {
1292
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1292
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1293 1293
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1294 1294
 								GROUP BY hour_name 
1295 1295
 								ORDER BY hour_name ASC";
@@ -1297,12 +1297,12 @@  discard block
 block discarded – undo
1297 1297
       
1298 1298
 		
1299 1299
 		$sth = $this->db->prepare($query);
1300
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1300
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1301 1301
       
1302 1302
 		$hour_array = array();
1303 1303
 		$temp_array = array();
1304 1304
         
1305
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1305
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1306 1306
 		{
1307 1307
 			$temp_array['hour_name'] = $row['hour_name'];
1308 1308
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1321,32 +1321,32 @@  discard block
 block discarded – undo
1321 1321
 	* @return Integer the number of flights
1322 1322
 	*
1323 1323
 	*/
1324
-	public function countOverallTracked($filters = array(),$year = '',$month = '')
1324
+	public function countOverallTracked($filters = array(), $year = '', $month = '')
1325 1325
 	{
1326 1326
 		global $globalDBdriver;
1327
-		$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1327
+		$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1328 1328
 		$query_values = array();
1329 1329
 		$query = '';
1330 1330
 		if ($year != '') {
1331 1331
 			if ($globalDBdriver == 'mysql') {
1332 1332
 				$query .= " AND YEAR(marine_output.date) = :year";
1333
-				$query_values = array_merge($query_values,array(':year' => $year));
1333
+				$query_values = array_merge($query_values, array(':year' => $year));
1334 1334
 			} else {
1335 1335
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1336
-				$query_values = array_merge($query_values,array(':year' => $year));
1336
+				$query_values = array_merge($query_values, array(':year' => $year));
1337 1337
 			}
1338 1338
 		}
1339 1339
 		if ($month != '') {
1340 1340
 			if ($globalDBdriver == 'mysql') {
1341 1341
 				$query .= " AND MONTH(marine_output.date) = :month";
1342
-				$query_values = array_merge($query_values,array(':month' => $month));
1342
+				$query_values = array_merge($query_values, array(':month' => $month));
1343 1343
 			} else {
1344 1344
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1345
-				$query_values = array_merge($query_values,array(':month' => $month));
1345
+				$query_values = array_merge($query_values, array(':month' => $month));
1346 1346
 			}
1347 1347
 		}
1348 1348
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1349
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1349
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1350 1350
 		
1351 1351
 		$sth = $this->db->prepare($queryi);
1352 1352
 		$sth->execute($query_values);
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 	public function countAllHoursFromToday($filters = array())
1364 1364
 	{
1365 1365
 		global $globalTimezone, $globalDBdriver;
1366
-		$filter_query = $this->getFilter($filters,true,true);
1366
+		$filter_query = $this->getFilter($filters, true, true);
1367 1367
 		if ($globalTimezone != '') {
1368 1368
 			date_default_timezone_set($globalTimezone);
1369 1369
 			$datetime = new DateTime();
@@ -1371,12 +1371,12 @@  discard block
 block discarded – undo
1371 1371
 		} else $offset = '+00:00';
1372 1372
 
1373 1373
 		if ($globalDBdriver == 'mysql') {
1374
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1374
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1375 1375
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1376 1376
 								GROUP BY hour_name 
1377 1377
 								ORDER BY hour_name ASC";
1378 1378
 		} else {
1379
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1379
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1380 1380
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1381 1381
 								GROUP BY hour_name 
1382 1382
 								ORDER BY hour_name ASC";
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
 		$hour_array = array();
1389 1389
 		$temp_array = array();
1390 1390
         
1391
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1391
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1392 1392
 		{
1393 1393
 			$temp_array['hour_name'] = $row['hour_name'];
1394 1394
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1407,9 +1407,9 @@  discard block
 block discarded – undo
1407 1407
 	*/
1408 1408
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1409 1409
 	{
1410
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1410
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1411 1411
 
1412
-		$query  = "SELECT marine_output.marine_id
1412
+		$query = "SELECT marine_output.marine_id
1413 1413
 				FROM marine_output 
1414 1414
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1415 1415
         
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
 		$sth = $this->db->prepare($query);
1418 1418
 		$sth->execute();
1419 1419
 
1420
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1420
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1421 1421
 		{
1422 1422
 			return $row['marine_id'];
1423 1423
 		}
@@ -1442,23 +1442,23 @@  discard block
 block discarded – undo
1442 1442
 		}
1443 1443
 		
1444 1444
 		$current_date = date("Y-m-d H:i:s");
1445
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1445
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1446 1446
 		
1447 1447
 		$diff = abs(strtotime($current_date) - strtotime($date));
1448 1448
 
1449
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1449
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1450 1450
 		$years = $time_array['years'];
1451 1451
 		
1452
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1452
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1453 1453
 		$months = $time_array['months'];
1454 1454
 		
1455
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1455
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1456 1456
 		$days = $time_array['days'];
1457
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1457
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1458 1458
 		$hours = $time_array['hours'];
1459
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1459
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1460 1460
 		$minutes = $time_array['minutes'];
1461
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1461
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1462 1462
 		
1463 1463
 		return $time_array;
1464 1464
 	}
@@ -1481,63 +1481,63 @@  discard block
 block discarded – undo
1481 1481
 			$temp_array['direction_degree'] = $direction;
1482 1482
 			$temp_array['direction_shortname'] = "N";
1483 1483
 			$temp_array['direction_fullname'] = "North";
1484
-		} elseif ($direction >= 22.5 && $direction < 45){
1484
+		} elseif ($direction >= 22.5 && $direction < 45) {
1485 1485
 			$temp_array['direction_degree'] = $direction;
1486 1486
 			$temp_array['direction_shortname'] = "NNE";
1487 1487
 			$temp_array['direction_fullname'] = "North-Northeast";
1488
-		} elseif ($direction >= 45 && $direction < 67.5){
1488
+		} elseif ($direction >= 45 && $direction < 67.5) {
1489 1489
 			$temp_array['direction_degree'] = $direction;
1490 1490
 			$temp_array['direction_shortname'] = "NE";
1491 1491
 			$temp_array['direction_fullname'] = "Northeast";
1492
-		} elseif ($direction >= 67.5 && $direction < 90){
1492
+		} elseif ($direction >= 67.5 && $direction < 90) {
1493 1493
 			$temp_array['direction_degree'] = $direction;
1494 1494
 			$temp_array['direction_shortname'] = "ENE";
1495 1495
 			$temp_array['direction_fullname'] = "East-Northeast";
1496
-		} elseif ($direction >= 90 && $direction < 112.5){
1496
+		} elseif ($direction >= 90 && $direction < 112.5) {
1497 1497
 			$temp_array['direction_degree'] = $direction;
1498 1498
 			$temp_array['direction_shortname'] = "E";
1499 1499
 			$temp_array['direction_fullname'] = "East";
1500
-		} elseif ($direction >= 112.5 && $direction < 135){
1500
+		} elseif ($direction >= 112.5 && $direction < 135) {
1501 1501
 			$temp_array['direction_degree'] = $direction;
1502 1502
 			$temp_array['direction_shortname'] = "ESE";
1503 1503
 			$temp_array['direction_fullname'] = "East-Southeast";
1504
-		} elseif ($direction >= 135 && $direction < 157.5){
1504
+		} elseif ($direction >= 135 && $direction < 157.5) {
1505 1505
 			$temp_array['direction_degree'] = $direction;
1506 1506
 			$temp_array['direction_shortname'] = "SE";
1507 1507
 			$temp_array['direction_fullname'] = "Southeast";
1508
-		} elseif ($direction >= 157.5 && $direction < 180){
1508
+		} elseif ($direction >= 157.5 && $direction < 180) {
1509 1509
 			$temp_array['direction_degree'] = $direction;
1510 1510
 			$temp_array['direction_shortname'] = "SSE";
1511 1511
 			$temp_array['direction_fullname'] = "South-Southeast";
1512
-		} elseif ($direction >= 180 && $direction < 202.5){
1512
+		} elseif ($direction >= 180 && $direction < 202.5) {
1513 1513
 			$temp_array['direction_degree'] = $direction;
1514 1514
 			$temp_array['direction_shortname'] = "S";
1515 1515
 			$temp_array['direction_fullname'] = "South";
1516
-		} elseif ($direction >= 202.5 && $direction < 225){
1516
+		} elseif ($direction >= 202.5 && $direction < 225) {
1517 1517
 			$temp_array['direction_degree'] = $direction;
1518 1518
 			$temp_array['direction_shortname'] = "SSW";
1519 1519
 			$temp_array['direction_fullname'] = "South-Southwest";
1520
-		} elseif ($direction >= 225 && $direction < 247.5){
1520
+		} elseif ($direction >= 225 && $direction < 247.5) {
1521 1521
 			$temp_array['direction_degree'] = $direction;
1522 1522
 			$temp_array['direction_shortname'] = "SW";
1523 1523
 			$temp_array['direction_fullname'] = "Southwest";
1524
-		} elseif ($direction >= 247.5 && $direction < 270){
1524
+		} elseif ($direction >= 247.5 && $direction < 270) {
1525 1525
 			$temp_array['direction_degree'] = $direction;
1526 1526
 			$temp_array['direction_shortname'] = "WSW";
1527 1527
 			$temp_array['direction_fullname'] = "West-Southwest";
1528
-		} elseif ($direction >= 270 && $direction < 292.5){
1528
+		} elseif ($direction >= 270 && $direction < 292.5) {
1529 1529
 			$temp_array['direction_degree'] = $direction;
1530 1530
 			$temp_array['direction_shortname'] = "W";
1531 1531
 			$temp_array['direction_fullname'] = "West";
1532
-		} elseif ($direction >= 292.5 && $direction < 315){
1532
+		} elseif ($direction >= 292.5 && $direction < 315) {
1533 1533
 			$temp_array['direction_degree'] = $direction;
1534 1534
 			$temp_array['direction_shortname'] = "WNW";
1535 1535
 			$temp_array['direction_fullname'] = "West-Northwest";
1536
-		} elseif ($direction >= 315 && $direction < 337.5){
1536
+		} elseif ($direction >= 315 && $direction < 337.5) {
1537 1537
 			$temp_array['direction_degree'] = $direction;
1538 1538
 			$temp_array['direction_shortname'] = "NW";
1539 1539
 			$temp_array['direction_fullname'] = "Northwest";
1540
-		} elseif ($direction >= 337.5 && $direction < 360){
1540
+		} elseif ($direction >= 337.5 && $direction < 360) {
1541 1541
 			$temp_array['direction_degree'] = $direction;
1542 1542
 			$temp_array['direction_shortname'] = "NNW";
1543 1543
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1554,11 +1554,11 @@  discard block
 block discarded – undo
1554 1554
 	* @param Float $longitude longitute of the flight
1555 1555
 	* @return String the countrie
1556 1556
 	*/
1557
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1557
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1558 1558
 	{
1559 1559
 		global $globalDBdriver, $globalDebug;
1560
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1561
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1560
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1561
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1562 1562
 	
1563 1563
 		$Connection = new Connection($this->db);
1564 1564
 		if (!$Connection->tableExists('countries')) return '';
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
 	public function getCountryFromISO2($iso2)
1599 1599
 	{
1600 1600
 		global $globalDBdriver, $globalDebug;
1601
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1601
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1602 1602
 	
1603 1603
 		$Connection = new Connection($this->db);
1604 1604
 		if (!$Connection->tableExists('countries')) return '';
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
 		
1647 1647
 		$bitly_data = json_decode($bitly_data);
1648 1648
 		$bitly_url = '';
1649
-		if ($bitly_data->status_txt = "OK"){
1649
+		if ($bitly_data->status_txt = "OK") {
1650 1650
 			$bitly_url = $bitly_data->data->url;
1651 1651
 		}
1652 1652
 
@@ -1656,7 +1656,7 @@  discard block
 block discarded – undo
1656 1656
 
1657 1657
 	public function getOrderBy()
1658 1658
 	{
1659
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao 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"));
1659
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao 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"));
1660 1660
 		
1661 1661
 		return $orderby;
1662 1662
 		
Please login to merge, or discard this patch.
Braces   +153 added lines, -55 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
69 71
 			}
70 72
 		}
71
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73
+		if ($filter_query_where == '' && $where) {
74
+			$filter_query_where = ' WHERE';
75
+		} elseif ($filter_query_where != '' && $and) {
76
+			$filter_query_where .= ' AND';
77
+		}
73 78
 		if ($filter_query_where != '') {
74 79
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75 80
 		}
@@ -123,31 +128,51 @@  discard block
 block discarded – undo
123 128
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
124 129
 			} elseif (isset($row['spotter_archive_output_id'])) {
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
126
-			*/} 
127
-			elseif (isset($row['marineid'])) {
131
+			*/} elseif (isset($row['marineid'])) {
128 132
 				$temp_array['marineid'] = $row['marineid'];
129 133
 			} else {
130 134
 				$temp_array['marineid'] = '';
131 135
 			}
132
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
133
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
134
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
135
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
136
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
137
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
138
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
136
+			if (isset($row['fammarine_id'])) {
137
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
138
+			}
139
+			if (isset($row['mmsi'])) {
140
+				$temp_array['mmsi'] = $row['mmsi'];
141
+			}
142
+			if (isset($row['type'])) {
143
+				$temp_array['type'] = $row['type'];
144
+			}
145
+			if (isset($row['ident'])) {
146
+				$temp_array['ident'] = $row['ident'];
147
+			}
148
+			if (isset($row['latitude'])) {
149
+				$temp_array['latitude'] = $row['latitude'];
150
+			}
151
+			if (isset($row['longitude'])) {
152
+				$temp_array['longitude'] = $row['longitude'];
153
+			}
154
+			if (isset($row['format_source'])) {
155
+				$temp_array['format_source'] = $row['format_source'];
156
+			}
139 157
 			if (isset($row['heading'])) {
140 158
 				$temp_array['heading'] = $row['heading'];
141 159
 				$heading_direction = $this->parseDirection($row['heading']);
142
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
160
+				if (isset($heading_direction[0]['direction_fullname'])) {
161
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
162
+				}
163
+			}
164
+			if (isset($row['ground_speed'])) {
165
+				$temp_array['ground_speed'] = $row['ground_speed'];
143 166
 			}
144
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
145 167
 
146 168
 			if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE)
147 169
 			{
148 170
 				$Image = new Image($this->db);
149
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
150
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
171
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
172
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
173
+				} else {
174
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
175
+				}
151 176
 				unset($Image);
152 177
 				if (count($image_array) > 0) {
153 178
 					$temp_array['image'] = $image_array[0]['image'];
@@ -199,13 +224,21 @@  discard block
 block discarded – undo
199 224
 			}
200 225
 			
201 226
 			$fromsource = NULL;
202
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
203
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
204
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
227
+			if (isset($row['source_name']) && $row['source_name'] != '') {
228
+				$temp_array['source_name'] = $row['source_name'];
229
+			}
230
+			if (isset($row['over_country']) && $row['over_country'] != '') {
231
+				$temp_array['over_country'] = $row['over_country'];
232
+			}
233
+			if (isset($row['distance']) && $row['distance'] != '') {
234
+				$temp_array['distance'] = $row['distance'];
235
+			}
205 236
 			$temp_array['query_number_rows'] = $num_rows;
206 237
 			$spotter_array[] = $temp_array;
207 238
 		}
208
-		if ($num_rows == 0) return array();
239
+		if ($num_rows == 0) {
240
+			return array();
241
+		}
209 242
 		$spotter_array[0]['query_number_rows'] = $num_rows;
210 243
 		return $spotter_array;
211 244
 	}	
@@ -236,8 +269,12 @@  discard block
 block discarded – undo
236 269
 			{
237 270
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
238 271
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
239
-			} else $limit_query = "";
240
-		} else $limit_query = "";
272
+			} else {
273
+				$limit_query = "";
274
+			}
275
+		} else {
276
+			$limit_query = "";
277
+		}
241 278
 		
242 279
 		if ($sort != "")
243 280
 		{
@@ -265,7 +302,9 @@  discard block
 block discarded – undo
265 302
 		global $global_query;
266 303
 		
267 304
 		date_default_timezone_set('UTC');
268
-		if ($id == '') return array();
305
+		if ($id == '') {
306
+			return array();
307
+		}
269 308
 		$additional_query = "marine_output.fammarine_id = :id";
270 309
 		$query_values = array(':id' => $id);
271 310
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -408,8 +447,11 @@  discard block
 block discarded – undo
408 447
 		$query .= " ORDER BY marine_output.source_name ASC";
409 448
 
410 449
 		$sth = $this->db->prepare($query);
411
-		if (!empty($query_values)) $sth->execute($query_values);
412
-		else $sth->execute();
450
+		if (!empty($query_values)) {
451
+			$sth->execute($query_values);
452
+		} else {
453
+			$sth->execute();
454
+		}
413 455
 
414 456
 		$source_array = array();
415 457
 		$temp_array = array();
@@ -464,8 +506,11 @@  discard block
 block discarded – undo
464 506
 		$sth = $this->db->prepare($query);
465 507
 		$sth->execute(array(':mmsi' => $mmsi));
466 508
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
467
-		if (isset($result[0])) return $result[0];
468
-		else return array();
509
+		if (isset($result[0])) {
510
+			return $result[0];
511
+		} else {
512
+			return array();
513
+		}
469 514
 	}
470 515
 
471 516
 	/*
@@ -481,7 +526,9 @@  discard block
 block discarded – undo
481 526
 			date_default_timezone_set($globalTimezone);
482 527
 			$datetime = new DateTime();
483 528
 			$offset = $datetime->format('P');
484
-		} else $offset = '+00:00';
529
+		} else {
530
+			$offset = '+00:00';
531
+		}
485 532
 
486 533
 		if ($globalDBdriver == 'mysql') {
487 534
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -685,9 +732,15 @@  discard block
 block discarded – undo
685 732
             		$latitude = 0;
686 733
             		$longitude = 0;
687 734
             	}
688
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
689
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
690
-                if ($arrival_date == '') $arrival_date = NULL;
735
+                if ($heading == '' || $Common->isInteger($heading) === false) {
736
+                	$heading = 0;
737
+                }
738
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
739
+                	$groundspeed = 0;
740
+                }
741
+                if ($arrival_date == '') {
742
+                	$arrival_date = NULL;
743
+                }
691 744
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
692 745
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
693 746
 
@@ -851,12 +904,18 @@  discard block
 block discarded – undo
851 904
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
852 905
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
853 906
 		 if ($olderthanmonths > 0) {
854
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
855
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
907
+			if ($globalDBdriver == 'mysql') {
908
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
909
+			} else {
910
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
911
+			}
856 912
 		}
857 913
 		if ($sincedate != '') {
858
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
859
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
914
+			if ($globalDBdriver == 'mysql') {
915
+				$query .= " AND marine_output.date > '".$sincedate."'";
916
+			} else {
917
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
918
+			}
860 919
 		}
861 920
 		$query_values = array();
862 921
 		if ($year != '') {
@@ -887,7 +946,9 @@  discard block
 block discarded – undo
887 946
 			}
888 947
 		}
889 948
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
890
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
949
+		if ($limit) {
950
+			$query .= " LIMIT 10 OFFSET 0";
951
+		}
891 952
       		
892 953
 		$sth = $this->db->prepare($query);
893 954
 		$sth->execute($query_values);
@@ -922,7 +983,9 @@  discard block
 block discarded – undo
922 983
 			date_default_timezone_set($globalTimezone);
923 984
 			$datetime = new DateTime();
924 985
 			$offset = $datetime->format('P');
925
-		} else $offset = '+00:00';
986
+		} else {
987
+			$offset = '+00:00';
988
+		}
926 989
 
927 990
 		if ($globalDBdriver == 'mysql') {
928 991
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -972,7 +1035,9 @@  discard block
 block discarded – undo
972 1035
 			date_default_timezone_set($globalTimezone);
973 1036
 			$datetime = new DateTime();
974 1037
 			$offset = $datetime->format('P');
975
-		} else $offset = '+00:00';
1038
+		} else {
1039
+			$offset = '+00:00';
1040
+		}
976 1041
 		$filter_query = $this->getFilter($filters,true,true);
977 1042
 		if ($globalDBdriver == 'mysql') {
978 1043
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1018,7 +1083,9 @@  discard block
 block discarded – undo
1018 1083
 			date_default_timezone_set($globalTimezone);
1019 1084
 			$datetime = new DateTime();
1020 1085
 			$offset = $datetime->format('P');
1021
-		} else $offset = '+00:00';
1086
+		} else {
1087
+			$offset = '+00:00';
1088
+		}
1022 1089
 		$filter_query = $this->getFilter($filters,true,true);
1023 1090
 		if ($globalDBdriver == 'mysql') {
1024 1091
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1066,7 +1133,9 @@  discard block
 block discarded – undo
1066 1133
 			date_default_timezone_set($globalTimezone);
1067 1134
 			$datetime = new DateTime();
1068 1135
 			$offset = $datetime->format('P');
1069
-		} else $offset = '+00:00';
1136
+		} else {
1137
+			$offset = '+00:00';
1138
+		}
1070 1139
 
1071 1140
 		if ($globalDBdriver == 'mysql') {
1072 1141
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1115,7 +1184,9 @@  discard block
 block discarded – undo
1115 1184
 			date_default_timezone_set($globalTimezone);
1116 1185
 			$datetime = new DateTime();
1117 1186
 			$offset = $datetime->format('P');
1118
-		} else $offset = '+00:00';
1187
+		} else {
1188
+			$offset = '+00:00';
1189
+		}
1119 1190
 		$filter_query = $this->getFilter($filters,true,true);
1120 1191
 		if ($globalDBdriver == 'mysql') {
1121 1192
 			$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
@@ -1164,7 +1235,9 @@  discard block
 block discarded – undo
1164 1235
 			date_default_timezone_set($globalTimezone);
1165 1236
 			$datetime = new DateTime();
1166 1237
 			$offset = $datetime->format('P');
1167
-		} else $offset = '+00:00';
1238
+		} else {
1239
+			$offset = '+00:00';
1240
+		}
1168 1241
 
1169 1242
 		$orderby_sql = '';
1170 1243
 		if ($orderby == "hour")
@@ -1233,7 +1306,9 @@  discard block
 block discarded – undo
1233 1306
 			date_default_timezone_set($globalTimezone);
1234 1307
 			$datetime = new DateTime($date);
1235 1308
 			$offset = $datetime->format('P');
1236
-		} else $offset = '+00:00';
1309
+		} else {
1310
+			$offset = '+00:00';
1311
+		}
1237 1312
 
1238 1313
 		if ($globalDBdriver == 'mysql') {
1239 1314
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1281,7 +1356,9 @@  discard block
 block discarded – undo
1281 1356
 			date_default_timezone_set($globalTimezone);
1282 1357
 			$datetime = new DateTime();
1283 1358
 			$offset = $datetime->format('P');
1284
-		} else $offset = '+00:00';
1359
+		} else {
1360
+			$offset = '+00:00';
1361
+		}
1285 1362
 
1286 1363
 		if ($globalDBdriver == 'mysql') {
1287 1364
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1345,8 +1422,11 @@  discard block
 block discarded – undo
1345 1422
 				$query_values = array_merge($query_values,array(':month' => $month));
1346 1423
 			}
1347 1424
 		}
1348
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1349
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1425
+		if (empty($query_values)) {
1426
+			$queryi .= $this->getFilter($filters);
1427
+		} else {
1428
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1429
+		}
1350 1430
 		
1351 1431
 		$sth = $this->db->prepare($queryi);
1352 1432
 		$sth->execute($query_values);
@@ -1368,7 +1448,9 @@  discard block
 block discarded – undo
1368 1448
 			date_default_timezone_set($globalTimezone);
1369 1449
 			$datetime = new DateTime();
1370 1450
 			$offset = $datetime->format('P');
1371
-		} else $offset = '+00:00';
1451
+		} else {
1452
+			$offset = '+00:00';
1453
+		}
1372 1454
 
1373 1455
 		if ($globalDBdriver == 'mysql') {
1374 1456
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1472,7 +1554,9 @@  discard block
 block discarded – undo
1472 1554
 	*/
1473 1555
 	public function parseDirection($direction = 0)
1474 1556
 	{
1475
-		if ($direction == '') $direction = 0;
1557
+		if ($direction == '') {
1558
+			$direction = 0;
1559
+		}
1476 1560
 		$direction_array = array();
1477 1561
 		$temp_array = array();
1478 1562
 
@@ -1561,7 +1645,9 @@  discard block
 block discarded – undo
1561 1645
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1562 1646
 	
1563 1647
 		$Connection = new Connection($this->db);
1564
-		if (!$Connection->tableExists('countries')) return '';
1648
+		if (!$Connection->tableExists('countries')) {
1649
+			return '';
1650
+		}
1565 1651
 	
1566 1652
 		try {
1567 1653
 			/*
@@ -1581,9 +1667,13 @@  discard block
 block discarded – undo
1581 1667
 			$sth->closeCursor();
1582 1668
 			if (count($row) > 0) {
1583 1669
 				return $row;
1584
-			} else return '';
1670
+			} else {
1671
+				return '';
1672
+			}
1585 1673
 		} catch (PDOException $e) {
1586
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1674
+			if (isset($globalDebug) && $globalDebug) {
1675
+				echo 'Error : '.$e->getMessage()."\n";
1676
+			}
1587 1677
 			return '';
1588 1678
 		}
1589 1679
 	
@@ -1601,7 +1691,9 @@  discard block
 block discarded – undo
1601 1691
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1602 1692
 	
1603 1693
 		$Connection = new Connection($this->db);
1604
-		if (!$Connection->tableExists('countries')) return '';
1694
+		if (!$Connection->tableExists('countries')) {
1695
+			return '';
1696
+		}
1605 1697
 	
1606 1698
 		try {
1607 1699
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1613,9 +1705,13 @@  discard block
 block discarded – undo
1613 1705
 			$sth->closeCursor();
1614 1706
 			if (count($row) > 0) {
1615 1707
 				return $row;
1616
-			} else return '';
1708
+			} else {
1709
+				return '';
1710
+			}
1617 1711
 		} catch (PDOException $e) {
1618
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1712
+			if (isset($globalDebug) && $globalDebug) {
1713
+				echo 'Error : '.$e->getMessage()."\n";
1714
+			}
1619 1715
 			return '';
1620 1716
 		}
1621 1717
 	
@@ -1633,7 +1729,9 @@  discard block
 block discarded – undo
1633 1729
 	{
1634 1730
 		global $globalBitlyAccessToken;
1635 1731
 		
1636
-		if ($globalBitlyAccessToken == '') return $url;
1732
+		if ($globalBitlyAccessToken == '') {
1733
+			return $url;
1734
+		}
1637 1735
         
1638 1736
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1639 1737
 		
Please login to merge, or discard this patch.