Completed
Push — master ( e14a40...cfb98e )
by Yannick
54:46 queued 27:34
created
news.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 else $type = 'global';
15 15
 
16 16
 //calculuation for the pagination
17
-if(!isset($_GET['limit']))
17
+if (!isset($_GET['limit']))
18 18
 {
19 19
   $limit_start = 0;
20 20
   $limit_end = 25;
21 21
   $absolute_difference = 25;
22
-}  else {
22
+} else {
23 23
 	$limit_explode = explode(",", $_GET['limit']);
24 24
 	$limit_start = $limit_explode[0];
25 25
 	$limit_end = $limit_explode[1];
26 26
 }
27 27
 
28
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
28
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
29 29
 
30 30
 $absolute_difference = abs($limit_start - $limit_end);
31 31
 $limit_next = $limit_end + $absolute_difference;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 if (!empty($anews))
60 60
 {
61 61
 	$j = 0;
62
-	foreach($anews as $news) {
62
+	foreach ($anews as $news) {
63 63
 		if ($j > 10) break;
64 64
 		$j++;
65 65
 		print '<div class="news">';
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,11 +7,17 @@  discard block
 block discarded – undo
7 7
 $title = _("News");
8 8
 require_once('header.php');
9 9
 
10
-if (isset($_GET['tracker'])) $type = 'tracker';
11
-elseif (isset($_GET['marine'])) $type = 'marine';
12
-elseif (isset($_GET['aircraft'])) $type = 'aircraft';
13
-elseif (isset($_GET['satellite'])) $type = 'satellite';
14
-else $type = 'global';
10
+if (isset($_GET['tracker'])) {
11
+	$type = 'tracker';
12
+} elseif (isset($_GET['marine'])) {
13
+	$type = 'marine';
14
+} elseif (isset($_GET['aircraft'])) {
15
+	$type = 'aircraft';
16
+} elseif (isset($_GET['satellite'])) {
17
+	$type = 'satellite';
18
+} else {
19
+	$type = 'global';
20
+}
15 21
 
16 22
 //calculuation for the pagination
17 23
 if(!isset($_GET['limit']))
@@ -19,7 +25,7 @@  discard block
 block discarded – undo
19 25
   $limit_start = 0;
20 26
   $limit_end = 25;
21 27
   $absolute_difference = 25;
22
-}  else {
28
+} else {
23 29
 	$limit_explode = explode(",", $_GET['limit']);
24 30
 	$limit_start = $limit_explode[0];
25 31
 	$limit_end = $limit_explode[1];
@@ -46,9 +52,12 @@  discard block
 block discarded – undo
46 52
 	$feeds = $globalNewsFeeds[$type];
47 53
 } else {
48 54
 	$lg = $lang[1];
49
-	if (isset($globalNewsFeeds[$type][$lg])) $feeds = $globalNewsFeeds[$type][$lg];
50
-	else $feeds = array_shift($globalNewsFeeds[$type]);
51
-}
55
+	if (isset($globalNewsFeeds[$type][$lg])) {
56
+		$feeds = $globalNewsFeeds[$type][$lg];
57
+	} else {
58
+		$feeds = array_shift($globalNewsFeeds[$type]);
59
+	}
60
+	}
52 61
 
53 62
 $SimplePie->set_feed_url($feeds);
54 63
 $SimplePie->set_cache_duration(3600);
@@ -60,7 +69,9 @@  discard block
 block discarded – undo
60 69
 {
61 70
 	$j = 0;
62 71
 	foreach($anews as $news) {
63
-		if ($j > 10) break;
72
+		if ($j > 10) {
73
+			break;
74
+		}
64 75
 		$j++;
65 76
 		print '<div class="news">';
66 77
 		print '<h4><a href="'.$news->get_permalink().'">'.$news->get_title().'</a> <span>('.$news->get_date('j M Y, g:i a').')</span></h4>'."\n";
Please login to merge, or discard this patch.
owner-sub-menu.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 	</form>
8 8
 </div>
9 9
 <?php
10
-    if (isset($owner)) {
10
+	if (isset($owner)) {
11 11
 ?>
12 12
 <div class="sub-menu sub-menu-container">
13 13
 	<ul class="nav nav-pills">
@@ -38,5 +38,5 @@  discard block
 block discarded – undo
38 38
 	</ul>
39 39
 </div>
40 40
 <?php
41
-    }
41
+	}
42 42
 ?>
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 ?>
12 12
 <div class="sub-menu sub-menu-container">
13 13
 	<ul class="nav nav-pills">
14
-		<li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
14
+		<li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
15 15
 		<li class="dropdown">
16
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "owner-statistics-aircraft" || strtolower($current_page) == "owner-statistics-registration" || strtolower($current_page) == "owner-statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
16
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "owner-statistics-aircraft" || strtolower($current_page) == "owner-statistics-registration" || strtolower($current_page) == "owner-statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#">
17 17
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
18 18
 		    </a>
19 19
 		    <ul class="dropdown-menu" role="menu">
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		    </ul>
24 24
 		</li>
25 25
 		<li class="dropdown">
26
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "owner-statistics-departure-airport" || strtolower($current_page) == "owner-statistics-departure-airport-country" || strtolower($current_page) == "owner-statistics-arrival-airport" || strtolower($current_page) == "owner-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
26
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "owner-statistics-departure-airport" || strtolower($current_page) == "owner-statistics-departure-airport-country" || strtolower($current_page) == "owner-statistics-arrival-airport" || strtolower($current_page) == "owner-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
27 27
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
28 28
 		    </a>
29 29
 		    <ul class="dropdown-menu" role="menu">
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 			  <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
34 34
 		    </ul>
35 35
 		</li>
36
-		<li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
-		<li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
36
+		<li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
+		<li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
38 38
 	</ul>
39 39
 </div>
40 40
 <?php
Please login to merge, or discard this patch.
Braces   +77 added lines, -11 removed lines patch added patch discarded remove patch
@@ -3,7 +3,13 @@  discard block
 block discarded – undo
3 3
 </span>
4 4
 <div class="stats_airline">
5 5
 	<form id="changedate" method="post">
6
-		<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" />
6
+		<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') {
7
+	echo $year.'-';
8
+}
9
+?><?php if (isset($month) && $month != '') {
10
+	echo $month;
11
+}
12
+?>" />
7 13
 	</form>
8 14
 </div>
9 15
 <?php
@@ -11,15 +17,39 @@  discard block
 block discarded – undo
11 17
 ?>
12 18
 <div class="sub-menu sub-menu-container">
13 19
 	<ul class="nav nav-pills">
14
-		<li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
20
+		<li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') {
21
+	echo '/'.$year;
22
+}
23
+?><?php if (isset($month) && $month != '') {
24
+	echo '/'.$month;
25
+}
26
+?>" <?php if (strtolower($current_page) == "owner-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
15 27
 		<li class="dropdown">
16 28
 		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "owner-statistics-aircraft" || strtolower($current_page) == "owner-statistics-registration" || strtolower($current_page) == "owner-statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
17 29
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
18 30
 		    </a>
19 31
 		    <ul class="dropdown-menu" role="menu">
20
-		      <li><a href="<?php print $globalURL; ?>/owner/statistics/aircraft/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Aircraft Type"); ?></a></li>
21
-					<li><a href="<?php print $globalURL; ?>/owner/statistics/registration/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Registration"); ?></a></li>
22
-					<li><a href="<?php print $globalURL; ?>/owner/statistics/manufacturer/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Manufacturer"); ?></a></li>
32
+		      <li><a href="<?php print $globalURL; ?>/owner/statistics/aircraft/<?php print $owner; ?><?php if (isset($year) && $year != '') {
33
+	echo '/'.$year;
34
+}
35
+?><?php if (isset($month) && $month != '') {
36
+	echo '/'.$month;
37
+}
38
+?>"><?php echo _("Aircraft Type"); ?></a></li>
39
+					<li><a href="<?php print $globalURL; ?>/owner/statistics/registration/<?php print $owner; ?><?php if (isset($year) && $year != '') {
40
+	echo '/'.$year;
41
+}
42
+?><?php if (isset($month) && $month != '') {
43
+	echo '/'.$month;
44
+}
45
+?>"><?php echo _("Registration"); ?></a></li>
46
+					<li><a href="<?php print $globalURL; ?>/owner/statistics/manufacturer/<?php print $owner; ?><?php if (isset($year) && $year != '') {
47
+	echo '/'.$year;
48
+}
49
+?><?php if (isset($month) && $month != '') {
50
+	echo '/'.$month;
51
+}
52
+?>"><?php echo _("Manufacturer"); ?></a></li>
23 53
 		    </ul>
24 54
 		</li>
25 55
 		<li class="dropdown">
@@ -27,14 +57,50 @@  discard block
 block discarded – undo
27 57
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
28 58
 		    </a>
29 59
 		    <ul class="dropdown-menu" role="menu">
30
-		      <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Departure Airport"); ?></a></li>
31
-		      <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
32
-			  <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Arrival Airport"); ?></a></li>
33
-			  <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
60
+		      <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') {
61
+	echo '/'.$year;
62
+}
63
+?><?php if (isset($month) && $month != '') {
64
+	echo '/'.$month;
65
+}
66
+?>"><?php echo _("Departure Airport"); ?></a></li>
67
+		      <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') {
68
+	echo '/'.$year;
69
+}
70
+?><?php if (isset($month) && $month != '') {
71
+	echo '/'.$month;
72
+}
73
+?>"><?php echo _("Departure Airport by Country"); ?></a></li>
74
+			  <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') {
75
+	echo '/'.$year;
76
+}
77
+?><?php if (isset($month) && $month != '') {
78
+	echo '/'.$month;
79
+}
80
+?>"><?php echo _("Arrival Airport"); ?></a></li>
81
+			  <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') {
82
+	echo '/'.$year;
83
+}
84
+?><?php if (isset($month) && $month != '') {
85
+	echo '/'.$month;
86
+}
87
+?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
34 88
 		    </ul>
35 89
 		</li>
36
-		<li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
-		<li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
90
+		<li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') {
91
+	echo '/'.$year;
92
+}
93
+?><?php if (isset($month) && $month != '') {
94
+	echo '/'.$month;
95
+}
96
+?>" <?php if (strtolower($current_page) == "owner-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
97
+		<li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') {
98
+	echo '/'.$year;
99
+}
100
+?><?php if (isset($month) && $month != '') {
101
+	echo '/'.$month;
102
+}
103
+?>" <?php if (strtolower($current_page) == "owner-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
38 104
 	</ul>
39 105
 </div>
40 106
 <?php
Please login to merge, or discard this patch.
manufacturer-detailed.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 $Spotter = new Spotter();
7
-if (!isset($_GET['aircraft_manufacturer'])){
7
+if (!isset($_GET['aircraft_manufacturer'])) {
8 8
 	header('Location: '.$globalURL.'');
9 9
 } else {
10 10
 	//calculuation for the pagination
11
-	if(!isset($_GET['limit']))
11
+	if (!isset($_GET['limit']))
12 12
 	{
13 13
 		$limit_start = 0;
14 14
 		$limit_end = 25;
15 15
 		$absolute_difference = 25;
16
-	}  else {
16
+	} else {
17 17
 		$limit_explode = explode(",", $_GET['limit']);
18 18
 		if (isset($limit_explode[1])) {
19 19
 			$limit_start = $limit_explode[0];
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
 	$limit_previous_1 = $limit_start - $absolute_difference;
33 33
 	$limit_previous_2 = $limit_end - $absolute_difference;
34 34
 	
35
-	$manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))));
36
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
35
+	$manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING))));
36
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
37 37
 	$page_url = $globalURL.'/manufacturer/'.$manufacturer;
38 38
 	
39 39
 	if ($sort != '') {
40
-		$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,$limit_start.",".$absolute_difference, $sort);
40
+		$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, $limit_start.",".$absolute_difference, $sort);
41 41
 	} else {
42
-		$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,$limit_start.",".$absolute_difference, '');
42
+		$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, $limit_start.",".$absolute_difference, '');
43 43
 	}
44 44
 	
45 45
 	if (!empty($spotter_array))
46 46
 	{
47
-		$title = sprintf(_("Detailed View for %s"),$manufacturer);
47
+		$title = sprintf(_("Detailed View for %s"), $manufacturer);
48 48
 
49 49
 		require_once('header.php');
50 50
 		print '<div class="select-item">';
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 		$Stats = new Stats();
54 54
 		$all_manufacturers = $Stats->getAllManufacturers();
55 55
 		if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
56
-		foreach($all_manufacturers as $all_manufacturer)
56
+		foreach ($all_manufacturers as $all_manufacturer)
57 57
 		{
58
-			if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
58
+			if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
59 59
 			{
60 60
 				print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
61 61
 			} else {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		print '</div>';
73 73
 
74 74
 		print '<div class="table column">';
75
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."),$manufacturer).'</p>';
75
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."), $manufacturer).'</p>';
76 76
 
77 77
 		include('manufacturer-sub-menu.php');
78 78
 		include('table-output.php'); 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 		$limit_start = 0;
14 14
 		$limit_end = 25;
15 15
 		$absolute_difference = 25;
16
-	}  else {
16
+	} else {
17 17
 		$limit_explode = explode(",", $_GET['limit']);
18 18
 		if (isset($limit_explode[1])) {
19 19
 			$limit_start = $limit_explode[0];
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
53 53
 		$Stats = new Stats();
54 54
 		$all_manufacturers = $Stats->getAllManufacturers();
55
-		if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
55
+		if (empty($all_manufacturers)) {
56
+			$all_manufacturers = $Spotter->getAllManufacturers();
57
+		}
56 58
 		foreach($all_manufacturers as $all_manufacturer)
57 59
 		{
58 60
 			if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
Please login to merge, or discard this patch.
tsk-geojson.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 		$id = $spotter_item['Waypoint']['@attributes']['id'];
24 24
 		if ($id == 0 || !is_numeric($id)) $id = $j;
25 25
 		$output .= '{"type": "Feature",';
26
-		    $output .= '"id": '.$id.',';
27
-		    $output .= '"properties": {';
26
+			$output .= '"id": '.$id.',';
27
+			$output .= '"properties": {';
28 28
 			$output .= '"type": "'.$spotter_item['@attributes']['type'].'",';
29 29
 			//$output .= '"id": "'.$spotter_item['Waypoint']['@attributes']['id'].'",';
30 30
 			$output .= '"name": "'.$spotter_item['Waypoint']['@attributes']['name'].'",';
@@ -35,31 +35,31 @@  discard block
 block discarded – undo
35 35
 			} elseif ($spotter_item['@attributes']['type'] == 'Finish') {
36 36
 				$output .= '"icon": "/images/tsk/tsk-finish.png"';
37 37
 			} else $output .= '"icon": "/images/tsk/number_'.$id.'.png"';
38
-		    $output .= '},';
39
-		    $output .= '"geometry": {';
38
+			$output .= '},';
39
+			$output .= '"geometry": {';
40 40
 			$output .= '"type": "Point",';
41 41
 			$output .= '"coordinates": [';
42
-			    $output .= $spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'];
42
+				$output .= $spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'];
43 43
 			$output .= ']';
44
-		    $output .= '}';
44
+			$output .= '}';
45 45
 		$output .= '},';
46 46
 		$j++;
47 47
 	}
48 48
 	// Lines
49 49
 	$output .= '{"type": "Feature",';
50
-	    $output .= '"properties": {';
50
+		$output .= '"properties": {';
51 51
 		$output .= '"type": "'.$spotter_array['@attributes']['type'].'"';
52
-	    $output .= '},';
53
-	    $output .= '"geometry": {';
52
+		$output .= '},';
53
+		$output .= '"geometry": {';
54 54
 		$output .= '"type": "LineString",';
55 55
 		$output .= '"coordinates": [';
56 56
 	foreach($spotter_array['Point'] as $spotter_item)
57 57
 	{
58
-			    $output .= '['.$spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'].'],';
58
+				$output .= '['.$spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'].'],';
59 59
 	}
60 60
 	$output  = substr($output, 0, -1);
61 61
 		$output .= ']';
62
-	    $output .= '}';
62
+		$output .= '}';
63 63
 	$output .= '},';
64 64
 	$output  = substr($output, 0, -1);
65 65
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 }
9 9
 header('Content-Type: text/javascript');
10 10
 
11
-$tskfile = filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL);
11
+$tskfile = filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL);
12 12
 
13 13
 $spotter_array = $TSK->parse_xml($tskfile);
14 14
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 if (!empty($spotter_array))
17 17
 {	  
18 18
 	$j = 0;
19
-	foreach($spotter_array['Point'] as $spotter_item)
19
+	foreach ($spotter_array['Point'] as $spotter_item)
20 20
 	{
21 21
 		date_default_timezone_set('UTC');
22 22
 		//waypoint plotting
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	    $output .= '"geometry": {';
54 54
 		$output .= '"type": "LineString",';
55 55
 		$output .= '"coordinates": [';
56
-	foreach($spotter_array['Point'] as $spotter_item)
56
+	foreach ($spotter_array['Point'] as $spotter_item)
57 57
 	{
58 58
 			    $output .= '['.$spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'].'],';
59 59
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
21 21
 		date_default_timezone_set('UTC');
22 22
 		//waypoint plotting
23 23
 		$id = $spotter_item['Waypoint']['@attributes']['id'];
24
-		if ($id == 0 || !is_numeric($id)) $id = $j;
24
+		if ($id == 0 || !is_numeric($id)) {
25
+			$id = $j;
26
+		}
25 27
 		$output .= '{"type": "Feature",';
26 28
 		    $output .= '"id": '.$id.',';
27 29
 		    $output .= '"properties": {';
@@ -34,7 +36,9 @@  discard block
 block discarded – undo
34 36
 				$output .= '"icon": "/images/tsk/tsk-start.png"';
35 37
 			} elseif ($spotter_item['@attributes']['type'] == 'Finish') {
36 38
 				$output .= '"icon": "/images/tsk/tsk-finish.png"';
37
-			} else $output .= '"icon": "/images/tsk/number_'.$id.'.png"';
39
+			} else {
40
+				$output .= '"icon": "/images/tsk/number_'.$id.'.png"';
41
+			}
38 42
 		    $output .= '},';
39 43
 		    $output .= '"geometry": {';
40 44
 			$output .= '"type": "Point",';
Please login to merge, or discard this patch.
js/map.2d.js.php 3 patches
Spacing   +15 added lines, -15 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
 if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = '';
8 8
 // Compressed GeoJson is used if true
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
21 21
 	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
22 22
 	else $enddate = time();
23
-	setcookie("archive_begin",$begindate);
24
-	setcookie("archive_end",$enddate);
25
-	setcookie("archive_update",$lastupd);
26
-	setcookie("archive_speed",$archivespeed);
23
+	setcookie("archive_begin", $begindate);
24
+	setcookie("archive_end", $enddate);
25
+	setcookie("archive_update", $lastupd);
26
+	setcookie("archive_speed", $archivespeed);
27 27
 ?>
28 28
 document.cookie =  'archive_begin=<?php print $begindate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
29 29
 document.cookie =  'archive_end=<?php print $enddate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 <?php
76 76
 	}
77 77
 	if (isset($_GET['ident'])) {
78
-		$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
78
+		$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
79 79
 	}
80 80
 	if (isset($_GET['flightaware_id'])) {
81
-		$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
81
+		$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
82 82
 	}
83 83
 	if (isset($_GET['latitude'])) {
84
-		$latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING);
84
+		$latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING);
85 85
 	}
86 86
 	if (isset($_GET['longitude'])) {
87
-		$longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING);
87
+		$longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING);
88 88
 	}
89 89
 ?>
90 90
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	} else {
113 113
 		if ((isset($globalCenterLatitude) && $globalCenterLatitude != '' && isset($globalCenterLongitude) && $globalCenterLongitude != '') || isset($_COOKIE['lastcentercoord'])) {
114 114
 			if (isset($_COOKIE['lastcentercoord'])) {
115
-				$lastcentercoord = explode(',',$_COOKIE['lastcentercoord']);
115
+				$lastcentercoord = explode(',', $_COOKIE['lastcentercoord']);
116 116
 				$viewcenterlatitude = $lastcentercoord[0];
117 117
 				$viewcenterlongitude = $lastcentercoord[1];
118 118
 				$viewzoom = $lastcentercoord[2];
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	     || navigator.userAgent.match(/BlackBerry/i)
134 134
 	     || navigator.userAgent.match(/Windows Phone/i))
135 135
 	{
136
-		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom-1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>;
136
+		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom - 1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>;
137 137
 	} else {
138 138
 		var zoom = <?php if (isset($viewzoom)) print $viewzoom; else print '9'; ?>;
139 139
 	}
@@ -227,19 +227,19 @@  discard block
 block discarded – undo
227 227
 	map.addLayer(yandexLayer);
228 228
 <?php
229 229
 	} elseif ($MapType == 'Bing-Aerial') {
230
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
230
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
231 231
 ?>
232 232
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
233 233
 	map.addLayer(bingLayer);
234 234
 <?php
235 235
 	} elseif ($MapType == 'Bing-Hybrid') {
236
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
236
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
237 237
 ?>
238 238
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
239 239
 	map.addLayer(bingLayer);
240 240
 <?php
241 241
 	} elseif ($MapType == 'Bing-Road') {
242
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
242
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
243 243
 ?>
244 244
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
245 245
 	map.addLayer(bingLayer);
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 
358 358
 	function update_tsk() {
359 359
 		var bbox = map.getBounds().toBBoxString();
360
-		var tskLayerQuery = $.getJSON("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php echo filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); ?>",function (data) {
360
+		var tskLayerQuery = $.getJSON("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php echo filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); ?>",function (data) {
361 361
 		    tskLayer = L.geoJson(data,{
362 362
 			onEachFeature: function (feature, layer) {
363 363
 			    tskPopup(feature, layer);
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	};
376 376
 
377 377
 <?php
378
-    if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) {
378
+	if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) {
379 379
 ?>
380 380
 	function tskPopup (feature, layer) {
381 381
 		var output = '';
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	};
411 411
 	update_tsk();
412 412
 <?php
413
-    }
413
+	}
414 414
 ?>
415 415
 	map.on('moveend', function() {
416 416
 		//if (map.getZoom() > 7) {
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
 setInterval(function(){if (noTimeout) update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
427 427
 
428 428
 <?php
429
-    // Add support for custom json via $globalMapJson
430
-    if (isset($globalMapJson) && is_array($globalMapJson)) {
429
+	// Add support for custom json via $globalMapJson
430
+	if (isset($globalMapJson) && is_array($globalMapJson)) {
431 431
 	foreach ($globalMapJson as $json) {
432
-	    if (isset($json['url'])) {
432
+		if (isset($json['url'])) {
433 433
 ?>
434 434
 update_genLayer('<?php print $json['url']; ?>');
435 435
 <?php
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 setInterval(function(){if (noTimeout) update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>);
439 439
 <?php
440 440
 		}
441
-	    }
441
+		}
442
+	}
442 443
 	}
443
-    }
444 444
 
445 445
 ?>
446 446
 //adds the bootstrap tooltip to the map icons
Please login to merge, or discard this patch.
Braces   +127 added lines, -30 removed lines patch added patch discarded remove patch
@@ -4,10 +4,15 @@  discard block
 block discarded – undo
4 4
 
5 5
 setcookie("MapFormat",'2d');
6 6
 
7
-if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = '';
7
+if (!isset($globalOpenWeatherMapKey)) {
8
+	$globalOpenWeatherMapKey = '';
9
+}
8 10
 // Compressed GeoJson is used if true
9
-if (!isset($globalJsonCompress)) $compress = true;
10
-else $compress = $globalJsonCompress;
11
+if (!isset($globalJsonCompress)) {
12
+	$compress = true;
13
+} else {
14
+	$compress = $globalJsonCompress;
15
+}
11 16
 if (isset($_GET['archive'])) {
12 17
 	$archive = true;
13 18
 	//$archiveupdatetime = 50;
@@ -18,8 +23,11 @@  discard block
 block discarded – undo
18 23
 	//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
19 24
 	//$lastupd = 20;
20 25
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
21
-	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
22
-	else $enddate = time();
26
+	if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
27
+		$enddate = $_GET['enddate'];
28
+	} else {
29
+		$enddate = time();
30
+	}
23 31
 	setcookie("archive_begin",$begindate);
24 32
 	setcookie("archive_end",$enddate);
25 33
 	setcookie("archive_update",$lastupd);
@@ -107,7 +115,17 @@  discard block
 block discarded – undo
107 115
 	}
108 116
 
109 117
 	//create the map
110
-	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);
118
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
119
+	print $latitude;
120
+} else {
121
+	print $globalCenterLatitude;
122
+}
123
+?>,<?php if (isset($longitude)) {
124
+	print $longitude;
125
+} else {
126
+	print $globalCenterLongitude;
127
+}
128
+?>], zoom);
111 129
 <?php
112 130
 	} else {
113 131
 		if ((isset($globalCenterLatitude) && $globalCenterLatitude != '' && isset($globalCenterLongitude) && $globalCenterLongitude != '') || isset($_COOKIE['lastcentercoord'])) {
@@ -133,9 +151,21 @@  discard block
 block discarded – undo
133 151
 	     || navigator.userAgent.match(/BlackBerry/i)
134 152
 	     || navigator.userAgent.match(/Windows Phone/i))
135 153
 	{
136
-		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom-1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>;
154
+		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) {
155
+	print $viewzoom-1;
156
+} elseif (isset($viewzoom)) {
157
+	print $viewzoom;
158
+} else {
159
+	print '8';
160
+}
161
+?>;
137 162
 	} else {
138
-		var zoom = <?php if (isset($viewzoom)) print $viewzoom; else print '9'; ?>;
163
+		var zoom = <?php if (isset($viewzoom)) {
164
+	print $viewzoom;
165
+} else {
166
+	print '9';
167
+}
168
+?>;
139 169
 	}
140 170
 
141 171
 	//create the map
@@ -161,16 +191,27 @@  discard block
 block discarded – undo
161 191
 	bounds = L.latLngBounds(southWest,northEast);
162 192
 	//a few title layers
163 193
 <?php
164
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
165
-	else $MapType = $globalMapProvider;
194
+	if (isset($_COOKIE['MapType'])) {
195
+		$MapType = $_COOKIE['MapType'];
196
+	} else {
197
+		$MapType = $globalMapProvider;
198
+	}
166 199
 
167 200
 	if ($MapType == 'Mapbox') {
168
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
169
-		else $MapBoxId = $_COOKIE['MapTypeId'];
170
-?>
201
+		if ($_COOKIE['MapTypeId'] == 'default') {
202
+			$MapBoxId = $globalMapboxId;
203
+		} else {
204
+			$MapBoxId = $_COOKIE['MapTypeId'];
205
+		}
206
+		?>
171 207
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
172 208
 	    maxZoom: 18,
173
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
209
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
210
+	print 'false';
211
+} else {
212
+	print 'true';
213
+}
214
+?>,
174 215
 	    attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
175 216
 	    id: '<?php print $MapBoxId; ?>',
176 217
 	    token: '<?php print $globalMapboxToken; ?>'
@@ -189,7 +230,12 @@  discard block
 block discarded – undo
189 230
 ?>
190 231
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
191 232
 	    maxZoom: 18,
192
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
233
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
234
+	print 'false';
235
+} else {
236
+	print 'true';
237
+}
238
+?>,
193 239
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
194 240
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
195 241
 	}).addTo(map);
@@ -198,7 +244,12 @@  discard block
 block discarded – undo
198 244
 ?>
199 245
 	L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
200 246
 	    maxZoom: 18,
201
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
247
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
248
+	print 'false';
249
+} else {
250
+	print 'true';
251
+}
252
+?>,
202 253
 	    attribution: 'Tiles &copy; Esri &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012'
203 254
 	}).addTo(map);
204 255
 <?php
@@ -206,7 +257,12 @@  discard block
 block discarded – undo
206 257
 ?>
207 258
 	L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
208 259
 	    maxZoom: 18,
209
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
260
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
261
+	print 'false';
262
+} else {
263
+	print 'true';
264
+}
265
+?>,
210 266
 	    attribution: 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
211 267
 	}).addTo(map);
212 268
 <?php
@@ -214,7 +270,12 @@  discard block
 block discarded – undo
214 270
 ?>
215 271
 	L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}', {
216 272
 	    maxZoom: 18,
217
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
273
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
274
+	print 'false';
275
+} else {
276
+	print 'true';
277
+}
278
+?>,
218 279
 	    attribution: 'Tiles &copy; Esri &mdash; National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC'
219 280
 	}).addTo(map);
220 281
 <?php
@@ -259,20 +320,26 @@  discard block
 block discarded – undo
259 320
 	map.addLayer(yandexLayer);
260 321
 <?php
261 322
 	} elseif ($MapType == 'Bing-Aerial') {
262
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
263
-?>
323
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
324
+			setcookie('MapType','OpenStreetMap');
325
+		}
326
+		?>
264 327
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
265 328
 	map.addLayer(bingLayer);
266 329
 <?php
267 330
 	} elseif ($MapType == 'Bing-Hybrid') {
268
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
269
-?>
331
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
332
+			setcookie('MapType','OpenStreetMap');
333
+		}
334
+		?>
270 335
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
271 336
 	map.addLayer(bingLayer);
272 337
 <?php
273 338
 	} elseif ($MapType == 'Bing-Road') {
274
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
275
-?>
339
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
340
+			setcookie('MapType','OpenStreetMap');
341
+		}
342
+		?>
276 343
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
277 344
 	map.addLayer(bingLayer);
278 345
 <?php
@@ -301,7 +368,12 @@  discard block
 block discarded – undo
301 368
 	    maxZoom: 5,
302 369
 	    tms : true,
303 370
 	    zindex : 3,
304
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
371
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
372
+	print 'false';
373
+} else {
374
+	print 'true';
375
+}
376
+?>,
305 377
 	    attribution: 'Natural Earth'
306 378
 	}).addTo(map);
307 379
 <?php
@@ -309,9 +381,24 @@  discard block
 block discarded – undo
309 381
 		$customid = $MapType;
310 382
 ?>
311 383
 	L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
312
-	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
313
-	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
314
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
384
+	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
385
+	print $globalMapCustomLayer[$customid]['maxZoom'];
386
+} else {
387
+	print '18';
388
+}
389
+?>,
390
+	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
391
+	print $globalMapCustomLayer[$customid]['minZoom'];
392
+} else {
393
+	print '0';
394
+}
395
+?>,
396
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
397
+	print 'false';
398
+} else {
399
+	print 'true';
400
+}
401
+?>,
315 402
 	    attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
316 403
 	}).addTo(map);
317 404
 
@@ -351,7 +438,12 @@  discard block
 block discarded – undo
351 438
 		}
352 439
 	} elseif ($globalBounding == 'circle') {
353 440
 ?>
354
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
441
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
442
+	print $globalBoundingCircleSize;
443
+} else {
444
+	print '70000';
445
+}
446
+?>,{
355 447
 	    color: '#92C7D1',
356 448
 	    fillColor: '#92C7D1',
357 449
 	    fillOpacity: 0.3,
@@ -443,7 +535,12 @@  discard block
 block discarded – undo
443 535
 		createCookie('lastcentercoord',map.getCenter().lat+','+map.getCenter().lng+','+map.getZoom(),2);
444 536
 	});
445 537
 update_locationsLayer();
446
-setInterval(function(){if (noTimeout) update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
538
+setInterval(function(){if (noTimeout) update_locationsLayer()},<?php if (isset($globalMapRefresh)) {
539
+	print $globalMapRefresh*1000*2;
540
+} else {
541
+	print '60000';
542
+}
543
+?>);
447 544
 
448 545
 <?php
449 546
     // Add support for custom json via $globalMapJson
Please login to merge, or discard this patch.
require/class.Common.php 4 patches
Doc Comments   +15 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,6 +97,10 @@  discard block
 block discarded – undo
97 97
 		return strlen($headerLine); // Needed by curl
98 98
 	}
99 99
 
100
+	/**
101
+	 * @param string $url
102
+	 * @param string $file
103
+	 */
100 104
 	public static function download($url, $file, $referer = '') {
101 105
 		global $globalDebug, $globalProxy, $globalForceIPv4;
102 106
 		$fp = fopen($file, 'w');
@@ -121,6 +125,9 @@  discard block
 block discarded – undo
121 125
 		fclose($fp);
122 126
 	}
123 127
 
128
+	/**
129
+	 * @param string $in_file
130
+	 */
124 131
 	public static function gunzip($in_file,$out_file_name = '') {
125 132
 		//echo $in_file.' -> '.$out_file_name."\n";
126 133
 		$buffer_size = 4096; // read 4kb at a time
@@ -272,7 +279,7 @@  discard block
 block discarded – undo
272 279
 	* Check is distance realistic
273 280
 	* @param int $timeDifference the time between the reception of both messages
274 281
 	* @param float $distance distance covered
275
-	* @return whether distance is realistic
282
+	* @return boolean distance is realistic
276 283
 	*/
277 284
 	public function withinThreshold ($timeDifference, $distance) {
278 285
 		$x = abs($timeDifference);
@@ -295,6 +302,9 @@  discard block
 block discarded – undo
295 302
 	}
296 303
 
297 304
 
305
+	/**
306
+	 * @param string $latlong
307
+	 */
298 308
 	public function convertDec($dms,$latlong) {
299 309
 		if ($latlong == 'latitude') {
300 310
 			$deg = substr($dms, 0, 2);
@@ -306,6 +316,9 @@  discard block
 block discarded – undo
306 316
 		return $deg+(($min*60)/3600);
307 317
 	}
308 318
 	
319
+	/**
320
+	 * @param string $latlong
321
+	 */
309 322
 	public function convertDM($coord,$latlong) {
310 323
 		if ($latlong == 'latitude') {
311 324
 			if ($coord < 0) $NSEW = 'S';
@@ -443,7 +456,7 @@  discard block
 block discarded – undo
443 456
 	/**
444 457
 	* Returns list of available locales
445 458
 	*
446
-	* @return array
459
+	* @return string[]
447 460
 	 */
448 461
 	public function listLocaleDir()
449 462
 	{
Please login to merge, or discard this patch.
Indentation   +156 added lines, -156 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 = '', $sizelimit = false, $async = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Convert a HTML table to an array
170
-	* @param String $data HTML page
171
-	* @return Array array of the tables in HTML page
172
-	*/
169
+	 * Convert a HTML table to an array
170
+	 * @param String $data HTML page
171
+	 * @return Array array of the tables in HTML page
172
+	 */
173 173
 	public function table2array($data) {
174 174
 		if (!is_string($data)) return array();
175 175
 		if ($data == '') return array();
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
 	}
204 204
 	
205 205
 	/**
206
-	* Convert <p> part of a HTML page to an array
207
-	* @param String $data HTML page
208
-	* @return Array array of the <p> in HTML page
209
-	*/
206
+	 * Convert <p> part of a HTML page to an array
207
+	 * @param String $data HTML page
208
+	 * @return Array array of the <p> in HTML page
209
+	 */
210 210
 	public function text2array($data) {
211 211
 		$html = str_get_html($data);
212 212
 		if ($html === false) return array();
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 
223 223
 	/**
224
-	* Give distance between 2 coordonnates
225
-	* @param Float $lat latitude of first point
226
-	* @param Float $lon longitude of first point
227
-	* @param Float $latc latitude of second point
228
-	* @param Float $lonc longitude of second point
229
-	* @param String $unit km else no unit used
230
-	* @return Float Distance in $unit
231
-	*/
224
+	 * Give distance between 2 coordonnates
225
+	 * @param Float $lat latitude of first point
226
+	 * @param Float $lon longitude of first point
227
+	 * @param Float $latc latitude of second point
228
+	 * @param Float $lonc longitude of second point
229
+	 * @param String $unit km else no unit used
230
+	 * @return Float Distance in $unit
231
+	 */
232 232
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233 233
 		if ($lat == $latc && $lon == $lonc) return 0;
234 234
 		$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;
@@ -246,25 +246,25 @@  discard block
 block discarded – undo
246 246
 	}
247 247
 
248 248
 	/**
249
-	* Give plunge between 2 altitudes and distance
250
-	* @param Float $initial_altitude altitude of first point in m
251
-	* @param Float $final_altitude altitude of second point in m
252
-	* @param String $distance distance between two points in m
253
-	* @return Float plunge
254
-	*/
249
+	 * Give plunge between 2 altitudes and distance
250
+	 * @param Float $initial_altitude altitude of first point in m
251
+	 * @param Float $final_altitude altitude of second point in m
252
+	 * @param String $distance distance between two points in m
253
+	 * @return Float plunge
254
+	 */
255 255
 	public function plunge($initial_altitude,$final_altitude,$distance) {
256 256
 		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
257 257
 		return $plunge;
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Give azimuth between 2 coordonnates
262
-	* @param Float $lat latitude of first point
263
-	* @param Float $lon longitude of first point
264
-	* @param Float $latc latitude of second point
265
-	* @param Float $lonc longitude of second point
266
-	* @return Float Azimuth
267
-	*/
261
+	 * Give azimuth between 2 coordonnates
262
+	 * @param Float $lat latitude of first point
263
+	 * @param Float $lon longitude of first point
264
+	 * @param Float $latc latitude of second point
265
+	 * @param Float $lonc longitude of second point
266
+	 * @return Float Azimuth
267
+	 */
268 268
 	public function azimuth($lat, $lon, $latc, $lonc) {
269 269
 		$dX = $latc - $lat;
270 270
 		$dY = $lonc - $lon;
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 	
276 276
 	
277 277
 	/**
278
-	* Check is distance realistic
279
-	* @param int $timeDifference the time between the reception of both messages
280
-	* @param float $distance distance covered
281
-	* @return whether distance is realistic
282
-	*/
278
+	 * Check is distance realistic
279
+	 * @param int $timeDifference the time between the reception of both messages
280
+	 * @param float $distance distance covered
281
+	 * @return whether distance is realistic
282
+	 */
283 283
 	public function withinThreshold ($timeDifference, $distance) {
284 284
 		$x = abs($timeDifference);
285 285
 		$d = abs($distance);
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	}
298 298
 
299 299
 	public function isInteger($input){
300
-	    return(ctype_digit(strval($input)));
300
+		return(ctype_digit(strval($input)));
301 301
 	}
302 302
 
303 303
 
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
 	}
329 329
 	
330 330
 	/**
331
-	* Copy folder contents
332
-	* @param       string   $source    Source path
333
-	* @param       string   $dest      Destination path
334
-	* @return      bool     Returns true on success, false on failure
335
-	*/
331
+	 * Copy folder contents
332
+	 * @param       string   $source    Source path
333
+	 * @param       string   $dest      Destination path
334
+	 * @return      bool     Returns true on success, false on failure
335
+	 */
336 336
 	public function xcopy($source, $dest)
337 337
 	{
338 338
 		$files = glob($source.'*.*');
@@ -344,20 +344,20 @@  discard block
 block discarded – undo
344 344
 	}
345 345
 	
346 346
 	/**
347
-	* Check if an url exist
348
-	* @param	String $url url to check
349
-	* @return	bool Return true on succes false on failure
350
-	*/
347
+	 * Check if an url exist
348
+	 * @param	String $url url to check
349
+	 * @return	bool Return true on succes false on failure
350
+	 */
351 351
 	public function urlexist($url){
352 352
 		$headers=get_headers($url);
353 353
 		return stripos($headers[0],"200 OK")?true:false;
354 354
 	}
355 355
 	
356 356
 	/**
357
-	* Convert hexa to string
358
-	* @param	String $hex data in hexa
359
-	* @return	String Return result
360
-	*/
357
+	 * Convert hexa to string
358
+	 * @param	String $hex data in hexa
359
+	 * @return	String Return result
360
+	 */
361 361
 	public function hex2str($hex) {
362 362
 		$str = '';
363 363
 		$hexln = strlen($hex);
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 	}
367 367
 	
368 368
 	/**
369
-	* Convert hexa color to rgb
370
-	* @param	String $hex data in hexa
371
-	* @return	String Return result
372
-	*/
369
+	 * Convert hexa color to rgb
370
+	 * @param	String $hex data in hexa
371
+	 * @return	String Return result
372
+	 */
373 373
 	public function hex2rgb($hex) {
374 374
 		$hex = str_replace('#','',$hex);
375 375
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 	}
448 448
 	
449 449
 	/**
450
-	* Returns list of available locales
451
-	*
452
-	* @return array
450
+	 * Returns list of available locales
451
+	 *
452
+	 * @return array
453 453
 	 */
454 454
 	public function listLocaleDir()
455 455
 	{
@@ -548,100 +548,100 @@  discard block
 block discarded – undo
548 548
 	public function remove_accents($string) {
549 549
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
550 550
 		$chars = array(
551
-		    // Decompositions for Latin-1 Supplement
552
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
553
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
554
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
555
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
556
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
557
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
558
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
559
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
560
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
561
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
562
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
563
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
564
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
565
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
566
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
567
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
568
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
569
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
570
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
571
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
572
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
573
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
574
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
575
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
576
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
577
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
578
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
579
-		    chr(195).chr(191) => 'y',
580
-		    // Decompositions for Latin Extended-A
581
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
582
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
583
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
584
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
585
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
586
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
587
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
588
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
589
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
590
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
591
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
592
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
593
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
594
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
595
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
596
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
597
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
598
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
599
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
600
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
601
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
602
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
603
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
604
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
605
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
606
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
607
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
608
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
609
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
610
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
611
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
612
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
613
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
614
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
615
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
616
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
617
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
618
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
619
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
620
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
621
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
622
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
623
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
624
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
625
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
626
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
627
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
628
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
629
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
630
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
631
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
632
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
633
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
634
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
635
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
636
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
637
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
638
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
639
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
640
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
641
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
642
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
643
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
644
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
551
+			// Decompositions for Latin-1 Supplement
552
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
553
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
554
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
555
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
556
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
557
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
558
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
559
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
560
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
561
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
562
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
563
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
564
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
565
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
566
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
567
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
568
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
569
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
570
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
571
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
572
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
573
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
574
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
575
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
576
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
577
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
578
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
579
+			chr(195).chr(191) => 'y',
580
+			// Decompositions for Latin Extended-A
581
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
582
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
583
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
584
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
585
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
586
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
587
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
588
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
589
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
590
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
591
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
592
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
593
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
594
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
595
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
596
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
597
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
598
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
599
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
600
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
601
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
602
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
603
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
604
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
605
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
606
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
607
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
608
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
609
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
610
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
611
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
612
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
613
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
614
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
615
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
616
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
617
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
618
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
619
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
620
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
621
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
622
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
623
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
624
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
625
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
626
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
627
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
628
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
629
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
630
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
631
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
632
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
633
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
634
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
635
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
636
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
637
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
638
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
639
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
640
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
641
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
642
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
643
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
644
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
645 645
 		);
646 646
 		$string = strtr($string, $chars);
647 647
 		return $string;
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 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 = '', $sizelimit = false, $async = false) {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false) {
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
 			}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		if ($sizelimit === true) {
69 69
 			curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
70 70
 			curl_setopt($ch, CURLOPT_NOPROGRESS, false);
71
-			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){
71
+			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) {
72 72
 				return ($downloaded > (3*1024)) ? 1 : 0;
73 73
 			});
74 74
 		}
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 		$result = curl_exec($ch);
80 80
 		$info = curl_getinfo($ch);
81 81
 		curl_close($ch);
82
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
82
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
83 83
 			echo "Cloudflare Detected\n";
84 84
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
85 85
 			$useragent = UAgent::random();
86 86
 			cloudflare::useUserAgent($useragent);
87 87
 			if ($clearanceCookie = cloudflare::bypass($url)) {
88
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
88
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
89 89
 			}
90 90
 		} else {
91 91
 			return $result;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110 110
 		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
111 111
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
112
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
113 113
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
114 114
 			}
115 115
 		}
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 		fclose($fp);
125 125
 	}
126 126
 
127
-	public static function gunzip($in_file,$out_file_name = '') {
127
+	public static function gunzip($in_file, $out_file_name = '') {
128 128
 		//echo $in_file.' -> '.$out_file_name."\n";
129 129
 		$buffer_size = 4096; // read 4kb at a time
130 130
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
131 131
 		if ($in_file != '' && file_exists($in_file)) {
132 132
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
133
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
134
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
135 135
 			else {
136 136
 				echo 'gzopen not available';
137 137
 				die;
138 138
 			}
139 139
 			$out_file = fopen($out_file_name, 'wb'); 
140
-			while(!gzeof($file)) {
140
+			while (!gzeof($file)) {
141 141
 				fwrite($out_file, gzread($file, $buffer_size));
142 142
 			}  
143 143
 			fclose($out_file);
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
 		}
146 146
 	}
147 147
 
148
-	public static function bunzip2($in_file,$out_file_name = '') {
148
+	public static function bunzip2($in_file, $out_file_name = '') {
149 149
 		//echo $in_file.' -> '.$out_file_name."\n";
150 150
 		$buffer_size = 4096; // read 4kb at a time
151 151
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
152 152
 		if ($in_file != '' && file_exists($in_file)) {
153 153
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
154
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
155 155
 			else {
156 156
 				echo 'bzopen not available';
157 157
 				die;
158 158
 			}
159 159
 			$out_file = fopen($out_file_name, 'wb'); 
160
-			while(!feof($file)) {
160
+			while (!feof($file)) {
161 161
 				fwrite($out_file, bzread($file, $buffer_size));
162 162
 			}  
163 163
 			fclose($out_file);
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 		if ($data == '') return array();
176 176
 		$html = str_get_html($data);
177 177
 		if ($html === false) return array();
178
-		$tabledata=array();
179
-		foreach($html->find('tr') as $element)
178
+		$tabledata = array();
179
+		foreach ($html->find('tr') as $element)
180 180
 		{
181 181
 			$td = array();
182
-			foreach( $element->find('th') as $row)
182
+			foreach ($element->find('th') as $row)
183 183
 			{
184 184
 				$td [] = trim($row->plaintext);
185 185
 			}
186
-			$td=array_filter($td);
186
+			$td = array_filter($td);
187 187
 			$tabledata[] = $td;
188 188
 
189 189
 			$td = array();
190 190
 			$tdi = array();
191
-			foreach( $element->find('td') as $row)
191
+			foreach ($element->find('td') as $row)
192 192
 			{
193 193
 				$td [] = trim($row->plaintext);
194 194
 				$tdi [] = trim($row->innertext);
195 195
 			}
196
-			$td=array_filter($td);
197
-			$tdi=array_filter($tdi);
198
-			$tabledata[]=array_merge($td,$tdi);
196
+			$td = array_filter($td);
197
+			$tdi = array_filter($tdi);
198
+			$tabledata[] = array_merge($td, $tdi);
199 199
 		}
200 200
 		$html->clear();
201 201
 		unset($html);
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	public function text2array($data) {
211 211
 		$html = str_get_html($data);
212 212
 		if ($html === false) return array();
213
-		$tabledata=array();
214
-		foreach($html->find('p') as $element)
213
+		$tabledata = array();
214
+		foreach ($html->find('p') as $element)
215 215
 		{
216 216
 			$tabledata [] = trim($element->plaintext);
217 217
 		}
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	*/
232 232
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233 233
 		if ($lat == $latc && $lon == $lonc) return 0;
234
-		$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;
234
+		$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;
235 235
 		if ($unit == "km") {
236
-			return round($dist * 1.609344);
236
+			return round($dist*1.609344);
237 237
 		} elseif ($unit == "m") {
238
-			return round($dist * 1.609344 * 1000);
238
+			return round($dist*1.609344*1000);
239 239
 		} elseif ($unit == "mile" || $unit == "mi") {
240 240
 			return round($dist);
241 241
 		} elseif ($unit == "nm") {
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	* @param String $distance distance between two points in m
253 253
 	* @return Float plunge
254 254
 	*/
255
-	public function plunge($initial_altitude,$final_altitude,$distance) {
256
-		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
255
+	public function plunge($initial_altitude, $final_altitude, $distance) {
256
+		$plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance));
257 257
 		return $plunge;
258 258
 	}
259 259
 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	public function azimuth($lat, $lon, $latc, $lonc) {
269 269
 		$dX = $latc - $lat;
270 270
 		$dY = $lonc - $lon;
271
-		$azimuth = rad2deg(atan2($dY,$dX));
272
-		if ($azimuth < 0) return $azimuth+360;
271
+		$azimuth = rad2deg(atan2($dY, $dX));
272
+		if ($azimuth < 0) return $azimuth + 360;
273 273
 		return $azimuth;
274 274
 	}
275 275
 	
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	* @param float $distance distance covered
281 281
 	* @return whether distance is realistic
282 282
 	*/
283
-	public function withinThreshold ($timeDifference, $distance) {
283
+	public function withinThreshold($timeDifference, $distance) {
284 284
 		$x = abs($timeDifference);
285 285
 		$d = abs($distance);
286 286
 		if ($x == 0 || $d == 0) return true;
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
 		return ($array !== array_values($array));
297 297
 	}
298 298
 
299
-	public function isInteger($input){
299
+	public function isInteger($input) {
300 300
 	    return(ctype_digit(strval($input)));
301 301
 	}
302 302
 
303 303
 
304
-	public function convertDec($dms,$latlong) {
304
+	public function convertDec($dms, $latlong) {
305 305
 		if ($latlong == 'latitude') {
306 306
 			$deg = substr($dms, 0, 2);
307 307
 			$min = substr($dms, 2, 4);
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 			$deg = substr($dms, 0, 3);
310 310
 			$min = substr($dms, 3, 5);
311 311
 		}
312
-		return $deg+(($min*60)/3600);
312
+		return $deg + (($min*60)/3600);
313 313
 	}
314 314
 	
315
-	public function convertDM($coord,$latlong) {
315
+	public function convertDM($coord, $latlong) {
316 316
 		if ($latlong == 'latitude') {
317 317
 			if ($coord < 0) $NSEW = 'S';
318 318
 			else $NSEW = 'N';
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 		}
323 323
 		$coord = abs($coord);
324 324
 		$deg = floor($coord);
325
-		$coord = ($coord-$deg)*60;
325
+		$coord = ($coord - $deg)*60;
326 326
 		$min = $coord;
327
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
327
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
328 328
 	}
329 329
 	
330 330
 	/**
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	public function xcopy($source, $dest)
337 337
 	{
338 338
 		$files = glob($source.'*.*');
339
-		foreach($files as $file){
340
-			$file_to_go = str_replace($source,$dest,$file);
339
+		foreach ($files as $file) {
340
+			$file_to_go = str_replace($source, $dest, $file);
341 341
 			copy($file, $file_to_go);
342 342
 		}
343 343
 		return true;
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 	* @param	String $url url to check
349 349
 	* @return	bool Return true on succes false on failure
350 350
 	*/
351
-	public function urlexist($url){
352
-		$headers=get_headers($url);
353
-		return stripos($headers[0],"200 OK")?true:false;
351
+	public function urlexist($url) {
352
+		$headers = get_headers($url);
353
+		return stripos($headers[0], "200 OK") ?true:false;
354 354
 	}
355 355
 	
356 356
 	/**
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	public function hex2str($hex) {
362 362
 		$str = '';
363 363
 		$hexln = strlen($hex);
364
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
364
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
365 365
 		return $str;
366 366
 	}
367 367
 	
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	* @return	String Return result
372 372
 	*/
373 373
 	public function hex2rgb($hex) {
374
-		$hex = str_replace('#','',$hex);
374
+		$hex = str_replace('#', '', $hex);
375 375
 		return sscanf($hex, "%02x%02x%02x"); 
376 376
 	}
377 377
 	
@@ -379,33 +379,33 @@  discard block
 block discarded – undo
379 379
 		//difference in longitudinal coordinates
380 380
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
381 381
 		//difference in the phi of latitudinal coordinates
382
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
382
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
383 383
 		//we need to recalculate $dLon if it is greater than pi
384
-		if(abs($dLon) > pi()) {
385
-			if($dLon > 0) {
386
-				$dLon = (2 * pi() - $dLon) * -1;
384
+		if (abs($dLon) > pi()) {
385
+			if ($dLon > 0) {
386
+				$dLon = (2*pi() - $dLon)*-1;
387 387
 			} else {
388
-				$dLon = 2 * pi() + $dLon;
388
+				$dLon = 2*pi() + $dLon;
389 389
 			}
390 390
 		}
391 391
 		//return the angle, normalized
392
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
392
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
393 393
 	}
394 394
 
395
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
395
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
396 396
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
397
-		$a = -($lon2-$lon1);
397
+		$a = -($lon2 - $lon1);
398 398
 		$b = $lat2 - $lat1;
399
-		$c = -($a*$lat1+$b*$lon1);
400
-		$d = $a*$lat3+$b*$lon3+$c;
399
+		$c = -($a*$lat1 + $b*$lon1);
400
+		$d = $a*$lat3 + $b*$lon3 + $c;
401 401
 		if ($d > -$approx && $d < $approx) return true;
402 402
 		else return false;
403 403
 	}
404 404
 	
405 405
 	public function array_merge_noappend() {
406 406
 		$output = array();
407
-		foreach(func_get_args() as $array) {
408
-			foreach($array as $key => $value) {
407
+		foreach (func_get_args() as $array) {
408
+			foreach ($array as $key => $value) {
409 409
 				$output[$key] = isset($output[$key]) ?
410 410
 				array_merge($output[$key], $value) : $value;
411 411
 			}
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		return $result;
470 470
 	}
471 471
 
472
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
472
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
473 473
 		global $globalMapRefresh;
474 474
 		if ($seconds == '') {
475 475
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 		$latitude = deg2rad($latitude);
481 481
 		$longitude = deg2rad($longitude);
482 482
 		$bearing = deg2rad($heading); 
483
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
484
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
485
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
483
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
484
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
485
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
486 486
 	}
487 487
 	
488
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
488
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
489 489
 		// distance in meter
490 490
 		$R = 6378.14;
491
-		$latitude1 = $latitude * (M_PI/180);
492
-		$longitude1 = $longitude * (M_PI/180);
493
-		$brng = $bearing * (M_PI/180);
491
+		$latitude1 = $latitude*(M_PI/180);
492
+		$longitude1 = $longitude*(M_PI/180);
493
+		$brng = $bearing*(M_PI/180);
494 494
 		$d = $distance;
495 495
 
496 496
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
497
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
497
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
498 498
 
499
-		$latitude2 = $latitude2 * (180/M_PI);
500
-		$longitude2 = $longitude2 * (180/M_PI);
499
+		$latitude2 = $latitude2*(180/M_PI);
500
+		$longitude2 = $longitude2*(180/M_PI);
501 501
 
502
-		$flat = round ($latitude2,6);
503
-		$flong = round ($longitude2,6);
502
+		$flat = round($latitude2, 6);
503
+		$flong = round($longitude2, 6);
504 504
 /*
505 505
 		$dx = $distance*cos($bearing);
506 506
 		$dy = $distance*sin($bearing);
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		$flong = $longitude + $dlong;
510 510
 		$flat = $latitude + $dlat;
511 511
 */
512
-		return array('latitude' => $flat,'longitude' => $flong);
512
+		return array('latitude' => $flat, 'longitude' => $flong);
513 513
 	}
514 514
 
515 515
 	/**
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
 	 * @param integer $level GZIP compression level (default: 9)
524 524
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
525 525
 	 */
526
-	public function gzCompressFile($source, $level = 9){ 
527
-		$dest = $source . '.gz'; 
528
-		$mode = 'wb' . $level; 
526
+	public function gzCompressFile($source, $level = 9) { 
527
+		$dest = $source.'.gz'; 
528
+		$mode = 'wb'.$level; 
529 529
 		$error = false; 
530 530
 		if ($fp_out = gzopen($dest, $mode)) { 
531
-			if ($fp_in = fopen($source,'rb')) { 
531
+			if ($fp_in = fopen($source, 'rb')) { 
532 532
 				while (!feof($fp_in)) 
533
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
533
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
534 534
 				fclose($fp_in); 
535 535
 			} else {
536 536
 				$error = true; 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	} 
547 547
 	
548 548
 	public function remove_accents($string) {
549
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
549
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
550 550
 		$chars = array(
551 551
 		    // Decompositions for Latin-1 Supplement
552 552
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
604 604
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
605 605
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
606
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
606
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
607 607
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
608 608
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
609 609
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
620 620
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
621 621
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
622
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
623
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
624
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
625
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
626
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
627
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
628
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
622
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
623
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
624
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
625
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
626
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
627
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
628
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
629 629
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
630 630
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
631 631
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
660 660
 			if (is_numeric($string[$i]) && $concat_flag) {
661 661
 				$int .= $string[$i];
662
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
662
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
663 663
 				$concat_flag = false;
664 664
 			}
665 665
 		}
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			$slice = array_slice($arr, $offset + 1, $length);
706 706
 			return implode("", $slice);
707 707
 		} else {
708
-			return mb_substr($string,$offset,$length,'UTF-8');
708
+			return mb_substr($string, $offset, $length, 'UTF-8');
709 709
 		}
710 710
 	}
711 711
 
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 		//NOTE: use a trailing slash for folders!!!
716 716
 		//see http://bugs.php.net/bug.php?id=27609
717 717
 		//see http://bugs.php.net/bug.php?id=30931
718
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
718
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
719 719
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
720 720
 		else if (is_dir($path))
721 721
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
722 722
 		// check tmp file for read/write capabilities
723 723
 		$rm = file_exists($path);
724 724
 		$f = @fopen($path, 'a');
725
-		if ($f===false)
725
+		if ($f === false)
726 726
 			return false;
727 727
 		fclose($f);
728 728
 		if (!$rm)
Please login to merge, or discard this patch.
Braces   +101 added lines, -45 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");
@@ -95,8 +98,9 @@  discard block
 block discarded – undo
95 98
 	private function curlResponseHeaderCallback($ch, $headerLine) {
96 99
 		//global $cookies;
97 100
 		$cookies = array();
98
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
99
-			$cookies[] = $cookie;
101
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
102
+					$cookies[] = $cookie;
103
+		}
100 104
 		return strlen($headerLine); // Needed by curl
101 105
 	}
102 106
 
@@ -107,7 +111,9 @@  discard block
 block discarded – undo
107 111
 		curl_setopt($ch, CURLOPT_URL, $url);
108 112
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
109 113
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
114
+		if ($referer != '') {
115
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
116
+		}
111 117
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112 118
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
113 119
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -119,7 +125,9 @@  discard block
 block discarded – undo
119 125
 		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');
120 126
 		curl_setopt($ch, CURLOPT_FILE, $fp);
121 127
 		curl_exec($ch);
122
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
128
+		if (curl_errno($ch) && $globalDebug) {
129
+			echo 'Download error: '.curl_error($ch);
130
+		}
123 131
 		curl_close($ch);
124 132
 		fclose($fp);
125 133
 	}
@@ -127,12 +135,16 @@  discard block
 block discarded – undo
127 135
 	public static function gunzip($in_file,$out_file_name = '') {
128 136
 		//echo $in_file.' -> '.$out_file_name."\n";
129 137
 		$buffer_size = 4096; // read 4kb at a time
130
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
138
+		if ($out_file_name == '') {
139
+			$out_file_name = str_replace('.gz', '', $in_file);
140
+		}
131 141
 		if ($in_file != '' && file_exists($in_file)) {
132 142
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
135
-			else {
143
+			if (function_exists('gzopen')) {
144
+				$file = gzopen($in_file,'rb');
145
+			} elseif (function_exists('gzopen64')) {
146
+				$file = gzopen64($in_file,'rb');
147
+			} else {
136 148
 				echo 'gzopen not available';
137 149
 				die;
138 150
 			}
@@ -148,11 +160,14 @@  discard block
 block discarded – undo
148 160
 	public static function bunzip2($in_file,$out_file_name = '') {
149 161
 		//echo $in_file.' -> '.$out_file_name."\n";
150 162
 		$buffer_size = 4096; // read 4kb at a time
151
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
163
+		if ($out_file_name == '') {
164
+			$out_file_name = str_replace('.bz2', '', $in_file);
165
+		}
152 166
 		if ($in_file != '' && file_exists($in_file)) {
153 167
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
155
-			else {
168
+			if (function_exists('bzopen')) {
169
+				$file = bzopen($in_file,'rb');
170
+			} else {
156 171
 				echo 'bzopen not available';
157 172
 				die;
158 173
 			}
@@ -171,10 +186,16 @@  discard block
 block discarded – undo
171 186
 	* @return Array array of the tables in HTML page
172 187
 	*/
173 188
 	public function table2array($data) {
174
-		if (!is_string($data)) return array();
175
-		if ($data == '') return array();
189
+		if (!is_string($data)) {
190
+			return array();
191
+		}
192
+		if ($data == '') {
193
+			return array();
194
+		}
176 195
 		$html = str_get_html($data);
177
-		if ($html === false) return array();
196
+		if ($html === false) {
197
+			return array();
198
+		}
178 199
 		$tabledata=array();
179 200
 		foreach($html->find('tr') as $element)
180 201
 		{
@@ -209,7 +230,9 @@  discard block
 block discarded – undo
209 230
 	*/
210 231
 	public function text2array($data) {
211 232
 		$html = str_get_html($data);
212
-		if ($html === false) return array();
233
+		if ($html === false) {
234
+			return array();
235
+		}
213 236
 		$tabledata=array();
214 237
 		foreach($html->find('p') as $element)
215 238
 		{
@@ -230,7 +253,9 @@  discard block
 block discarded – undo
230 253
 	* @return Float Distance in $unit
231 254
 	*/
232 255
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233
-		if ($lat == $latc && $lon == $lonc) return 0;
256
+		if ($lat == $latc && $lon == $lonc) {
257
+			return 0;
258
+		}
234 259
 		$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;
235 260
 		if ($unit == "km") {
236 261
 			return round($dist * 1.609344);
@@ -269,7 +294,9 @@  discard block
 block discarded – undo
269 294
 		$dX = $latc - $lat;
270 295
 		$dY = $lonc - $lon;
271 296
 		$azimuth = rad2deg(atan2($dY,$dX));
272
-		if ($azimuth < 0) return $azimuth+360;
297
+		if ($azimuth < 0) {
298
+			return $azimuth+360;
299
+		}
273 300
 		return $azimuth;
274 301
 	}
275 302
 	
@@ -283,10 +310,16 @@  discard block
 block discarded – undo
283 310
 	public function withinThreshold ($timeDifference, $distance) {
284 311
 		$x = abs($timeDifference);
285 312
 		$d = abs($distance);
286
-		if ($x == 0 || $d == 0) return true;
313
+		if ($x == 0 || $d == 0) {
314
+			return true;
315
+		}
287 316
 		// may be due to Internet jitter; distance is realistic
288
-		if ($x < 0.7 && $d < 2000) return true;
289
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
317
+		if ($x < 0.7 && $d < 2000) {
318
+			return true;
319
+		} else {
320
+			return $d/$x < 1500*0.27778;
321
+		}
322
+		// 1500 km/h max
290 323
 	}
291 324
 
292 325
 
@@ -314,11 +347,17 @@  discard block
 block discarded – undo
314 347
 	
315 348
 	public function convertDM($coord,$latlong) {
316 349
 		if ($latlong == 'latitude') {
317
-			if ($coord < 0) $NSEW = 'S';
318
-			else $NSEW = 'N';
350
+			if ($coord < 0) {
351
+				$NSEW = 'S';
352
+			} else {
353
+				$NSEW = 'N';
354
+			}
319 355
 		} else {
320
-			if ($coord < 0) $NSEW = 'W';
321
-			else $NSEW = 'E';
356
+			if ($coord < 0) {
357
+				$NSEW = 'W';
358
+			} else {
359
+				$NSEW = 'E';
360
+			}
322 361
 		}
323 362
 		$coord = abs($coord);
324 363
 		$deg = floor($coord);
@@ -361,7 +400,9 @@  discard block
 block discarded – undo
361 400
 	public function hex2str($hex) {
362 401
 		$str = '';
363 402
 		$hexln = strlen($hex);
364
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
403
+		for($i=0;$i<$hexln;$i+=2) {
404
+			$str .= chr(hexdec(substr($hex,$i,2)));
405
+		}
365 406
 		return $str;
366 407
 	}
367 408
 	
@@ -398,8 +439,11 @@  discard block
 block discarded – undo
398 439
 		$b = $lat2 - $lat1;
399 440
 		$c = -($a*$lat1+$b*$lon1);
400 441
 		$d = $a*$lat3+$b*$lon3+$c;
401
-		if ($d > -$approx && $d < $approx) return true;
402
-		else return false;
442
+		if ($d > -$approx && $d < $approx) {
443
+			return true;
444
+		} else {
445
+			return false;
446
+		}
403 447
 	}
404 448
 	
405 449
 	public function array_merge_noappend() {
@@ -458,7 +502,9 @@  discard block
 block discarded – undo
458 502
 			return $result;
459 503
 		}
460 504
 		$handle = @opendir('./locale');
461
-		if ($handle === false) return $result;
505
+		if ($handle === false) {
506
+			return $result;
507
+		}
462 508
 		while (false !== ($file = readdir($handle))) {
463 509
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
464 510
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -529,8 +575,9 @@  discard block
 block discarded – undo
529 575
 		$error = false; 
530 576
 		if ($fp_out = gzopen($dest, $mode)) { 
531 577
 			if ($fp_in = fopen($source,'rb')) { 
532
-				while (!feof($fp_in)) 
533
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
578
+				while (!feof($fp_in)) {
579
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
580
+				}
534 581
 				fclose($fp_in); 
535 582
 			} else {
536 583
 				$error = true; 
@@ -539,14 +586,17 @@  discard block
 block discarded – undo
539 586
 		} else {
540 587
 			$error = true; 
541 588
 		}
542
-		if ($error)
543
-			return false; 
544
-		else
545
-			return $dest; 
589
+		if ($error) {
590
+					return false;
591
+		} else {
592
+					return $dest;
593
+		}
546 594
 	} 
547 595
 	
548 596
 	public function remove_accents($string) {
549
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
597
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
598
+			return $string;
599
+		}
550 600
 		$chars = array(
551 601
 		    // Decompositions for Latin-1 Supplement
552 602
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -670,7 +720,9 @@  discard block
 block discarded – undo
670 720
 		$ip = gethostbyname($host);
671 721
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
672 722
 		$r = @socket_connect($s, $ip, $port);
673
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
723
+		if (!socket_set_nonblock($s)) {
724
+			echo "Unable to set nonblock on socket\n";
725
+		}
674 726
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
675 727
 			return $s;
676 728
 		}
@@ -715,18 +767,22 @@  discard block
 block discarded – undo
715 767
 		//NOTE: use a trailing slash for folders!!!
716 768
 		//see http://bugs.php.net/bug.php?id=27609
717 769
 		//see http://bugs.php.net/bug.php?id=30931
718
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
770
+		if ($path{strlen($path)-1}=='/') {
771
+			// recursively return a temporary file path
719 772
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
720
-		else if (is_dir($path))
721
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
773
+		} else if (is_dir($path)) {
774
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
775
+		}
722 776
 		// check tmp file for read/write capabilities
723 777
 		$rm = file_exists($path);
724 778
 		$f = @fopen($path, 'a');
725
-		if ($f===false)
726
-			return false;
779
+		if ($f===false) {
780
+					return false;
781
+		}
727 782
 		fclose($f);
728
-		if (!$rm)
729
-			unlink($path);
783
+		if (!$rm) {
784
+					unlink($path);
785
+		}
730 786
 		return true;
731 787
 	}
732 788
 }
Please login to merge, or discard this patch.
js/map.3d.js.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	}
370 370
     }
371 371
 
372
-    var tsk_geojson = Cesium.loadJson("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php print filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); ?>");
372
+    var tsk_geojson = Cesium.loadJson("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php print filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); ?>");
373 373
     tsk_geojson.then(function(geojsondata) {
374 374
 	tsk = new Cesium.CustomDataSource('tsk');
375 375
 	for (var i =0;i < geojsondata.features.length; i++) {
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 <?php
457 457
 	if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) {
458 458
 		if (isset($_COOKIE['lastcentercoord'])) {
459
-			$lastcentercoord = explode(',',$_COOKIE['lastcentercoord']);
459
+			$lastcentercoord = explode(',', $_COOKIE['lastcentercoord']);
460 460
 			if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0;
461 461
 			else $zoom = $lastcentercoord[3];
462 462
 			$viewcenterlatitude = $lastcentercoord[0];
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -331,15 +331,15 @@  discard block
 block discarded – undo
331 331
     }
332 332
 
333 333
 <?php
334
-    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
334
+	if (isset($globalMapUseBbox) && $globalMapUseBbox) {
335 335
 ?>
336 336
     var loc_geojson = Cesium.loadJson("<?php print $globalURL; ?>/location-geojson.php?coord="+bbox());
337 337
 <?php
338
-    } else {
338
+	} else {
339 339
 ?>
340 340
     var loc_geojson = Cesium.loadJson("<?php print $globalURL; ?>/location-geojson.php");
341 341
 <?php
342
-    }
342
+	}
343 343
 ?>
344 344
     loc_geojson.then(function(geojsondata) {
345 345
 	loc = new Cesium.CustomDataSource('location');
@@ -512,15 +512,15 @@  discard block
 block discarded – undo
512 512
 //	if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
513 513
 ?>
514 514
 <?php
515
-    if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
515
+	if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
516 516
 ?>
517 517
 var MapTerrain = 'ellipsoid';
518 518
 <?php
519
-    } else {
519
+	} else {
520 520
 ?>
521 521
 var MapTerrain = getCookie('MapTerrain');
522 522
 <?php
523
-    }
523
+	}
524 524
 ?>
525 525
 
526 526
 
@@ -574,11 +574,11 @@  discard block
 block discarded – undo
574 574
 }
575 575
 
576 576
 <?php
577
-    if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) {
577
+	if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) {
578 578
 ?>
579 579
 update_tsk();
580 580
 <?php
581
-    }
581
+	}
582 582
 ?>
583 583
 
584 584
 update_locationsLayer();
Please login to merge, or discard this patch.
Braces   +40 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,21 +5,30 @@  discard block
 block discarded – undo
5 5
 
6 6
 document.cookie =  'MapFormat=3d; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
7 7
 <?php
8
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
9
-	else $MapType = $globalMapProvider;
8
+	if (isset($_COOKIE['MapType'])) {
9
+		$MapType = $_COOKIE['MapType'];
10
+	} else {
11
+		$MapType = $globalMapProvider;
12
+	}
10 13
 
11 14
 //	unset($_COOKIE['MapType']);
12 15
 	if ($MapType != 'Mapbox' && $MapType != 'OpenStreetMap' && $MapType != 'Bing-Aerial' && $MapType != 'Bing-Hybrid' && $MapType != 'Bing-Road' && $MapType != 'offline' && $MapType != 'ArcGIS-Streetmap' && $MapType != 'ArcGIS-Satellite' && $MapType != 'NatGeo-Street') {
13
-		if (isset($globalBingMapKey) && $globalBingMapKey != '') $MapType = 'Bing-Aerial';
14
-		else $MapType = 'OpenStreetMap';
16
+		if (isset($globalBingMapKey) && $globalBingMapKey != '') {
17
+			$MapType = 'Bing-Aerial';
18
+		} else {
19
+			$MapType = 'OpenStreetMap';
20
+		}
15 21
 	}
16 22
 	if (($MapType == 'Bing-Aerial' || $MapType == 'Bing-Hybrid' || $MapType == 'Bing-Road') && (!isset($globalBingMapKey) || $globalBingMapKey == '')) {
17 23
 		$MapType = 'OpenStreetMap';
18 24
 	}
19 25
 	if ($MapType == 'Mapbox') {
20
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
21
-		else $MapBoxId = $_COOKIE['MapTypeId'];
22
-?>
26
+		if ($_COOKIE['MapTypeId'] == 'default') {
27
+			$MapBoxId = $globalMapboxId;
28
+		} else {
29
+			$MapBoxId = $_COOKIE['MapTypeId'];
30
+		}
31
+		?>
23 32
 	var imProv = Cesium.MapboxImageryProvider({
24 33
 		credit: 'Map data © OpenStreetMap contributors, ' +
25 34
 	      'CC-BY-SA, ' +
@@ -147,13 +156,23 @@  discard block
 block discarded – undo
147 156
 */
148 157
 ?>
149 158
 <?php
150
-	}  elseif (isset($globalMapCustomLayer[$MapType])) {
159
+	} elseif (isset($globalMapCustomLayer[$MapType])) {
151 160
 		$customid = $MapType;
152 161
 ?>
153 162
 	var imProv = Cesium.createOpenStreetMapImageryProvider({
154 163
 		url : '<?php print $globalMapCustomLayer[$customid]['url']; ?>',
155
-		maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '99'; ?>,
156
-		minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
164
+		maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
165
+	print $globalMapCustomLayer[$customid]['maxZoom'];
166
+} else {
167
+	print '99';
168
+}
169
+?>,
170
+		minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
171
+	print $globalMapCustomLayer[$customid]['minZoom'];
172
+} else {
173
+	print '0';
174
+}
175
+?>,
157 176
 		credit: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
158 177
 	});
159 178
 <?php
@@ -480,8 +499,11 @@  discard block
 block discarded – undo
480 499
 	if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) {
481 500
 		if (isset($_COOKIE['lastcentercoord'])) {
482 501
 			$lastcentercoord = explode(',',$_COOKIE['lastcentercoord']);
483
-			if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0;
484
-			else $zoom = $lastcentercoord[3];
502
+			if (!isset($lastcentercoord[3])) {
503
+				$zoom = $lastcentercoord[2]*1000000.0;
504
+			} else {
505
+				$zoom = $lastcentercoord[3];
506
+			}
485 507
 			$viewcenterlatitude = $lastcentercoord[0];
486 508
 			$viewcenterlongitude = $lastcentercoord[1];
487 509
 		} else {
@@ -602,7 +624,12 @@  discard block
 block discarded – undo
602 624
 ?>
603 625
 
604 626
 update_locationsLayer();
605
-setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
627
+setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) {
628
+	print $globalMapRefresh*1000*2;
629
+} else {
630
+	print '60000';
631
+}
632
+?>);
606 633
 /*
607 634
 var handlera = new Cesium.ScreenSpaceEventHandler(viewer.canvas, false);
608 635
 handlera.setInputAction(
Please login to merge, or discard this patch.
require/class.APRS.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -174,6 +174,10 @@
 block discarded – undo
174 174
 		'\|' => 'TNC Stream SW',
175 175
 		'\~' => 'TNC Stream SW');
176 176
 
177
+	/**
178
+	 * @param integer $n
179
+	 * @param integer $s
180
+	 */
177 181
 	private function urshift($n, $s) {
178 182
 		return ($n >= 0) ? ($n >> $s) :
179 183
 		    (($n & 0x7fffffff) >> $s) | 
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -176,8 +176,8 @@
 block discarded – undo
176 176
 
177 177
 	private function urshift($n, $s) {
178 178
 		return ($n >= 0) ? ($n >> $s) :
179
-		    (($n & 0x7fffffff) >> $s) | 
180
-		    (0x40000000 >> ($s - 1));
179
+			(($n & 0x7fffffff) >> $s) | 
180
+			(0x40000000 >> ($s - 1));
181 181
 	}
182 182
 
183 183
 	/*
Please login to merge, or discard this patch.
Spacing   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -175,8 +175,7 @@  discard block
 block discarded – undo
175 175
 		'\~' => 'TNC Stream SW');
176 176
 
177 177
 	private function urshift($n, $s) {
178
-		return ($n >= 0) ? ($n >> $s) :
179
-		    (($n & 0x7fffffff) >> $s) | 
178
+		return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
180 179
 		    (0x40000000 >> ($s - 1));
181 180
 	}
182 181
 
@@ -192,7 +191,7 @@  discard block
 block discarded – undo
192 191
 		$input_len = strlen($input);
193 192
 		
194 193
 		/* Find the end of header checking for NULL bytes while doing it. */
195
-		$splitpos = strpos($input,':');
194
+		$splitpos = strpos($input, ':');
196 195
 		
197 196
 		/* Check that end was found and body has at least one byte. */
198 197
 		if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -202,14 +201,14 @@  discard block
 block discarded – undo
202 201
 		
203 202
 		if ($debug) echo 'input : '.$input."\n";
204 203
 		/* Save header and body. */
205
-		$body = substr($input,$splitpos+1,$input_len);
204
+		$body = substr($input, $splitpos + 1, $input_len);
206 205
 		$body_len = strlen($body);
207
-		$header = substr($input,0,$splitpos);
206
+		$header = substr($input, 0, $splitpos);
208 207
 		if ($debug) echo 'header : '.$header."\n";
209 208
 		
210 209
 		/* Parse source, target and path. */
211 210
 		//FLRDF0A52>APRS,qAS,LSTB
212
-		if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
211
+		if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
213 212
 			$ident = $matches[1];
214 213
 			$all_elements = $matches[2];
215 214
 			if ($ident == 'AIRCRAFT') {
@@ -226,13 +225,13 @@  discard block
 block discarded – undo
226 225
 			if ($debug) 'No ident'."\n";
227 226
 			return false;
228 227
 		}
229
-		$elements = explode(',',$all_elements);
228
+		$elements = explode(',', $all_elements);
230 229
 		$source = end($elements);
231 230
 		$result['source'] = $source;
232 231
 		foreach ($elements as $element) {
233
-			if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
232
+			if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
234 233
 			//if ($element == 'TCPIP*') return false;
235
-			} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
234
+			} elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
236 235
 				if ($debug) echo 'element : '.$element."\n";
237 236
 				return false;
238 237
 			}
@@ -245,14 +244,14 @@  discard block
 block discarded – undo
245 244
 			*/
246 245
 		}
247 246
 		
248
-		$type = substr($body,0,1);
247
+		$type = substr($body, 0, 1);
249 248
 		if ($debug) echo 'type : '.$type."\n";
250 249
 		if ($type == ';') {
251 250
 			if (isset($result['source_type']) && $result['source_type'] == 'modes') {
252
-				$result['address'] = trim(substr($body,1,9));
251
+				$result['address'] = trim(substr($body, 1, 9));
253 252
 			} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
254
-				$result['mmsi'] = trim(substr($body,1,9));
255
-			} else $result['ident'] = trim(substr($body,1,9));
253
+				$result['mmsi'] = trim(substr($body, 1, 9));
254
+			} else $result['ident'] = trim(substr($body, 1, 9));
256 255
 		} elseif ($type == ',') {
257 256
 			// Invalid data or test data
258 257
 			return false;
@@ -260,20 +259,20 @@  discard block
 block discarded – undo
260 259
 		
261 260
 		// Check for Timestamp
262 261
 		$find = false;
263
-		$body_parse = substr($body,1);
264
-		if (preg_match('/^;(.){9}\*/',$body,$matches)) {
265
-			$body_parse = substr($body_parse,10);
262
+		$body_parse = substr($body, 1);
263
+		if (preg_match('/^;(.){9}\*/', $body, $matches)) {
264
+			$body_parse = substr($body_parse, 10);
266 265
 			$find = true;
267 266
 		}
268
-		if (preg_match('/^`(.*)\//',$body,$matches)) {
269
-			$body_parse = substr($body_parse,strlen($matches[1])-1);
267
+		if (preg_match('/^`(.*)\//', $body, $matches)) {
268
+			$body_parse = substr($body_parse, strlen($matches[1]) - 1);
270 269
 			$find = true;
271 270
 		}
272
-		if (preg_match("/^'(.*)\//",$body,$matches)) {
273
-			$body_parse = substr($body_parse,strlen($matches[1])-1);
271
+		if (preg_match("/^'(.*)\//", $body, $matches)) {
272
+			$body_parse = substr($body_parse, strlen($matches[1]) - 1);
274 273
 			$find = true;
275 274
 		}
276
-		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
275
+		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
277 276
 			$find = true;
278 277
 			$timestamp = $matches[0];
279 278
 			if ($matches[4] == 'h') {
@@ -286,17 +285,17 @@  discard block
 block discarded – undo
286 285
 				// This work or not ?
287 286
 				$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
288 287
 			}
289
-			$body_parse = substr($body_parse,7);
288
+			$body_parse = substr($body_parse, 7);
290 289
 			$result['timestamp'] = $timestamp;
291 290
 		}
292
-		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
291
+		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
293 292
 			$find = true;
294 293
 			$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
295
-			$body_parse = substr($body_parse,8);
294
+			$body_parse = substr($body_parse, 8);
296 295
 			$result['timestamp'] = $timestamp;
297 296
 		}
298 297
 		//if (strlen($body_parse) > 19) {
299
-		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
298
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
300 299
 			$find = true;
301 300
 			// 4658.70N/00707.78Ez
302 301
 			$sind = strtoupper($matches[3]);
@@ -318,11 +317,11 @@  discard block
 block discarded – undo
318 317
 			    */
319 318
 			$latitude = $lat + floatval($lat_min)/60;
320 319
 			$longitude = $lon + floatval($lon_min)/60;
321
-			if ($sind == 'S') $latitude = 0-$latitude;
322
-			if ($wind == 'W') $longitude = 0-$longitude;
320
+			if ($sind == 'S') $latitude = 0 - $latitude;
321
+			if ($wind == 'W') $longitude = 0 - $longitude;
323 322
 			$result['latitude'] = $latitude;
324 323
 			$result['longitude'] = $longitude;
325
-			$body_parse = substr($body_parse,18);
324
+			$body_parse = substr($body_parse, 18);
326 325
 			$body_parse_len = strlen($body_parse);
327 326
 		}
328 327
 		$body_parse_len = strlen($body_parse);
@@ -349,22 +348,22 @@  discard block
 block discarded – undo
349 348
 				//'
350 349
 				//if ($type != ';' && $type != '>') {
351 350
 				if ($type != '') {
352
-					$body_parse = substr($body_parse,1);
351
+					$body_parse = substr($body_parse, 1);
353 352
 					$body_parse_len = strlen($body_parse);
354 353
 					$result['symbol_code'] = $symbol_code;
355 354
 					if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
356 355
 					if ($symbol_code != '_') {
357 356
 					}
358 357
 					if ($body_parse_len >= 7) {
359
-						if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
360
-							$course = substr($body_parse,0,3);
358
+						if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
359
+							$course = substr($body_parse, 0, 3);
361 360
 							$tmp_s = intval($course);
362 361
 							if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
363
-							$speed = substr($body_parse,4,3);
362
+							$speed = substr($body_parse, 4, 3);
364 363
 							if ($speed != '...') {
365 364
 								$result['speed'] = intval($speed);
366 365
 							}
367
-							$body_parse = substr($body_parse,7);
366
+							$body_parse = substr($body_parse, 7);
368 367
 						}
369 368
 						// Check PHGR, PHG, RNG
370 369
 					} 
@@ -374,11 +373,11 @@  discard block
 block discarded – undo
374 373
 					}
375 374
 					*/
376 375
 					if (strlen($body_parse) > 0) {
377
-						if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
376
+						if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
378 377
 							$altitude = intval($matches[1]);
379 378
 							$result['altitude'] = $altitude;
380 379
 							//$body_parse = trim(substr($body_parse,strlen($matches[0])));
381
-							$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
380
+							$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
382 381
 						}
383 382
 					}
384 383
 					// Telemetry
@@ -388,58 +387,58 @@  discard block
 block discarded – undo
388 387
 					}
389 388
 					*/
390 389
 					// DAO
391
-					if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
390
+					if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
392 391
 						$dao = $matches[1];
393
-						if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
392
+						if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
394 393
 							$dao_split = str_split($dao);
395
-							$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
396
-							$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
394
+							$lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
395
+							$lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
397 396
 							if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
398 397
 							else $result['latitude'] += $lat_off;
399 398
 							if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
400 399
 							else $result['longitude'] += $lon_off;
401 400
 						}
402
-						$body_parse = substr($body_parse,6);
401
+						$body_parse = substr($body_parse, 6);
403 402
 					}
404
-					if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
405
-						$result['ident'] = str_replace('_',' ',$matches[1]);
403
+					if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
404
+						$result['ident'] = str_replace('_', ' ', $matches[1]);
406 405
 					}
407
-					if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
406
+					if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
408 407
 						$result['squawk'] = $matches[1];
409 408
 					}
410
-					if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
409
+					if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
411 410
 						$result['aircraft_icao'] = $matches[1];
412 411
 					}
413
-					if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
412
+					if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
414 413
 						$result['verticalrate'] = $matches[1];
415 414
 					}
416
-					if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
415
+					if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
417 416
 						$result['typeid'] = $matches[1];
418 417
 					}
419
-					if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
418
+					if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
420 419
 						$result['statusid'] = $matches[1];
421 420
 					}
422
-					if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
421
+					if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
423 422
 						$result['imo'] = $matches[1];
424 423
 					}
425
-					if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
424
+					if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
426 425
 						$result['arrival_date'] = $matches[1];
427 426
 					}
428
-					if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
429
-						$result['arrival_code'] = str_replace('_',' ',$matches[1]);
427
+					if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
428
+						$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
430 429
 					}
431 430
 					// OGN comment
432 431
 					//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
433
-					if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
432
+					if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
434 433
 						$id = $matches[1];
435 434
 						//$mode = substr($id,0,2);
436
-						$address = substr($id,2);
437
-						$addressType = (intval(substr($id,0,2),16))&3;
435
+						$address = substr($id, 2);
436
+						$addressType = (intval(substr($id, 0, 2), 16))&3;
438 437
 						if ($addressType == 0) $result['addresstype'] = "RANDOM";
439 438
 						elseif ($addressType == 1) $result['addresstype'] = "ICAO";
440 439
 						elseif ($addressType == 2) $result['addresstype'] = "FLARM";
441 440
 						elseif ($addressType == 3) $result['addresstype'] = "OGN";
442
-						$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
441
+						$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
443 442
 						$result['aircrafttype_code'] = $aircraftType;
444 443
 						if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
445 444
 						elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -456,110 +455,110 @@  discard block
 block discarded – undo
456 455
 						elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
457 456
 						elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
458 457
 						elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
459
-						$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
458
+						$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
460 459
 						$result['stealth'] = $stealth;
461 460
 						$result['address'] = $address;
462 461
 					}
463 462
 					//Comment
464 463
 					$result['comment'] = trim($body_parse);
465 464
 					// parse weather
466
-					if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
465
+					if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
467 466
 						$result['wind_dir'] = intval($matches[1]);
468
-						$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
469
-						$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
470
-						$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
471
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
472
-					} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
467
+						$result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
468
+						$result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
469
+						$result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
470
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
471
+					} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
473 472
 						$result['wind_dir'] = intval($matches[1]);
474
-						$result['wind_speed'] = round($matches[2]*1.60934,1);
475
-						$result['wind_gust'] = round($matches[3]*1.60934,1);
476
-						$result['temp'] = round(5/9*(($matches[4])-32),1);
477
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
478
-					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
473
+						$result['wind_speed'] = round($matches[2]*1.60934, 1);
474
+						$result['wind_gust'] = round($matches[3]*1.60934, 1);
475
+						$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
476
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
477
+					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
479 478
 						$result['wind_dir'] = intval($matches[1]);
480
-						$result['wind_speed'] = round($matches[2]*1.60934,1);
481
-						$result['wind_gust'] = round($matches[3]*1.60934,1);
482
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
483
-					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
479
+						$result['wind_speed'] = round($matches[2]*1.60934, 1);
480
+						$result['wind_gust'] = round($matches[3]*1.60934, 1);
481
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
482
+					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
484 483
 						$result['wind_dir'] = intval($matches[1]);
485
-						$result['wind_speed'] = round($matches[2]*1.60934,1);
486
-						$result['wind_gust'] = round($matches[3]*1.60934,1);
487
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
484
+						$result['wind_speed'] = round($matches[2]*1.60934, 1);
485
+						$result['wind_gust'] = round($matches[3]*1.60934, 1);
486
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
488 487
 					}
489 488
 					// temperature
490 489
 					//g012t088r000p000P000h38b10110
491 490
 					//g011t086r000p000P000h29b10198
492
-					if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
493
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
494
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
495
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
496
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
497
-						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
491
+					if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
492
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
493
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
494
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
495
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
496
+						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
498 497
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
499
-						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
500
-						$body_parse = substr($body_parse,strlen($matches[0]));
501
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
502
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
503
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
504
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
505
-						if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
506
-						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
498
+						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
499
+						$body_parse = substr($body_parse, strlen($matches[0]));
500
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
501
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
502
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
503
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
504
+						if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1);
505
+						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
507 506
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
508
-						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
509
-						$body_parse = substr($body_parse,strlen($matches[0]));
510
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
511
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
512
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
513
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
514
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
515
-						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
507
+						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
508
+						$body_parse = substr($body_parse, strlen($matches[0]));
509
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
510
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
511
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
512
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
513
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
514
+						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
516 515
 						if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
517
-						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
518
-						$body_parse = substr($body_parse,strlen($matches[0]));
519
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
520
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
516
+						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
517
+						$body_parse = substr($body_parse, strlen($matches[0]));
518
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
519
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
520
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
521
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
522
+						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
524 523
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
525
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
526
-						$body_parse = substr($body_parse,strlen($matches[0]));
527
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
528
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
529
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
530
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
531
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
+						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
525
+						$body_parse = substr($body_parse, strlen($matches[0]));
526
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
527
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
528
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
529
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
530
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
532 531
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
533
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
534
-						$body_parse = substr($body_parse,strlen($matches[0]));
535
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
536
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
537
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
538
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
539
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
532
+						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
533
+						$body_parse = substr($body_parse, strlen($matches[0]));
534
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
535
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
536
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
537
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
538
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
540 539
 						if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
541
-						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
542
-						$body_parse = substr($body_parse,strlen($matches[0]));
543
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
544
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
545
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
+						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
541
+						$body_parse = substr($body_parse, strlen($matches[0]));
542
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
543
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
544
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
546 545
 						if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
547
-						if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
548
-						$body_parse = substr($body_parse,strlen($matches[0]));
549
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
550
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
551
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
552
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
546
+						if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1);
547
+						$body_parse = substr($body_parse, strlen($matches[0]));
548
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
549
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
550
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
551
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
553 552
 						if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
554
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
555
-						$body_parse = substr($body_parse,strlen($matches[0]));
553
+						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
554
+						$body_parse = substr($body_parse, strlen($matches[0]));
556 555
 					}
557 556
 					$result['comment'] = trim($body_parse);
558 557
 				}
559 558
 			} else $result['comment'] = trim($body_parse);
560 559
 		}
561
-		if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
562
-		if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
560
+		if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
561
+		if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
563 562
 		if ($debug) print_r($result);
564 563
 		return $result;
565 564
 	}
@@ -568,34 +567,34 @@  discard block
 block discarded – undo
568 567
 	 * Connect to APRS server
569 568
 	*/
570 569
 	public function connect() {
571
-		global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
570
+		global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
572 571
 		$aprs_connect = 0;
573 572
 		$aprs_keep = 120;
574 573
 		$aprs_last_tx = time();
575 574
 		if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
576
-		else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
575
+		else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
577 576
 		if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
578
-		else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
577
+		else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
579 578
 		if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
580 579
 		else $aprs_pass = '-1';
581
-		$aprs_filter  = '';
580
+		$aprs_filter = '';
582 581
 		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
583 582
 		$Common = new Common();
584
-		$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
583
+		$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
585 584
 		if ($s !== false) {
586 585
 			echo 'Connected to APRS server! '."\n";
587 586
 			$authstart = time();
588 587
 			$this->socket = $s;
589
-			$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
590
-			socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
591
-			while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
588
+			$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
589
+			socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
590
+			while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
592 591
 				if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
593 592
 					echo 'APRS user verified !'."\n";
594 593
 					$this->connected = true;
595 594
 					return true;
596 595
 					break;
597 596
 				}
598
-				if (time()-$authstart > 5) {
597
+				if (time() - $authstart > 5) {
599 598
 					echo 'APRS timeout'."\n";
600 599
 					break;
601 600
 				}
@@ -617,7 +616,7 @@  discard block
 block discarded – undo
617 616
 	public function send($data) {
618 617
 		global $globalDebug;
619 618
 		if ($this->connected === false) $this->connect();
620
-		$send = socket_send( $this->socket  , $data , strlen($data),0);
619
+		$send = socket_send($this->socket, $data, strlen($data), 0);
621 620
 		if ($send === FALSE) {
622 621
 			if ($globalDebug) echo 'Reconnect...';
623 622
 			socket_close($this->socket);
@@ -627,17 +626,17 @@  discard block
 block discarded – undo
627 626
 }
628 627
 
629 628
 class APRSSpotter extends APRS {
630
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
629
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
631 630
 		$Common = new Common();
632 631
 		date_default_timezone_set('UTC');
633 632
 		if ($latitude != '' && $longitude != '') {
634 633
 			$lat = $latitude;
635 634
 			$long = $longitude;
636
-			$latitude = $Common->convertDM($latitude,'latitude');
637
-			$longitude = $Common->convertDM($longitude,'longitude');
638
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
639
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
640
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
635
+			$latitude = $Common->convertDM($latitude, 'latitude');
636
+			$longitude = $Common->convertDM($longitude, 'longitude');
637
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
638
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
639
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
641 640
 			$w = $w1.$w2;
642 641
 			//$w = '00';
643 642
 			$custom = '';
@@ -664,26 +663,26 @@  discard block
 block discarded – undo
664 663
 			$geoid= round($GeoidClass->get($lat,$long)*3.28084,2);
665 664
 			$altitude_real = round($altitude_real + $geoid);
666 665
 			*/
667
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
666
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
668 667
 		}
669 668
 	}
670 669
 }
671 670
 class APRSMarine extends APRS {
672
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
671
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
673 672
 		$Common = new Common();
674 673
 		date_default_timezone_set('UTC');
675 674
 		if ($latitude != '' && $longitude != '') {
676
-			$latitude = $Common->convertDM($latitude,'latitude');
677
-			$longitude = $Common->convertDM($longitude,'longitude');
678
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
679
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
680
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
675
+			$latitude = $Common->convertDM($latitude, 'latitude');
676
+			$longitude = $Common->convertDM($longitude, 'longitude');
677
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
678
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
679
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
681 680
 			$w = $w1.$w2;
682 681
 			//$w = '00';
683 682
 			$custom = '';
684 683
 			if ($ident != '') {
685 684
 				if ($custom != '') $custom .= '/';
686
-				$custom .= 'CS='.str_replace(' ','_',$ident);
685
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
687 686
 			}
688 687
 			if ($typeid != '') {
689 688
 				if ($custom != '') $custom .= '/';
@@ -703,11 +702,11 @@  discard block
 block discarded – undo
703 702
 			}
704 703
 			if ($arrival_code != '') {
705 704
 				if ($custom != '') $custom .= '/';
706
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
705
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
707 706
 			}
708 707
 			if ($custom != '') $custom = ' '.$custom;
709 708
 			$altitude = 0;
710
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
709
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
711 710
 		}
712 711
 	}
713 712
 }
Please login to merge, or discard this patch.
Braces   +307 added lines, -110 removed lines patch added patch discarded remove patch
@@ -196,16 +196,22 @@  discard block
 block discarded – undo
196 196
 		
197 197
 		/* Check that end was found and body has at least one byte. */
198 198
 		if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
199
-			if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
199
+			if ($globalDebug) {
200
+				echo '!!! APRS invalid : '.$input."\n";
201
+			}
200 202
 			return false;
201 203
 		}
202 204
 		
203
-		if ($debug) echo 'input : '.$input."\n";
205
+		if ($debug) {
206
+			echo 'input : '.$input."\n";
207
+		}
204 208
 		/* Save header and body. */
205 209
 		$body = substr($input,$splitpos+1,$input_len);
206 210
 		$body_len = strlen($body);
207 211
 		$header = substr($input,0,$splitpos);
208
-		if ($debug) echo 'header : '.$header."\n";
212
+		if ($debug) {
213
+			echo 'header : '.$header."\n";
214
+		}
209 215
 		
210 216
 		/* Parse source, target and path. */
211 217
 		//FLRDF0A52>APRS,qAS,LSTB
@@ -219,11 +225,15 @@  discard block
 block discarded – undo
219 225
 				$result['format_source'] = 'famaprs';
220 226
 				$result['source_type'] = 'ais';
221 227
 			} else {
222
-				if ($debug) echo 'ident : '.$ident."\n";
228
+				if ($debug) {
229
+					echo 'ident : '.$ident."\n";
230
+				}
223 231
 				$result['ident'] = $ident;
224 232
 			}
225 233
 		} else {
226
-			if ($debug) 'No ident'."\n";
234
+			if ($debug) {
235
+				'No ident'."\n";
236
+			}
227 237
 			return false;
228 238
 		}
229 239
 		$elements = explode(',',$all_elements);
@@ -233,7 +243,9 @@  discard block
 block discarded – undo
233 243
 			if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
234 244
 			//if ($element == 'TCPIP*') return false;
235 245
 			} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
236
-				if ($debug) echo 'element : '.$element."\n";
246
+				if ($debug) {
247
+					echo 'element : '.$element."\n";
248
+				}
237 249
 				return false;
238 250
 			}
239 251
 			/*
@@ -246,13 +258,17 @@  discard block
 block discarded – undo
246 258
 		}
247 259
 		
248 260
 		$type = substr($body,0,1);
249
-		if ($debug) echo 'type : '.$type."\n";
261
+		if ($debug) {
262
+			echo 'type : '.$type."\n";
263
+		}
250 264
 		if ($type == ';') {
251 265
 			if (isset($result['source_type']) && $result['source_type'] == 'modes') {
252 266
 				$result['address'] = trim(substr($body,1,9));
253 267
 			} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
254 268
 				$result['mmsi'] = trim(substr($body,1,9));
255
-			} else $result['ident'] = trim(substr($body,1,9));
269
+			} else {
270
+				$result['ident'] = trim(substr($body,1,9));
271
+			}
256 272
 		} elseif ($type == ',') {
257 273
 			// Invalid data or test data
258 274
 			return false;
@@ -309,7 +325,9 @@  discard block
 block discarded – undo
309 325
 			//$symbol_table = $matches[4];
310 326
 			$lat = intval($lat_deg);
311 327
 			$lon = intval($lon_deg);
312
-			if ($lat > 89 || $lon > 179) return false;
328
+			if ($lat > 89 || $lon > 179) {
329
+				return false;
330
+			}
313 331
 			/*
314 332
 			    $tmp_5b = str_replace('.','',$lat_min);
315 333
 			    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
@@ -318,8 +336,12 @@  discard block
 block discarded – undo
318 336
 			    */
319 337
 			$latitude = $lat + floatval($lat_min)/60;
320 338
 			$longitude = $lon + floatval($lon_min)/60;
321
-			if ($sind == 'S') $latitude = 0-$latitude;
322
-			if ($wind == 'W') $longitude = 0-$longitude;
339
+			if ($sind == 'S') {
340
+				$latitude = 0-$latitude;
341
+			}
342
+			if ($wind == 'W') {
343
+				$longitude = 0-$longitude;
344
+			}
323 345
 			$result['latitude'] = $latitude;
324 346
 			$result['longitude'] = $longitude;
325 347
 			$body_parse = substr($body_parse,18);
@@ -344,22 +366,29 @@  discard block
 block discarded – undo
344 366
 			if ($find) {
345 367
 				$body_split = str_split($body_parse);
346 368
 				$symbol_code = $body_split[0];
347
-				if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code;
348
-				else $symbol_code = '\\'.$symbol_code;
369
+				if (!isset($symbolll) || $symbolll == '/') {
370
+					$symbol_code = '/'.$symbol_code;
371
+				} else {
372
+					$symbol_code = '\\'.$symbol_code;
373
+				}
349 374
 				//'
350 375
 				//if ($type != ';' && $type != '>') {
351 376
 				if ($type != '') {
352 377
 					$body_parse = substr($body_parse,1);
353 378
 					$body_parse_len = strlen($body_parse);
354 379
 					$result['symbol_code'] = $symbol_code;
355
-					if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
380
+					if (isset($this->symbols[$symbol_code])) {
381
+						$result['symbol'] = $this->symbols[$symbol_code];
382
+					}
356 383
 					if ($symbol_code != '_') {
357 384
 					}
358 385
 					if ($body_parse_len >= 7) {
359 386
 						if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
360 387
 							$course = substr($body_parse,0,3);
361 388
 							$tmp_s = intval($course);
362
-							if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
389
+							if ($tmp_s >= 1 && $tmp_s <= 360) {
390
+								$result['heading'] = intval($course);
391
+							}
363 392
 							$speed = substr($body_parse,4,3);
364 393
 							if ($speed != '...') {
365 394
 								$result['speed'] = intval($speed);
@@ -394,10 +423,16 @@  discard block
 block discarded – undo
394 423
 							$dao_split = str_split($dao);
395 424
 							$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
396 425
 							$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
397
-							if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
398
-							else $result['latitude'] += $lat_off;
399
-							if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
400
-							else $result['longitude'] += $lon_off;
426
+							if ($result['latitude'] < 0) {
427
+								$result['latitude'] -= $lat_off;
428
+							} else {
429
+								$result['latitude'] += $lat_off;
430
+							}
431
+							if ($result['longitude'] < 0) {
432
+								$result['longitude'] -= $lon_off;
433
+							} else {
434
+								$result['longitude'] += $lon_off;
435
+							}
401 436
 						}
402 437
 						$body_parse = substr($body_parse,6);
403 438
 					}
@@ -435,27 +470,48 @@  discard block
 block discarded – undo
435 470
 						//$mode = substr($id,0,2);
436 471
 						$address = substr($id,2);
437 472
 						$addressType = (intval(substr($id,0,2),16))&3;
438
-						if ($addressType == 0) $result['addresstype'] = "RANDOM";
439
-						elseif ($addressType == 1) $result['addresstype'] = "ICAO";
440
-						elseif ($addressType == 2) $result['addresstype'] = "FLARM";
441
-						elseif ($addressType == 3) $result['addresstype'] = "OGN";
473
+						if ($addressType == 0) {
474
+							$result['addresstype'] = "RANDOM";
475
+						} elseif ($addressType == 1) {
476
+							$result['addresstype'] = "ICAO";
477
+						} elseif ($addressType == 2) {
478
+							$result['addresstype'] = "FLARM";
479
+						} elseif ($addressType == 3) {
480
+							$result['addresstype'] = "OGN";
481
+						}
442 482
 						$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
443 483
 						$result['aircrafttype_code'] = $aircraftType;
444
-						if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
445
-						elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
446
-						elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
447
-						elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
448
-						elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
449
-						elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
450
-						elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
451
-						elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
452
-						elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
453
-						elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
454
-						elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
455
-						elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
456
-						elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
457
-						elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
458
-						elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
484
+						if ($aircraftType == 0) {
485
+							$result['aircrafttype'] = "UNKNOWN";
486
+						} elseif ($aircraftType == 1) {
487
+							$result['aircrafttype'] = "GLIDER";
488
+						} elseif ($aircraftType == 2) {
489
+							$result['aircrafttype'] = "TOW_PLANE";
490
+						} elseif ($aircraftType == 3) {
491
+							$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
492
+						} elseif ($aircraftType == 4) {
493
+							$result['aircrafttype'] = "PARACHUTE";
494
+						} elseif ($aircraftType == 5) {
495
+							$result['aircrafttype'] = "DROP_PLANE";
496
+						} elseif ($aircraftType == 6) {
497
+							$result['aircrafttype'] = "HANG_GLIDER";
498
+						} elseif ($aircraftType == 7) {
499
+							$result['aircrafttype'] = "PARA_GLIDER";
500
+						} elseif ($aircraftType == 8) {
501
+							$result['aircrafttype'] = "POWERED_AIRCRAFT";
502
+						} elseif ($aircraftType == 9) {
503
+							$result['aircrafttype'] = "JET_AIRCRAFT";
504
+						} elseif ($aircraftType == 10) {
505
+							$result['aircrafttype'] = "UFO";
506
+						} elseif ($aircraftType == 11) {
507
+							$result['aircrafttype'] = "BALLOON";
508
+						} elseif ($aircraftType == 12) {
509
+							$result['aircrafttype'] = "AIRSHIP";
510
+						} elseif ($aircraftType == 13) {
511
+							$result['aircrafttype'] = "UAV";
512
+						} elseif ($aircraftType == 15) {
513
+							$result['aircrafttype'] = "STATIC_OBJECT";
514
+						}
459 515
 						$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
460 516
 						$result['stealth'] = $stealth;
461 517
 						$result['address'] = $address;
@@ -490,77 +546,181 @@  discard block
 block discarded – undo
490 546
 					//g012t088r000p000P000h38b10110
491 547
 					//g011t086r000p000P000h29b10198
492 548
 					if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
493
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
494
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
495
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
496
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
497
-						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
498
-						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
499
-						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
549
+						if ($matches[1] != '...') {
550
+							$result['wind_gust'] = round($matches[1]*1.60934,1);
551
+						}
552
+						if ($matches[2] != '...') {
553
+							$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
554
+						}
555
+						if ($matches[3] != '...') {
556
+							$result['rain'] = round((intval($matches[3])/100)*25.1,1);
557
+						}
558
+						if ($matches[4] != '...') {
559
+							$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
560
+						}
561
+						if ($matches[5] != '...') {
562
+							$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
563
+						}
564
+						if ($matches[6] != '...') {
565
+							$result['humidity'] = intval($matches[6]);
566
+						}
567
+						if ($matches[7] != '...') {
568
+							$result['pressure'] = round((intval($matches[7])/10),1);
569
+						}
500 570
 						$body_parse = substr($body_parse,strlen($matches[0]));
501 571
 					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
502
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
503
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
504
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
505
-						if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
506
-						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
507
-						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
508
-						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
572
+						if ($matches[1] != '...') {
573
+							$result['wind_gust'] = round($matches[1]*1.60934,1);
574
+						}
575
+						if ($matches[2] != '...') {
576
+							$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
577
+						}
578
+						if ($matches[3] != '...') {
579
+							$result['rain'] = round((intval($matches[3])/100)*25.1,1);
580
+						}
581
+						if ($matches[5] != '...') {
582
+							$result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
583
+						}
584
+						if ($matches[4] != '...') {
585
+							$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
586
+						}
587
+						if ($matches[6] != '...') {
588
+							$result['humidity'] = intval($matches[6]);
589
+						}
590
+						if ($matches[7] != '...') {
591
+							$result['pressure'] = round((intval($matches[7])/10),1);
592
+						}
509 593
 						$body_parse = substr($body_parse,strlen($matches[0]));
510 594
 					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
511
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
512
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
513
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
514
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
515
-						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
516
-						if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
517
-						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
595
+						if ($matches[1] != '...') {
596
+							$result['wind_gust'] = round($matches[1]*1.60934,1);
597
+						}
598
+						if ($matches[2] != '...') {
599
+							$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
600
+						}
601
+						if ($matches[3] != '...') {
602
+							$result['rain'] = round((intval($matches[3])/100)*25.1,1);
603
+						}
604
+						if ($matches[4] != '...') {
605
+							$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
606
+						}
607
+						if ($matches[5] != '...') {
608
+							$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
609
+						}
610
+						if ($matches[7] != '...') {
611
+							$result['humidity'] = intval($matches[7]);
612
+						}
613
+						if ($matches[6] != '...') {
614
+							$result['pressure'] = round((intval($matches[6])/10),1);
615
+						}
518 616
 						$body_parse = substr($body_parse,strlen($matches[0]));
519 617
 					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
520
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
524
-						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
525
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
618
+						if ($matches[1] != '...') {
619
+							$result['wind_gust'] = round($matches[1]*1.60934,1);
620
+						}
621
+						if ($matches[2] != '...') {
622
+							$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
623
+						}
624
+						if ($matches[3] != '...') {
625
+							$result['rain'] = round((intval($matches[3])/100)*25.1,1);
626
+						}
627
+						if ($matches[4] != '...') {
628
+							$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
629
+						}
630
+						if ($matches[6] != '...') {
631
+							$result['humidity'] = intval($matches[6]);
632
+						}
633
+						if ($matches[5] != '...') {
634
+							$result['pressure'] = round((intval($matches[5])/10),1);
635
+						}
526 636
 						$body_parse = substr($body_parse,strlen($matches[0]));
527 637
 					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
528
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
529
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
530
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
531
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
532
-						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
533
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
638
+						if ($matches[1] != '...') {
639
+							$result['wind_gust'] = round($matches[1]*1.60934,1);
640
+						}
641
+						if ($matches[2] != '...') {
642
+							$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
643
+						}
644
+						if ($matches[3] != '...') {
645
+							$result['rain'] = round((intval($matches[3])/100)*25.1,1);
646
+						}
647
+						if ($matches[4] != '...') {
648
+							$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
649
+						}
650
+						if ($matches[6] != '...') {
651
+							$result['humidity'] = intval($matches[6]);
652
+						}
653
+						if ($matches[5] != '...') {
654
+							$result['pressure'] = round((intval($matches[5])/10),1);
655
+						}
534 656
 						$body_parse = substr($body_parse,strlen($matches[0]));
535 657
 					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
536
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
537
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
538
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
539
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
540
-						if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
541
-						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
658
+						if ($matches[1] != '...') {
659
+							$result['wind_gust'] = round($matches[1]*1.60934,1);
660
+						}
661
+						if ($matches[2] != '...') {
662
+							$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
663
+						}
664
+						if ($matches[3] != '...') {
665
+							$result['rain'] = round((intval($matches[3])/100)*25.1,1);
666
+						}
667
+						if ($matches[4] != '...') {
668
+							$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
669
+						}
670
+						if ($matches[5] != '...') {
671
+							$result['humidity'] = intval($matches[5]);
672
+						}
673
+						if ($matches[6] != '...') {
674
+							$result['pressure'] = round((intval($matches[6])/10),1);
675
+						}
542 676
 						$body_parse = substr($body_parse,strlen($matches[0]));
543 677
 					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
544
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
545
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
546
-						if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
547
-						if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
678
+						if ($matches[1] != '...') {
679
+							$result['wind_gust'] = round($matches[1]*1.60934,1);
680
+						}
681
+						if ($matches[2] != '...') {
682
+							$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
683
+						}
684
+						if ($matches[2] != '...') {
685
+							$result['humidity'] = intval($matches[3]);
686
+						}
687
+						if ($matches[4] != '...') {
688
+							$result['pressure'] = round((intval($matches[4])/10),1);
689
+						}
548 690
 						$body_parse = substr($body_parse,strlen($matches[0]));
549 691
 					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
550
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
551
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
552
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
553
-						if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
554
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
692
+						if ($matches[1] != '...') {
693
+							$result['wind_gust'] = round($matches[1]*1.60934,1);
694
+						}
695
+						if ($matches[2] != '...') {
696
+							$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
697
+						}
698
+						if ($matches[3] != '...') {
699
+							$result['rain'] = round((intval($matches[3])/100)*25.1,1);
700
+						}
701
+						if ($matches[4] != '...') {
702
+							$result['humidity'] = intval($matches[4]);
703
+						}
704
+						if ($matches[5] != '...') {
705
+							$result['pressure'] = round((intval($matches[5])/10),1);
706
+						}
555 707
 						$body_parse = substr($body_parse,strlen($matches[0]));
556 708
 					}
557 709
 					$result['comment'] = trim($body_parse);
558 710
 				}
559
-			} else $result['comment'] = trim($body_parse);
711
+			} else {
712
+				$result['comment'] = trim($body_parse);
713
+			}
714
+		}
715
+		if (isset($result['latitude'])) {
716
+			$result['latitude'] = round($result['latitude'],4);
717
+		}
718
+		if (isset($result['longitude'])) {
719
+			$result['longitude'] = round($result['longitude'],4);
720
+		}
721
+		if ($debug) {
722
+			print_r($result);
560 723
 		}
561
-		if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
562
-		if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
563
-		if ($debug) print_r($result);
564 724
 		return $result;
565 725
 	}
566 726
 
@@ -572,12 +732,21 @@  discard block
 block discarded – undo
572 732
 		$aprs_connect = 0;
573 733
 		$aprs_keep = 120;
574 734
 		$aprs_last_tx = time();
575
-		if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
576
-		else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
577
-		if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
578
-		else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
579
-		if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
580
-		else $aprs_pass = '-1';
735
+		if (isset($globalAPRSversion)) {
736
+			$aprs_version = $globalAPRSversion;
737
+		} else {
738
+			$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
739
+		}
740
+		if (isset($globalServerAPRSssid)) {
741
+			$aprs_ssid = $globalServerAPRSssid;
742
+		} else {
743
+			$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
744
+		}
745
+		if (isset($globalServerAPRSpass)) {
746
+			$aprs_pass = $globalServerAPRSpass;
747
+		} else {
748
+			$aprs_pass = '-1';
749
+		}
581 750
 		$aprs_filter  = '';
582 751
 		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
583 752
 		$Common = new Common();
@@ -616,10 +785,14 @@  discard block
 block discarded – undo
616 785
 	*/
617 786
 	public function send($data) {
618 787
 		global $globalDebug;
619
-		if ($this->connected === false) $this->connect();
788
+		if ($this->connected === false) {
789
+			$this->connect();
790
+		}
620 791
 		$send = socket_send( $this->socket  , $data , strlen($data),0);
621 792
 		if ($send === FALSE) {
622
-			if ($globalDebug) echo 'Reconnect...';
793
+			if ($globalDebug) {
794
+				echo 'Reconnect...';
795
+			}
623 796
 			socket_close($this->socket);
624 797
 			$this->connect();
625 798
 		}
@@ -642,22 +815,32 @@  discard block
 block discarded – undo
642 815
 			//$w = '00';
643 816
 			$custom = '';
644 817
 			if ($ident != '') {
645
-				if ($custom != '') $custom .= '/';
818
+				if ($custom != '') {
819
+					$custom .= '/';
820
+				}
646 821
 				$custom .= 'CS='.$ident;
647 822
 			}
648 823
 			if ($squawk != '') {
649
-				if ($custom != '') $custom .= '/';
824
+				if ($custom != '') {
825
+					$custom .= '/';
826
+				}
650 827
 				$custom .= 'SQ='.$squawk;
651 828
 			}
652 829
 			if ($verticalrate != '') {
653
-				if ($custom != '') $custom .= '/';
830
+				if ($custom != '') {
831
+					$custom .= '/';
832
+				}
654 833
 				$custom .= 'VR='.$verticalrate;
655 834
 			}
656 835
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
657
-				if ($custom != '') $custom .= '/';
836
+				if ($custom != '') {
837
+					$custom .= '/';
838
+				}
658 839
 				$custom .= 'AI='.$aircraft_icao;
659 840
 			}
660
-			if ($custom != '') $custom = ' '.$custom;
841
+			if ($custom != '') {
842
+				$custom = ' '.$custom;
843
+			}
661 844
 			/*
662 845
 			// Use AMSL altitude
663 846
 			$GeoidClass = new GeoidHeight();
@@ -682,30 +865,44 @@  discard block
 block discarded – undo
682 865
 			//$w = '00';
683 866
 			$custom = '';
684 867
 			if ($ident != '') {
685
-				if ($custom != '') $custom .= '/';
868
+				if ($custom != '') {
869
+					$custom .= '/';
870
+				}
686 871
 				$custom .= 'CS='.str_replace(' ','_',$ident);
687 872
 			}
688 873
 			if ($typeid != '') {
689
-				if ($custom != '') $custom .= '/';
874
+				if ($custom != '') {
875
+					$custom .= '/';
876
+				}
690 877
 				$custom .= 'TI='.$typeid;
691 878
 			}
692 879
 			if ($statusid != '') {
693
-				if ($custom != '') $custom .= '/';
880
+				if ($custom != '') {
881
+					$custom .= '/';
882
+				}
694 883
 				$custom .= 'SI='.$statusid;
695 884
 			}
696 885
 			if ($imo != '') {
697
-				if ($custom != '') $custom .= '/';
886
+				if ($custom != '') {
887
+					$custom .= '/';
888
+				}
698 889
 				$custom .= 'IMO='.$imo;
699 890
 			}
700 891
 			if ($arrival_date != '') {
701
-				if ($custom != '') $custom .= '/';
892
+				if ($custom != '') {
893
+					$custom .= '/';
894
+				}
702 895
 				$custom .= 'AD='.strtotime($arrival_date);
703 896
 			}
704 897
 			if ($arrival_code != '') {
705
-				if ($custom != '') $custom .= '/';
898
+				if ($custom != '') {
899
+					$custom .= '/';
900
+				}
706 901
 				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
707 902
 			}
708
-			if ($custom != '') $custom = ' '.$custom;
903
+			if ($custom != '') {
904
+				$custom = ' '.$custom;
905
+			}
709 906
 			$altitude = 0;
710 907
 			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
711 908
 		}
Please login to merge, or discard this patch.
require/class.SBS.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -190,12 +190,20 @@
 block discarded – undo
190 190
 		return 1;
191 191
 	}
192 192
 
193
+	/**
194
+	 * @param double $lat
195
+	 * @param integer $isodd
196
+	 */
193 197
 	private function cprN($lat,$isodd) {
194 198
 		$nl = $this->cprNL($lat) - $isodd;
195 199
 		if ($nl > 1) return $nl;
196 200
 		else return 1;
197 201
 	}
198 202
 
203
+	/**
204
+	 * @param string $msg
205
+	 * @param string $bin
206
+	 */
199 207
 	private function parityCheck($msg, $bin) {
200 208
 		$modes_checksum_table = array(
201 209
 		    0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -198,20 +198,20 @@
 block discarded – undo
198 198
 
199 199
 	private function parityCheck($msg, $bin) {
200 200
 		$modes_checksum_table = array(
201
-		    0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
202
-		    0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14,
203
-		    0x682e0a, 0x341705, 0xe5f186, 0x72f8c3, 0xc68665, 0x9cb936, 0x4e5c9b, 0xd8d449,
204
-		    0x939020, 0x49c810, 0x24e408, 0x127204, 0x093902, 0x049c81, 0xfdb444, 0x7eda22,
205
-		    0x3f6d11, 0xe04c8c, 0x702646, 0x381323, 0xe3f395, 0x8e03ce, 0x4701e7, 0xdc7af7,
206
-		    0x91c77f, 0xb719bb, 0xa476d9, 0xadc168, 0x56e0b4, 0x2b705a, 0x15b82d, 0xf52612,
207
-		    0x7a9309, 0xc2b380, 0x6159c0, 0x30ace0, 0x185670, 0x0c2b38, 0x06159c, 0x030ace,
208
-		    0x018567, 0xff38b7, 0x80665f, 0xbfc92b, 0xa01e91, 0xaff54c, 0x57faa6, 0x2bfd53,
209
-		    0xea04ad, 0x8af852, 0x457c29, 0xdd4410, 0x6ea208, 0x375104, 0x1ba882, 0x0dd441,
210
-		    0xf91024, 0x7c8812, 0x3e4409, 0xe0d800, 0x706c00, 0x383600, 0x1c1b00, 0x0e0d80,
211
-		    0x0706c0, 0x038360, 0x01c1b0, 0x00e0d8, 0x00706c, 0x003836, 0x001c1b, 0xfff409,
212
-		    0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
213
-		    0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
214
-		    0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
201
+			0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
202
+			0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14,
203
+			0x682e0a, 0x341705, 0xe5f186, 0x72f8c3, 0xc68665, 0x9cb936, 0x4e5c9b, 0xd8d449,
204
+			0x939020, 0x49c810, 0x24e408, 0x127204, 0x093902, 0x049c81, 0xfdb444, 0x7eda22,
205
+			0x3f6d11, 0xe04c8c, 0x702646, 0x381323, 0xe3f395, 0x8e03ce, 0x4701e7, 0xdc7af7,
206
+			0x91c77f, 0xb719bb, 0xa476d9, 0xadc168, 0x56e0b4, 0x2b705a, 0x15b82d, 0xf52612,
207
+			0x7a9309, 0xc2b380, 0x6159c0, 0x30ace0, 0x185670, 0x0c2b38, 0x06159c, 0x030ace,
208
+			0x018567, 0xff38b7, 0x80665f, 0xbfc92b, 0xa01e91, 0xaff54c, 0x57faa6, 0x2bfd53,
209
+			0xea04ad, 0x8af852, 0x457c29, 0xdd4410, 0x6ea208, 0x375104, 0x1ba882, 0x0dd441,
210
+			0xf91024, 0x7c8812, 0x3e4409, 0xe0d800, 0x706c00, 0x383600, 0x1c1b00, 0x0e0d80,
211
+			0x0706c0, 0x038360, 0x01c1b0, 0x00e0d8, 0x00706c, 0x003836, 0x001c1b, 0xfff409,
212
+			0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
213
+			0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
214
+			0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
215 215
 		);
216 216
 		$crc = 0;
217 217
 		$checksum = intval(substr($msg,22,6),16);
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -18,82 +18,82 @@  discard block
 block discarded – undo
18 18
 	public function parse($buffer) {
19 19
 		// Not yet finished, no CRC checks
20 20
 		$data = array();
21
-		$typehex = substr($buffer,0,1);
22
-		if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
23
-		elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
24
-		else $hex = substr($buffer,1,-1);
25
-		$bin = gmp_strval( gmp_init($hex,16), 2);
21
+		$typehex = substr($buffer, 0, 1);
22
+		if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1);
23
+		elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13);
24
+		else $hex = substr($buffer, 1, -1);
25
+		$bin = gmp_strval(gmp_init($hex, 16), 2);
26 26
 		//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
27 27
 		if (strlen($hex) == 28) {
28
-			$df = intval(substr($bin,0,5),2);
28
+			$df = intval(substr($bin, 0, 5), 2);
29 29
 			//$ca = intval(substr($bin,5,3),2);
30 30
 			// Only support DF17 for now
31 31
 			//if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
32
-			if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
33
-				$icao = substr($hex,2,6);
32
+			if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) {
33
+				$icao = substr($hex, 2, 6);
34 34
 				$data['hex'] = $icao;
35
-				$tc = intval(substr($bin,32,5),2);
35
+				$tc = intval(substr($bin, 32, 5), 2);
36 36
 				if ($tc >= 1 && $tc <= 4) {
37 37
 					//callsign
38
-					$csbin = substr($bin,40,56);
38
+					$csbin = substr($bin, 40, 56);
39 39
 					$charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
40 40
 					$cs = '';
41
-					$cs .= $charset[intval(substr($csbin,0,6),2)];
42
-					$cs .= $charset[intval(substr($csbin,6,6),2)];
43
-					$cs .= $charset[intval(substr($csbin,12,6),2)];
44
-					$cs .= $charset[intval(substr($csbin,18,6),2)];
45
-					$cs .= $charset[intval(substr($csbin,24,6),2)];
46
-					$cs .= $charset[intval(substr($csbin,30,6),2)];
47
-					$cs .= $charset[intval(substr($csbin,36,6),2)];
48
-					$cs .= $charset[intval(substr($csbin,42,6),2)];
49
-					$cs = str_replace('_','',$cs);
50
-					$cs = str_replace('#','',$cs);
41
+					$cs .= $charset[intval(substr($csbin, 0, 6), 2)];
42
+					$cs .= $charset[intval(substr($csbin, 6, 6), 2)];
43
+					$cs .= $charset[intval(substr($csbin, 12, 6), 2)];
44
+					$cs .= $charset[intval(substr($csbin, 18, 6), 2)];
45
+					$cs .= $charset[intval(substr($csbin, 24, 6), 2)];
46
+					$cs .= $charset[intval(substr($csbin, 30, 6), 2)];
47
+					$cs .= $charset[intval(substr($csbin, 36, 6), 2)];
48
+					$cs .= $charset[intval(substr($csbin, 42, 6), 2)];
49
+					$cs = str_replace('_', '', $cs);
50
+					$cs = str_replace('#', '', $cs);
51 51
 					$callsign = $cs;
52 52
 					$data['ident'] = $callsign;
53 53
 				} elseif ($tc >= 9 && $tc <= 18) {
54 54
 					// Check Q-bit
55
-					$q = substr($bin,47,1);
55
+					$q = substr($bin, 47, 1);
56 56
 					if ($q) {
57
-						$n = intval(substr($bin,40,7).substr($bin,48,4),2);
58
-						$alt = $n*25-1000;
57
+						$n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2);
58
+						$alt = $n*25 - 1000;
59 59
 						$data['altitude'] = $alt;
60 60
 					}
61 61
 					// Check odd/even flag
62
-					$oe = substr($bin,53,1);
62
+					$oe = substr($bin, 53, 1);
63 63
 					//if ($oe) => odd else even
64 64
 					//  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
65
-					$cprlat = intval(substr($bin,54,17),2)/131072.0;
66
-					$cprlon = intval(substr($bin,71,17),2)/131072.0;
67
-					if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
65
+					$cprlat = intval(substr($bin, 54, 17), 2)/131072.0;
66
+					$cprlon = intval(substr($bin, 71, 17), 2)/131072.0;
67
+					if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time());
68 68
 					elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
69 69
 						$cprlat_odd = $cprlat;
70 70
 						$cprlon_odd = $cprlon;
71 71
 						$cprlat_even = $this::$latlon[$icao]['latitude'];
72 72
 						$cprlon_even = $this::$latlon[$icao]['longitude'];
73
-						$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
74
-						$lat_even = (360.0/60)*($j%60+$cprlat_even);
75
-						$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
73
+						$j = 59*$cprlat_even - 60*$cprlat_odd + 0.5;
74
+						$lat_even = (360.0/60)*($j%60 + $cprlat_even);
75
+						$lat_odd = (360.0/59)*($j%59 + $cprlat_odd);
76 76
 						if ($lat_even >= 270) $lat_even = $lat_even - 360;
77 77
 						if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
78 78
 						// check latitude zone
79 79
 						if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
80 80
 							if ($this::$latlon[$icao]['created'] > time()) {
81
-								$ni = $this->cprN($lat_even,0);
82
-								$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
83
-								$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
81
+								$ni = $this->cprN($lat_even, 0);
82
+								$m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5);
83
+								$lon = (360.0/$ni)*($m%$ni + $cprlon_even);
84 84
 								$lat = $lat_even;
85
-								if ($lon > 180) $lon = $lon -360;
85
+								if ($lon > 180) $lon = $lon - 360;
86 86
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 87
 									//if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
88 88
 									$data['latitude'] = $lat;
89 89
 									$data['longitude'] = $lon;
90 90
 								}
91 91
 							} else {
92
-								$ni = $this->cprN($lat_odd,1);
93
-								$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
94
-								$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
92
+								$ni = $this->cprN($lat_odd, 1);
93
+								$m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5);
94
+								$lon = (360.0/$ni)*($m%$ni + $cprlon_odd);
95 95
 								$lat = $lat_odd;
96
-								if ($lon > 180) $lon = $lon -360;
96
+								if ($lon > 180) $lon = $lon - 360;
97 97
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
98 98
 									//if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
99 99
 									$data['latitude'] = $lat;
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
 					}
106 106
 				} elseif ($tc == 19) {
107 107
 					// speed & heading
108
-					$v_ew_dir = intval(substr($bin,45,1));
109
-					$v_ew = intval(substr($bin,46,10),2);
110
-					$v_ns_dir = intval(substr($bin,56,1));
111
-					$v_ns = intval(substr($bin,57,10),2);
108
+					$v_ew_dir = intval(substr($bin, 45, 1));
109
+					$v_ew = intval(substr($bin, 46, 10), 2);
110
+					$v_ns_dir = intval(substr($bin, 56, 1));
111
+					$v_ns = intval(substr($bin, 57, 10), 2);
112 112
 					if ($v_ew_dir) $v_ew = -1*$v_ew;
113 113
 					if ($v_ns_dir) $v_ns = -1*$v_ns;
114
-					$speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
115
-					$heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
116
-					if ($heading <0) $heading = $heading+360;
114
+					$speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew);
115
+					$heading = atan2($v_ew, $v_ns)*360.0/(2*pi());
116
+					if ($heading < 0) $heading = $heading + 360;
117 117
 					$data['speed'] = $speed;
118 118
 					$data['heading'] = $heading;
119 119
 				}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * Lookup table to convert the latitude to index.
129 129
 	*/
130 130
 	private function cprNL($lat) {
131
-		if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
131
+		if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator.
132 132
 		if ($lat < 10.47047130) return 59;
133 133
 		if ($lat < 14.82817437) return 58;
134 134
 		if ($lat < 18.18626357) return 57;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		return 1;
191 191
 	}
192 192
 
193
-	private function cprN($lat,$isodd) {
193
+	private function cprN($lat, $isodd) {
194 194
 		$nl = $this->cprNL($lat) - $isodd;
195 195
 		if ($nl > 1) return $nl;
196 196
 		else return 1;
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 		    0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
215 215
 		);
216 216
 		$crc = 0;
217
-		$checksum = intval(substr($msg,22,6),16);
217
+		$checksum = intval(substr($msg, 22, 6), 16);
218 218
 		for ($j = 0; $j < strlen($bin); $j++) {
219
-			if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
219
+			if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0);
220 220
 		}
221 221
 		if ($crc == $checksum) return true;
222 222
 		else {
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 			$msg['aircraftid'] = hexdec($data['address']);
239 239
 			$msg['hex'] = $data['address'];
240 240
 			$msg['flightid'] = hexdec($data['address']);
241
-			$msg['date_gen'] = date('Y/m/d',$data['timestamp']);
242
-			$msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
243
-			$msg['date_log'] = date('Y/m/d',$data['timestamp']);
244
-			$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
241
+			$msg['date_gen'] = date('Y/m/d', $data['timestamp']);
242
+			$msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180';
243
+			$msg['date_log'] = date('Y/m/d', $data['timestamp']);
244
+			$msg['time_log'] = date('H:i:s', $data['timestamp']).'.180';
245 245
 			$msg['callsign'] = $data['ident'];
246 246
 			$msg['altitude'] = '';
247 247
 			$msg['speed'] = '';
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			$msg['emergency'] = '';
255 255
 			$msg['SPI'] = '';
256 256
 			$msg['ground'] = '';
257
-			$result[] = implode(',',$msg);
257
+			$result[] = implode(',', $msg);
258 258
 		}
259 259
 		if (isset($data['latitude']) && $data['latitude'] != 0) {
260 260
 			$msg = array();
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 			$msg['aircraftid'] = hexdec($data['address']);
265 265
 			$msg['hex'] = $data['address'];
266 266
 			$msg['flightid'] = hexdec($data['address']);
267
-			$msg['date_gen'] = date('Y/m/d',$data['timestamp']);
268
-			$msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
269
-			$msg['date_log'] = date('Y/m/d',$data['timestamp']);
270
-			$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
267
+			$msg['date_gen'] = date('Y/m/d', $data['timestamp']);
268
+			$msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180';
269
+			$msg['date_log'] = date('Y/m/d', $data['timestamp']);
270
+			$msg['time_log'] = date('H:i:s', $data['timestamp']).'.180';
271 271
 			$msg['callsign'] = '';
272 272
 			if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
273 273
 			else $msg['altitude'] = '';
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 			$msg['SPI'] = 0;
286 286
 			if (isset($data['ground'])) $msg['ground'] = 1;
287 287
 			else $msg['ground'] = 0;
288
-			$result[] = implode(',',$msg);
288
+			$result[] = implode(',', $msg);
289 289
 		}
290 290
 		return $result;
291 291
 	}
Please login to merge, or discard this patch.
Braces   +248 added lines, -87 removed lines patch added patch discarded remove patch
@@ -19,9 +19,13 @@  discard block
 block discarded – undo
19 19
 		// Not yet finished, no CRC checks
20 20
 		$data = array();
21 21
 		$typehex = substr($buffer,0,1);
22
-		if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
23
-		elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
24
-		else $hex = substr($buffer,1,-1);
22
+		if ($typehex == '*' || $typehex == ':') {
23
+			$hex = substr($buffer,1,-1);
24
+		} elseif ($typehex == '@' || $typehex == '%') {
25
+			$hex = substr($buffer,13,-13);
26
+		} else {
27
+			$hex = substr($buffer,1,-1);
28
+		}
25 29
 		$bin = gmp_strval( gmp_init($hex,16), 2);
26 30
 		//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
27 31
 		if (strlen($hex) == 28) {
@@ -64,8 +68,9 @@  discard block
 block discarded – undo
64 68
 					//  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
65 69
 					$cprlat = intval(substr($bin,54,17),2)/131072.0;
66 70
 					$cprlon = intval(substr($bin,71,17),2)/131072.0;
67
-					if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
68
-					elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
71
+					if ($oe == 0) {
72
+						$this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
73
+					} elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
69 74
 						$cprlat_odd = $cprlat;
70 75
 						$cprlon_odd = $cprlon;
71 76
 						$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -73,8 +78,12 @@  discard block
 block discarded – undo
73 78
 						$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
74 79
 						$lat_even = (360.0/60)*($j%60+$cprlat_even);
75 80
 						$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
76
-						if ($lat_even >= 270) $lat_even = $lat_even - 360;
77
-						if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
81
+						if ($lat_even >= 270) {
82
+							$lat_even = $lat_even - 360;
83
+						}
84
+						if ($lat_odd >= 270) {
85
+							$lat_odd = $lat_odd - 360;
86
+						}
78 87
 						// check latitude zone
79 88
 						if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
80 89
 							if ($this::$latlon[$icao]['created'] > time()) {
@@ -82,7 +91,9 @@  discard block
 block discarded – undo
82 91
 								$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
83 92
 								$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
84 93
 								$lat = $lat_even;
85
-								if ($lon > 180) $lon = $lon -360;
94
+								if ($lon > 180) {
95
+									$lon = $lon -360;
96
+								}
86 97
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 98
 									//if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
88 99
 									$data['latitude'] = $lat;
@@ -93,14 +104,18 @@  discard block
 block discarded – undo
93 104
 								$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
94 105
 								$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
95 106
 								$lat = $lat_odd;
96
-								if ($lon > 180) $lon = $lon -360;
107
+								if ($lon > 180) {
108
+									$lon = $lon -360;
109
+								}
97 110
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
98 111
 									//if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
99 112
 									$data['latitude'] = $lat;
100 113
 									$data['longitude'] = $lon;
101 114
 								}
102 115
 							}
103
-						} else echo "Not cprNL";
116
+						} else {
117
+							echo "Not cprNL";
118
+						}
104 119
 						unset($this::$latlon[$icao]);
105 120
 					}
106 121
 				} elseif ($tc == 19) {
@@ -109,11 +124,17 @@  discard block
 block discarded – undo
109 124
 					$v_ew = intval(substr($bin,46,10),2);
110 125
 					$v_ns_dir = intval(substr($bin,56,1));
111 126
 					$v_ns = intval(substr($bin,57,10),2);
112
-					if ($v_ew_dir) $v_ew = -1*$v_ew;
113
-					if ($v_ns_dir) $v_ns = -1*$v_ns;
127
+					if ($v_ew_dir) {
128
+						$v_ew = -1*$v_ew;
129
+					}
130
+					if ($v_ns_dir) {
131
+						$v_ns = -1*$v_ns;
132
+					}
114 133
 					$speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
115 134
 					$heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
116
-					if ($heading <0) $heading = $heading+360;
135
+					if ($heading <0) {
136
+						$heading = $heading+360;
137
+					}
117 138
 					$data['speed'] = $speed;
118 139
 					$data['heading'] = $heading;
119 140
 				}
@@ -128,72 +149,194 @@  discard block
 block discarded – undo
128 149
 	 * Lookup table to convert the latitude to index.
129 150
 	*/
130 151
 	private function cprNL($lat) {
131
-		if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
132
-		if ($lat < 10.47047130) return 59;
133
-		if ($lat < 14.82817437) return 58;
134
-		if ($lat < 18.18626357) return 57;
135
-		if ($lat < 21.02939493) return 56;
136
-		if ($lat < 23.54504487) return 55;
137
-		if ($lat < 25.82924707) return 54;
138
-		if ($lat < 27.93898710) return 53;
139
-		if ($lat < 29.91135686) return 52;
140
-		if ($lat < 31.77209708) return 51;
141
-		if ($lat < 33.53993436) return 50;
142
-		if ($lat < 35.22899598) return 49;
143
-		if ($lat < 36.85025108) return 48;
144
-		if ($lat < 38.41241892) return 47;
145
-		if ($lat < 39.92256684) return 46;
146
-		if ($lat < 41.38651832) return 45;
147
-		if ($lat < 42.80914012) return 44;
148
-		if ($lat < 44.19454951) return 43;
149
-		if ($lat < 45.54626723) return 42;
150
-		if ($lat < 46.86733252) return 41;
151
-		if ($lat < 48.16039128) return 40;
152
-		if ($lat < 49.42776439) return 39;
153
-		if ($lat < 50.67150166) return 38;
154
-		if ($lat < 51.89342469) return 37;
155
-		if ($lat < 53.09516153) return 36;
156
-		if ($lat < 54.27817472) return 35;
157
-		if ($lat < 55.44378444) return 34;
158
-		if ($lat < 56.59318756) return 33;
159
-		if ($lat < 57.72747354) return 32;
160
-		if ($lat < 58.84763776) return 31;
161
-		if ($lat < 59.95459277) return 30;
162
-		if ($lat < 61.04917774) return 29;
163
-		if ($lat < 62.13216659) return 28;
164
-		if ($lat < 63.20427479) return 27;
165
-		if ($lat < 64.26616523) return 26;
166
-		if ($lat < 65.31845310) return 25;
167
-		if ($lat < 66.36171008) return 24;
168
-		if ($lat < 67.39646774) return 23;
169
-		if ($lat < 68.42322022) return 22;
170
-		if ($lat < 69.44242631) return 21;
171
-		if ($lat < 70.45451075) return 20;
172
-		if ($lat < 71.45986473) return 19;
173
-		if ($lat < 72.45884545) return 18;
174
-		if ($lat < 73.45177442) return 17;
175
-		if ($lat < 74.43893416) return 16;
176
-		if ($lat < 75.42056257) return 15;
177
-		if ($lat < 76.39684391) return 14;
178
-		if ($lat < 77.36789461) return 13;
179
-		if ($lat < 78.33374083) return 12;
180
-		if ($lat < 79.29428225) return 11;
181
-		if ($lat < 80.24923213) return 10;
182
-		if ($lat < 81.19801349) return 9;
183
-		if ($lat < 82.13956981) return 8;
184
-		if ($lat < 83.07199445) return 7;
185
-		if ($lat < 83.99173563) return 6;
186
-		if ($lat < 84.89166191) return 5;
187
-		if ($lat < 85.75541621) return 4;
188
-		if ($lat < 86.53536998) return 3;
189
-		if ($lat < 87.00000000) return 2;
152
+		if ($lat < 0) {
153
+			$lat = -$lat;
154
+		}
155
+		// Table is simmetric about the equator.
156
+		if ($lat < 10.47047130) {
157
+			return 59;
158
+		}
159
+		if ($lat < 14.82817437) {
160
+			return 58;
161
+		}
162
+		if ($lat < 18.18626357) {
163
+			return 57;
164
+		}
165
+		if ($lat < 21.02939493) {
166
+			return 56;
167
+		}
168
+		if ($lat < 23.54504487) {
169
+			return 55;
170
+		}
171
+		if ($lat < 25.82924707) {
172
+			return 54;
173
+		}
174
+		if ($lat < 27.93898710) {
175
+			return 53;
176
+		}
177
+		if ($lat < 29.91135686) {
178
+			return 52;
179
+		}
180
+		if ($lat < 31.77209708) {
181
+			return 51;
182
+		}
183
+		if ($lat < 33.53993436) {
184
+			return 50;
185
+		}
186
+		if ($lat < 35.22899598) {
187
+			return 49;
188
+		}
189
+		if ($lat < 36.85025108) {
190
+			return 48;
191
+		}
192
+		if ($lat < 38.41241892) {
193
+			return 47;
194
+		}
195
+		if ($lat < 39.92256684) {
196
+			return 46;
197
+		}
198
+		if ($lat < 41.38651832) {
199
+			return 45;
200
+		}
201
+		if ($lat < 42.80914012) {
202
+			return 44;
203
+		}
204
+		if ($lat < 44.19454951) {
205
+			return 43;
206
+		}
207
+		if ($lat < 45.54626723) {
208
+			return 42;
209
+		}
210
+		if ($lat < 46.86733252) {
211
+			return 41;
212
+		}
213
+		if ($lat < 48.16039128) {
214
+			return 40;
215
+		}
216
+		if ($lat < 49.42776439) {
217
+			return 39;
218
+		}
219
+		if ($lat < 50.67150166) {
220
+			return 38;
221
+		}
222
+		if ($lat < 51.89342469) {
223
+			return 37;
224
+		}
225
+		if ($lat < 53.09516153) {
226
+			return 36;
227
+		}
228
+		if ($lat < 54.27817472) {
229
+			return 35;
230
+		}
231
+		if ($lat < 55.44378444) {
232
+			return 34;
233
+		}
234
+		if ($lat < 56.59318756) {
235
+			return 33;
236
+		}
237
+		if ($lat < 57.72747354) {
238
+			return 32;
239
+		}
240
+		if ($lat < 58.84763776) {
241
+			return 31;
242
+		}
243
+		if ($lat < 59.95459277) {
244
+			return 30;
245
+		}
246
+		if ($lat < 61.04917774) {
247
+			return 29;
248
+		}
249
+		if ($lat < 62.13216659) {
250
+			return 28;
251
+		}
252
+		if ($lat < 63.20427479) {
253
+			return 27;
254
+		}
255
+		if ($lat < 64.26616523) {
256
+			return 26;
257
+		}
258
+		if ($lat < 65.31845310) {
259
+			return 25;
260
+		}
261
+		if ($lat < 66.36171008) {
262
+			return 24;
263
+		}
264
+		if ($lat < 67.39646774) {
265
+			return 23;
266
+		}
267
+		if ($lat < 68.42322022) {
268
+			return 22;
269
+		}
270
+		if ($lat < 69.44242631) {
271
+			return 21;
272
+		}
273
+		if ($lat < 70.45451075) {
274
+			return 20;
275
+		}
276
+		if ($lat < 71.45986473) {
277
+			return 19;
278
+		}
279
+		if ($lat < 72.45884545) {
280
+			return 18;
281
+		}
282
+		if ($lat < 73.45177442) {
283
+			return 17;
284
+		}
285
+		if ($lat < 74.43893416) {
286
+			return 16;
287
+		}
288
+		if ($lat < 75.42056257) {
289
+			return 15;
290
+		}
291
+		if ($lat < 76.39684391) {
292
+			return 14;
293
+		}
294
+		if ($lat < 77.36789461) {
295
+			return 13;
296
+		}
297
+		if ($lat < 78.33374083) {
298
+			return 12;
299
+		}
300
+		if ($lat < 79.29428225) {
301
+			return 11;
302
+		}
303
+		if ($lat < 80.24923213) {
304
+			return 10;
305
+		}
306
+		if ($lat < 81.19801349) {
307
+			return 9;
308
+		}
309
+		if ($lat < 82.13956981) {
310
+			return 8;
311
+		}
312
+		if ($lat < 83.07199445) {
313
+			return 7;
314
+		}
315
+		if ($lat < 83.99173563) {
316
+			return 6;
317
+		}
318
+		if ($lat < 84.89166191) {
319
+			return 5;
320
+		}
321
+		if ($lat < 85.75541621) {
322
+			return 4;
323
+		}
324
+		if ($lat < 86.53536998) {
325
+			return 3;
326
+		}
327
+		if ($lat < 87.00000000) {
328
+			return 2;
329
+		}
190 330
 		return 1;
191 331
 	}
192 332
 
193 333
 	private function cprN($lat,$isodd) {
194 334
 		$nl = $this->cprNL($lat) - $isodd;
195
-		if ($nl > 1) return $nl;
196
-		else return 1;
335
+		if ($nl > 1) {
336
+			return $nl;
337
+		} else {
338
+			return 1;
339
+		}
197 340
 	}
198 341
 
199 342
 	private function parityCheck($msg, $bin) {
@@ -216,10 +359,13 @@  discard block
 block discarded – undo
216 359
 		$crc = 0;
217 360
 		$checksum = intval(substr($msg,22,6),16);
218 361
 		for ($j = 0; $j < strlen($bin); $j++) {
219
-			if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
362
+			if ($bin[$j]) {
363
+				$crc = $crc^intval($modes_checksum_table[$j],0);
364
+			}
220 365
 		}
221
-		if ($crc == $checksum) return true;
222
-		else {
366
+		if ($crc == $checksum) {
367
+			return true;
368
+		} else {
223 369
 			//echo "**** CRC ERROR ****\n";
224 370
 			return false;
225 371
 		}
@@ -269,22 +415,37 @@  discard block
 block discarded – undo
269 415
 			$msg['date_log'] = date('Y/m/d',$data['timestamp']);
270 416
 			$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
271 417
 			$msg['callsign'] = '';
272
-			if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
273
-			else $msg['altitude'] = '';
418
+			if (isset($data['altitude'])) {
419
+				$msg['altitude'] = $data['altitude'];
420
+			} else {
421
+				$msg['altitude'] = '';
422
+			}
274 423
 			$msg['speed'] = $data['speed'];
275
-			if (isset($data['heading'])) $msg['track'] = $data['heading'];
276
-			else $msg['track'] = '';
424
+			if (isset($data['heading'])) {
425
+				$msg['track'] = $data['heading'];
426
+			} else {
427
+				$msg['track'] = '';
428
+			}
277 429
 			$msg['latitude'] = $data['latitude'];
278 430
 			$msg['longitude'] = $data['longitude'];
279
-			if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate'];
280
-			else $msg['verticalrate'] = '';
281
-			if (isset($data['squawk'])) $msg['squawk'] = $data['squawk'];
282
-			else $msg['squawk'] = 0;
431
+			if (isset($data['verticalrate'])) {
432
+				$msg['verticalrate'] = $data['verticalrate'];
433
+			} else {
434
+				$msg['verticalrate'] = '';
435
+			}
436
+			if (isset($data['squawk'])) {
437
+				$msg['squawk'] = $data['squawk'];
438
+			} else {
439
+				$msg['squawk'] = 0;
440
+			}
283 441
 			$msg['alert'] = 0;
284 442
 			$msg['emergency'] = 0;
285 443
 			$msg['SPI'] = 0;
286
-			if (isset($data['ground'])) $msg['ground'] = 1;
287
-			else $msg['ground'] = 0;
444
+			if (isset($data['ground'])) {
445
+				$msg['ground'] = 1;
446
+			} else {
447
+				$msg['ground'] = 0;
448
+			}
288 449
 			$result[] = implode(',',$msg);
289 450
 		}
290 451
 		return $result;
Please login to merge, or discard this patch.