Completed
Push — master ( 64830d...1886a8 )
by Yannick
33:09
created
owner-sub-menu.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
 </div>
9 9
 <div class="sub-menu sub-menu-container">
10 10
 	<ul class="nav nav-pills">
11
-		<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>
11
+		<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>
12 12
 		<li class="dropdown">
13
-		    <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="#">
13
+		    <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="#">
14 14
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
15 15
 		    </a>
16 16
 		    <ul class="dropdown-menu" role="menu">
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 		    </ul>
21 21
 		</li>
22 22
 		<li class="dropdown">
23
-		    <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="#">
23
+		    <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="#">
24 24
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
25 25
 		    </a>
26 26
 		    <ul class="dropdown-menu" role="menu">
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 			  <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>
31 31
 		    </ul>
32 32
 		</li>
33
-		<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>
34
-		<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>
33
+		<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>
34
+		<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>
35 35
 	</ul>
36 36
 </div>
37 37
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +77 added lines, -11 removed lines patch added patch discarded remove patch
@@ -3,20 +3,50 @@  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
 <div class="sub-menu sub-menu-container">
10 16
 	<ul class="nav nav-pills">
11
-		<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>
17
+		<li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') {
18
+	echo '/'.$year;
19
+}
20
+?><?php if (isset($month) && $month != '') {
21
+	echo '/'.$month;
22
+}
23
+?>" <?php if (strtolower($current_page) == "owner-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
12 24
 		<li class="dropdown">
13 25
 		    <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="#">
14 26
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
15 27
 		    </a>
16 28
 		    <ul class="dropdown-menu" role="menu">
17
-		      <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>
18
-					<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>
19
-					<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>
29
+		      <li><a href="<?php print $globalURL; ?>/owner/statistics/aircraft/<?php print $owner; ?><?php if (isset($year) && $year != '') {
30
+	echo '/'.$year;
31
+}
32
+?><?php if (isset($month) && $month != '') {
33
+	echo '/'.$month;
34
+}
35
+?>"><?php echo _("Aircraft Type"); ?></a></li>
36
+					<li><a href="<?php print $globalURL; ?>/owner/statistics/registration/<?php print $owner; ?><?php if (isset($year) && $year != '') {
37
+	echo '/'.$year;
38
+}
39
+?><?php if (isset($month) && $month != '') {
40
+	echo '/'.$month;
41
+}
42
+?>"><?php echo _("Registration"); ?></a></li>
43
+					<li><a href="<?php print $globalURL; ?>/owner/statistics/manufacturer/<?php print $owner; ?><?php if (isset($year) && $year != '') {
44
+	echo '/'.$year;
45
+}
46
+?><?php if (isset($month) && $month != '') {
47
+	echo '/'.$month;
48
+}
49
+?>"><?php echo _("Manufacturer"); ?></a></li>
20 50
 		    </ul>
21 51
 		</li>
22 52
 		<li class="dropdown">
@@ -24,13 +54,49 @@  discard block
 block discarded – undo
24 54
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
25 55
 		    </a>
26 56
 		    <ul class="dropdown-menu" role="menu">
27
-		      <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>
28
-		      <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>
29
-			  <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>
30
-			  <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>
57
+		      <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') {
58
+	echo '/'.$year;
59
+}
60
+?><?php if (isset($month) && $month != '') {
61
+	echo '/'.$month;
62
+}
63
+?>"><?php echo _("Departure Airport"); ?></a></li>
64
+		      <li><a href="<?php print $globalURL; ?>/owner/statistics/departure-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') {
65
+	echo '/'.$year;
66
+}
67
+?><?php if (isset($month) && $month != '') {
68
+	echo '/'.$month;
69
+}
70
+?>"><?php echo _("Departure Airport by Country"); ?></a></li>
71
+			  <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport/<?php print $owner; ?><?php if (isset($year) && $year != '') {
72
+	echo '/'.$year;
73
+}
74
+?><?php if (isset($month) && $month != '') {
75
+	echo '/'.$month;
76
+}
77
+?>"><?php echo _("Arrival Airport"); ?></a></li>
78
+			  <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') {
79
+	echo '/'.$year;
80
+}
81
+?><?php if (isset($month) && $month != '') {
82
+	echo '/'.$month;
83
+}
84
+?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
31 85
 		    </ul>
32 86
 		</li>
33
-		<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>
34
-		<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>
87
+		<li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') {
88
+	echo '/'.$year;
89
+}
90
+?><?php if (isset($month) && $month != '') {
91
+	echo '/'.$month;
92
+}
93
+?>" <?php if (strtolower($current_page) == "owner-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
94
+		<li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') {
95
+	echo '/'.$year;
96
+}
97
+?><?php if (isset($month) && $month != '') {
98
+	echo '/'.$month;
99
+}
100
+?>" <?php if (strtolower($current_page) == "owner-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
35 101
 	</ul>
36 102
 </div>
37 103
\ No newline at end of file
Please login to merge, or discard this patch.
date-sub-menu.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 </span>
4 4
 <div class="sub-menu sub-menu-container">
5 5
 	<ul class="nav nav-pills">
6
-		<li><a href="<?php print $globalURL; ?>/date/<?php print $date; ?>" <?php if (strtolower($current_page) == "date-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
6
+		<li><a href="<?php print $globalURL; ?>/date/<?php print $date; ?>" <?php if (strtolower($current_page) == "date-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
7 7
 		<li class="dropdown">
8
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "date-statistics-aircraft" || strtolower($current_page) == "date-statistics-registration" || strtolower($current_page) == "date-statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
8
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "date-statistics-aircraft" || strtolower($current_page) == "date-statistics-registration" || strtolower($current_page) == "date-statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#">
9 9
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
10 10
 		    </a>
11 11
 		    <ul class="dropdown-menu" role="menu">
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		    </ul>
16 16
 		</li>
17 17
 		<li class="dropdown">
18
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "date-statistics-airline" || strtolower($current_page) == "date-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
18
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "date-statistics-airline" || strtolower($current_page) == "date-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
19 19
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
20 20
 		    </a>
21 21
 		    <ul class="dropdown-menu" role="menu">
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		    </ul>
25 25
 		</li>
26 26
 		<li class="dropdown">
27
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "date-statistics-departure-airport" || strtolower($current_page) == "date-statistics-departure-airport-country" || strtolower($current_page) == "date-statistics-arrival-airport" || strtolower($current_page) == "date-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
27
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "date-statistics-departure-airport" || strtolower($current_page) == "date-statistics-departure-airport-country" || strtolower($current_page) == "date-statistics-arrival-airport" || strtolower($current_page) == "date-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
28 28
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
29 29
 		    </a>
30 30
 		    <ul class="dropdown-menu" role="menu">
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 			  <li><a href="<?php print $globalURL; ?>/date/statistics/arrival-airport-country/<?php print $date; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
35 35
 		    </ul>
36 36
 		</li>
37
-		<li><a href="<?php print $globalURL; ?>/date/statistics/route/<?php print $date; ?>" <?php if (strtolower($current_page) == "date-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
38
-		<li><a href="<?php print $globalURL; ?>/date/statistics/time/<?php print $date; ?>" <?php if (strtolower($current_page) == "date-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
37
+		<li><a href="<?php print $globalURL; ?>/date/statistics/route/<?php print $date; ?>" <?php if (strtolower($current_page) == "date-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
38
+		<li><a href="<?php print $globalURL; ?>/date/statistics/time/<?php print $date; ?>" <?php if (strtolower($current_page) == "date-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
39 39
 	</ul>
40 40
 </div>
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
route-statistics-time.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@
 block discarded – undo
14 14
 $arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING);
15 15
 if (isset($_GET['departure_airport']) && isset($_GET['arrival_airport'])) {
16 16
 	$spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, "0,1", $sort);
17
-} else $spotter_array = array();
17
+} else {
18
+	$spotter_array = array();
19
+}
18 20
   
19 21
 if (!empty($spotter_array))
20 22
 {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once('require/class.Language.php');
10 10
 
11 11
 $Spotter = new Spotter();
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING);
14
-$arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING);
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$departure_airport = filter_input(INPUT_GET, 'departure_airport', FILTER_SANITIZE_STRING);
14
+$arrival_airport = filter_input(INPUT_GET, 'arrival_airport', FILTER_SANITIZE_STRING);
15 15
 if (isset($_GET['departure_airport']) && isset($_GET['arrival_airport'])) {
16 16
 	$spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, "0,1", $sort);
17 17
 } else $spotter_array = array();
18 18
 
19 19
 if (!empty($spotter_array))
20 20
 {
21
-	$title = sprintf(_("Most Common Time of Day between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']);
21
+	$title = sprintf(_("Most Common Time of Day between %s (%s), %s - %s (%s), %s"), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']);
22 22
 	require_once('header.php');
23 23
 	print '<div class="info column">';
24 24
 	print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>';
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	include('route-sub-menu.php');
30 30
 	print '<div class="column">';
31 31
 	print '<h2>'._("Most Common Time of Day").'</h2>';
32
-	print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']).'</p>';
32
+	print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']).'</p>';
33 33
 
34 34
 	$hour_array = $Spotter->countAllHoursByRoute($departure_airport, $arrival_airport);
35 35
 	print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 	$hour_data = '';
40 40
 	$hour_cnt = '';
41 41
 	$last = 0;
42
-	foreach($hour_array as $hour_item)
42
+	foreach ($hour_array as $hour_item)
43 43
 	{
44
-		while($last != $hour_item['hour_name']) {
44
+		while ($last != $hour_item['hour_name']) {
45 45
 			$hour_data .= '"'.$last.':00",';
46 46
 			$hour_cnt .= '0,';
47 47
 			$last++;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$hour_cnt .= $hour_item['hour_count'].',';
52 52
 	}
53 53
 	$hour_data = "['x',".substr($hour_data, 0, -1)."]";
54
-	$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
54
+	$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
55 55
 	print 'c3.generate({
56 56
 	    bindto: "#chartHour",
57 57
 	    data: {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		print '</thead>';
77 77
 		print '<tbody>';
78 78
 		$i = 1;
79
-		foreach($hour_array as $hour_item)
79
+		foreach ($hour_array as $hour_item)
80 80
 		{
81 81
 			print '<tr>';
82 82
 			print '<td>'.$hour_item['hour_name'].':00</td>';
Please login to merge, or discard this patch.
require/class.TrackerLive.php 4 patches
Doc Comments   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -759,10 +759,6 @@  discard block
 block discarded – undo
759 759
 	*
760 760
 	* @param String $famtrackid the ID from flightaware
761 761
 	* @param String $ident the flight ident
762
-	* @param String $aircraft_icao the aircraft type
763
-	* @param String $departure_airport_icao the departure airport
764
-	* @param String $arrival_airport_icao the arrival airport
765
-	* @return String success or false
766 762
 	*
767 763
 	*/
768 764
 	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
Please login to merge, or discard this patch.
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	}
88 88
 
89 89
 	/**
90
-	* Gets all the spotter information based on the latest data entry
91
-	*
92
-	* @return Array the spotter information
93
-	*
94
-	*/
90
+	 * Gets all the spotter information based on the latest data entry
91
+	 *
92
+	 * @return Array the spotter information
93
+	 *
94
+	 */
95 95
 	public function getLiveTrackerData($limit = '', $sort = '', $filter = array())
96 96
 	{
97 97
 		global $globalDBdriver, $globalLiveInterval;
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 
135 135
 	/**
136
-	* Gets Minimal Live Spotter data
137
-	*
138
-	* @return Array the spotter information
139
-	*
140
-	*/
136
+	 * Gets Minimal Live Spotter data
137
+	 *
138
+	 * @return Array the spotter information
139
+	 *
140
+	 */
141 141
 	public function getMinLiveTrackerData($filter = array())
142 142
 	{
143 143
 		global $globalDBdriver, $globalLiveInterval;
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	}
172 172
 
173 173
 	/**
174
-	* Gets Minimal Live Spotter data since xx seconds
175
-	*
176
-	* @return Array the spotter information
177
-	*
178
-	*/
174
+	 * Gets Minimal Live Spotter data since xx seconds
175
+	 *
176
+	 * @return Array the spotter information
177
+	 *
178
+	 */
179 179
 	public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false)
180 180
 	{
181 181
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit;
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 	}
250 250
 
251 251
 	/**
252
-	* Gets number of latest data entry
253
-	*
254
-	* @return String number of entry
255
-	*
256
-	*/
252
+	 * Gets number of latest data entry
253
+	 *
254
+	 * @return String number of entry
255
+	 *
256
+	 */
257 257
 	public function getLiveTrackerCount($filter = array())
258 258
 	{
259 259
 		global $globalDBdriver, $globalLiveInterval;
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 	}
279 279
 
280 280
 	/**
281
-	* Gets all the spotter information based on the latest data entry and coord
282
-	*
283
-	* @return Array the spotter information
284
-	*
285
-	*/
281
+	 * Gets all the spotter information based on the latest data entry and coord
282
+	 *
283
+	 * @return Array the spotter information
284
+	 *
285
+	 */
286 286
 	public function getLiveTrackerDatabyCoord($coord, $filter = array())
287 287
 	{
288 288
 		global $globalDBdriver, $globalLiveInterval;
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 	}
307 307
 
308 308
 	/**
309
-	* Gets all the spotter information based on the latest data entry and coord
310
-	*
311
-	* @return Array the spotter information
312
-	*
313
-	*/
309
+	 * Gets all the spotter information based on the latest data entry and coord
310
+	 *
311
+	 * @return Array the spotter information
312
+	 *
313
+	 */
314 314
 	public function getMinLiveTrackerDatabyCoord($coord, $filter = array())
315 315
 	{
316 316
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -378,11 +378,11 @@  discard block
 block discarded – undo
378 378
 	}
379 379
 
380 380
 	/**
381
-	* Gets all the spotter information based on a user's latitude and longitude
382
-	*
383
-	* @return Array the spotter information
384
-	*
385
-	*/
381
+	 * Gets all the spotter information based on a user's latitude and longitude
382
+	 *
383
+	 * @return Array the spotter information
384
+	 *
385
+	 */
386 386
 	public function getLatestTrackerForLayar($lat, $lng, $radius, $interval)
387 387
 	{
388 388
 		$Tracker = new Tracker($this->db);
@@ -395,142 +395,142 @@  discard block
 block discarded – undo
395 395
 		if ($lng != '')
396 396
 		{
397 397
 			if (!is_numeric($lng))
398
-                        {
399
-                                return false;
400
-                        }
401
-                }
402
-
403
-                if ($radius != '')
404
-                {
405
-                        if (!is_numeric($radius))
406
-                        {
407
-                                return false;
408
-                        }
409
-                }
398
+						{
399
+								return false;
400
+						}
401
+				}
402
+
403
+				if ($radius != '')
404
+				{
405
+						if (!is_numeric($radius))
406
+						{
407
+								return false;
408
+						}
409
+				}
410 410
 		$additional_query = '';
411 411
 		if ($interval != '')
412
-                {
413
-                        if (!is_string($interval))
414
-                        {
415
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
416
-			        return false;
417
-                        } else {
418
-                if ($interval == '1m')
419
-                {
420
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
421
-                } else if ($interval == '15m'){
422
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
423
-                } 
424
-            }
425
-                } else {
426
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
427
-        }
428
-
429
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
412
+				{
413
+						if (!is_string($interval))
414
+						{
415
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
416
+					return false;
417
+						} else {
418
+				if ($interval == '1m')
419
+				{
420
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
421
+				} else if ($interval == '15m'){
422
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
423
+				} 
424
+			}
425
+				} else {
426
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
427
+		}
428
+
429
+				$query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
430 430
                    WHERE tracker_live.latitude <> '' 
431 431
                                    AND tracker_live.longitude <> '' 
432 432
                    ".$additional_query."
433 433
                    HAVING distance < :radius  
434 434
                                    ORDER BY distance";
435 435
 
436
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
436
+				$spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
437 437
 
438
-                return $spotter_array;
439
-        }
438
+				return $spotter_array;
439
+		}
440 440
 
441 441
     
442
-        /**
443
-	* Gets all the spotter information based on a particular callsign
444
-	*
445
-	* @return Array the spotter information
446
-	*
447
-	*/
442
+		/**
443
+		 * Gets all the spotter information based on a particular callsign
444
+		 *
445
+		 * @return Array the spotter information
446
+		 *
447
+		 */
448 448
 	public function getLastLiveTrackerDataByIdent($ident)
449 449
 	{
450 450
 		$Tracker = new Tracker($this->db);
451 451
 		date_default_timezone_set('UTC');
452 452
 
453 453
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
454
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
454
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
455 455
 
456 456
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
457 457
 
458 458
 		return $spotter_array;
459 459
 	}
460 460
 
461
-        /**
462
-	* Gets all the spotter information based on a particular callsign
463
-	*
464
-	* @return Array the spotter information
465
-	*
466
-	*/
461
+		/**
462
+		 * Gets all the spotter information based on a particular callsign
463
+		 *
464
+		 * @return Array the spotter information
465
+		 *
466
+		 */
467 467
 	public function getDateLiveTrackerDataByIdent($ident,$date)
468 468
 	{
469 469
 		$Tracker = new Tracker($this->db);
470 470
 		date_default_timezone_set('UTC');
471 471
 
472 472
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
473
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
473
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
474 474
 
475
-                $date = date('c',$date);
475
+				$date = date('c',$date);
476 476
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
477 477
 
478 478
 		return $spotter_array;
479 479
 	}
480 480
 
481
-        /**
482
-	* Gets last spotter information based on a particular callsign
483
-	*
484
-	* @return Array the spotter information
485
-	*
486
-	*/
481
+		/**
482
+		 * Gets last spotter information based on a particular callsign
483
+		 *
484
+		 * @return Array the spotter information
485
+		 *
486
+		 */
487 487
 	public function getLastLiveTrackerDataById($id)
488 488
 	{
489 489
 		$Tracker = new Tracker($this->db);
490 490
 		date_default_timezone_set('UTC');
491 491
 
492 492
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
493
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
493
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
494 494
 
495 495
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
496 496
 
497 497
 		return $spotter_array;
498 498
 	}
499 499
 
500
-        /**
501
-	* Gets last spotter information based on a particular callsign
502
-	*
503
-	* @return Array the spotter information
504
-	*
505
-	*/
500
+		/**
501
+		 * Gets last spotter information based on a particular callsign
502
+		 *
503
+		 * @return Array the spotter information
504
+		 *
505
+		 */
506 506
 	public function getDateLiveTrackerDataById($id,$date)
507 507
 	{
508 508
 		$Tracker = new Tracker($this->db);
509 509
 		date_default_timezone_set('UTC');
510 510
 
511 511
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
512
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
-                $date = date('c',$date);
512
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
+				$date = date('c',$date);
514 514
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
515 515
 
516 516
 		return $spotter_array;
517 517
 	}
518 518
 
519
-        /**
520
-	* Gets altitude information based on a particular callsign
521
-	*
522
-	* @return Array the spotter information
523
-	*
524
-	*/
519
+		/**
520
+		 * Gets altitude information based on a particular callsign
521
+		 *
522
+		 * @return Array the spotter information
523
+		 *
524
+		 */
525 525
 	public function getAltitudeLiveTrackerDataByIdent($ident)
526 526
 	{
527 527
 
528 528
 		date_default_timezone_set('UTC');
529 529
 
530 530
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
531
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
531
+				$query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
532 532
 
533
-    		try {
533
+			try {
534 534
 			
535 535
 			$sth = $this->db->prepare($query);
536 536
 			$sth->execute(array(':ident' => $ident));
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
 		return $spotter_array;
544 544
 	}
545 545
 
546
-        /**
547
-	* Gets all the spotter information based on a particular id
548
-	*
549
-	* @return Array the spotter information
550
-	*
551
-	*/
546
+		/**
547
+		 * Gets all the spotter information based on a particular id
548
+		 *
549
+		 * @return Array the spotter information
550
+		 *
551
+		 */
552 552
 	public function getAllLiveTrackerDataById($id,$liveinterval = false)
553 553
 	{
554 554
 		global $globalDBdriver, $globalLiveInterval;
@@ -576,18 +576,18 @@  discard block
 block discarded – undo
576 576
 		return $spotter_array;
577 577
 	}
578 578
 
579
-        /**
580
-	* Gets all the spotter information based on a particular ident
581
-	*
582
-	* @return Array the spotter information
583
-	*
584
-	*/
579
+		/**
580
+		 * Gets all the spotter information based on a particular ident
581
+		 *
582
+		 * @return Array the spotter information
583
+		 *
584
+		 */
585 585
 	public function getAllLiveTrackerDataByIdent($ident)
586 586
 	{
587 587
 		date_default_timezone_set('UTC');
588 588
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
589 589
 		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
590
-    		try {
590
+			try {
591 591
 			
592 592
 			$sth = $this->db->prepare($query);
593 593
 			$sth->execute(array(':ident' => $ident));
@@ -601,23 +601,23 @@  discard block
 block discarded – undo
601 601
 
602 602
 
603 603
 	/**
604
-	* Deletes all info in the table
605
-	*
606
-	* @return String success or false
607
-	*
608
-	*/
604
+	 * Deletes all info in the table
605
+	 *
606
+	 * @return String success or false
607
+	 *
608
+	 */
609 609
 	public function deleteLiveTrackerData()
610 610
 	{
611 611
 		global $globalDBdriver;
612 612
 		if ($globalDBdriver == 'mysql') {
613 613
 			//$query  = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date";
614 614
 			$query  = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date';
615
-            		//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
615
+					//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
616 616
 		} else {
617 617
 			$query  = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date";
618 618
 		}
619 619
         
620
-    		try {
620
+			try {
621 621
 			
622 622
 			$sth = $this->db->prepare($query);
623 623
 			$sth->execute();
@@ -629,18 +629,18 @@  discard block
 block discarded – undo
629 629
 	}
630 630
 
631 631
 	/**
632
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
633
-	*
634
-	* @return String success or false
635
-	*
636
-	*/
632
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
633
+	 *
634
+	 * @return String success or false
635
+	 *
636
+	 */
637 637
 	public function deleteLiveTrackerDataNotUpdated()
638 638
 	{
639 639
 		global $globalDBdriver, $globalDebug;
640 640
 		if ($globalDBdriver == 'mysql') {
641 641
 			//$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0';
642
-    			$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
643
-    			try {
642
+				$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
643
+				try {
644 644
 				
645 645
 				$sth = $this->db->prepare($query);
646 646
 				$sth->execute();
@@ -648,8 +648,8 @@  discard block
 block discarded – undo
648 648
 				return "error";
649 649
 			}
650 650
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
651
-                        $i = 0;
652
-                        $j =0;
651
+						$i = 0;
652
+						$j =0;
653 653
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
654 654
 			foreach($all as $row)
655 655
 			{
@@ -657,20 +657,20 @@  discard block
 block discarded – undo
657 657
 				$j++;
658 658
 				if ($j == 30) {
659 659
 					if ($globalDebug) echo ".";
660
-				    	try {
660
+						try {
661 661
 						
662 662
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
663 663
 						$sth->execute();
664 664
 					} catch(PDOException $e) {
665 665
 						return "error";
666 666
 					}
667
-                                	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
668
-                                	$j = 0;
667
+									$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
668
+									$j = 0;
669 669
 				}
670 670
 				$query_delete .= "'".$row['famtrackid']."',";
671 671
 			}
672 672
 			if ($i > 0) {
673
-    				try {
673
+					try {
674 674
 					
675 675
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
676 676
 					$sth->execute();
@@ -681,9 +681,9 @@  discard block
 block discarded – undo
681 681
 			return "success";
682 682
 		} elseif ($globalDBdriver == 'pgsql') {
683 683
 			//$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0";
684
-    			//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
685
-    			$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
686
-    			try {
684
+				//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
685
+				$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
686
+				try {
687 687
 				
688 688
 				$sth = $this->db->prepare($query);
689 689
 				$sth->execute();
@@ -727,17 +727,17 @@  discard block
 block discarded – undo
727 727
 	}
728 728
 
729 729
 	/**
730
-	* Deletes all info in the table for an ident
731
-	*
732
-	* @return String success or false
733
-	*
734
-	*/
730
+	 * Deletes all info in the table for an ident
731
+	 *
732
+	 * @return String success or false
733
+	 *
734
+	 */
735 735
 	public function deleteLiveTrackerDataByIdent($ident)
736 736
 	{
737 737
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
738 738
 		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
739 739
         
740
-    		try {
740
+			try {
741 741
 			
742 742
 			$sth = $this->db->prepare($query);
743 743
 			$sth->execute(array(':ident' => $ident));
@@ -749,17 +749,17 @@  discard block
 block discarded – undo
749 749
 	}
750 750
 
751 751
 	/**
752
-	* Deletes all info in the table for an id
753
-	*
754
-	* @return String success or false
755
-	*
756
-	*/
752
+	 * Deletes all info in the table for an id
753
+	 *
754
+	 * @return String success or false
755
+	 *
756
+	 */
757 757
 	public function deleteLiveTrackerDataById($id)
758 758
 	{
759 759
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
760 760
 		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
761 761
         
762
-    		try {
762
+			try {
763 763
 			
764 764
 			$sth = $this->db->prepare($query);
765 765
 			$sth->execute(array(':id' => $id));
@@ -772,11 +772,11 @@  discard block
 block discarded – undo
772 772
 
773 773
 
774 774
 	/**
775
-	* Gets the aircraft ident within the last hour
776
-	*
777
-	* @return String the ident
778
-	*
779
-	*/
775
+	 * Gets the aircraft ident within the last hour
776
+	 *
777
+	 * @return String the ident
778
+	 *
779
+	 */
780 780
 	public function getIdentFromLastHour($ident)
781 781
 	{
782 782
 		global $globalDBdriver, $globalTimezone;
@@ -802,14 +802,14 @@  discard block
 block discarded – undo
802 802
 			$ident_result = $row['ident'];
803 803
 		}
804 804
 		return $ident_result;
805
-        }
805
+		}
806 806
 
807 807
 	/**
808
-	* Check recent aircraft
809
-	*
810
-	* @return String the ident
811
-	*
812
-	*/
808
+	 * Check recent aircraft
809
+	 *
810
+	 * @return String the ident
811
+	 *
812
+	 */
813 813
 	public function checkIdentRecent($ident)
814 814
 	{
815 815
 		global $globalDBdriver, $globalTimezone;
@@ -835,14 +835,14 @@  discard block
 block discarded – undo
835 835
 			$ident_result = $row['famtrackid'];
836 836
 		}
837 837
 		return $ident_result;
838
-        }
838
+		}
839 839
 
840 840
 	/**
841
-	* Check recent aircraft by id
842
-	*
843
-	* @return String the ident
844
-	*
845
-	*/
841
+	 * Check recent aircraft by id
842
+	 *
843
+	 * @return String the ident
844
+	 *
845
+	 */
846 846
 	public function checkIdRecent($id)
847 847
 	{
848 848
 		global $globalDBdriver, $globalTimezone;
@@ -868,19 +868,19 @@  discard block
 block discarded – undo
868 868
 			$ident_result = $row['famtrackid'];
869 869
 		}
870 870
 		return $ident_result;
871
-        }
871
+		}
872 872
 
873 873
 	/**
874
-	* Adds a new spotter data
875
-	*
876
-	* @param String $famtrackid the ID from flightaware
877
-	* @param String $ident the flight ident
878
-	* @param String $aircraft_icao the aircraft type
879
-	* @param String $departure_airport_icao the departure airport
880
-	* @param String $arrival_airport_icao the arrival airport
881
-	* @return String success or false
882
-	*
883
-	*/
874
+	 * Adds a new spotter data
875
+	 *
876
+	 * @param String $famtrackid the ID from flightaware
877
+	 * @param String $ident the flight ident
878
+	 * @param String $aircraft_icao the aircraft type
879
+	 * @param String $departure_airport_icao the departure airport
880
+	 * @param String $arrival_airport_icao the arrival airport
881
+	 * @return String success or false
882
+	 *
883
+	 */
884 884
 	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
885 885
 	{
886 886
 		global $globalURL, $globalArchive, $globalDebug;
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
954 954
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
955 955
 
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
956
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
958 958
             	
959 959
 		$query = '';
960 960
 		if ($globalArchive) {
@@ -972,15 +972,15 @@  discard block
 block discarded – undo
972 972
 		} catch(PDOException $e) {
973 973
 			return "error : ".$e->getMessage();
974 974
 		}
975
-                /*
975
+				/*
976 976
                 echo 'putinarchive : '.$putinarchive."\n";
977 977
                 echo 'noarchive : '.$noarchive."\n";
978 978
                 */
979 979
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
980
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
981
-		    $TrackerArchive = new TrackerArchive($this->db);
982
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
983
-		    if ($globalDebug) echo $result.')';
980
+			if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
981
+			$TrackerArchive = new TrackerArchive($this->db);
982
+			$result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
983
+			if ($globalDebug) echo $result.')';
984 984
 		}
985 985
 
986 986
 		return "success";
Please login to merge, or discard this patch.
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
39
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
41
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
73 73
 				}
74 74
 			}
75
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
75
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
76 76
 		}
77 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
79 79
 		}
80 80
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81 81
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
82 82
 		if ($filter_query_where != '') {
83
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
84 84
 		}
85 85
 		$filter_query = $filter_query_join.$filter_query_where;
86 86
 		return $filter_query;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 		if ($limit != '')
104 104
 		{
105 105
 			$limit_array = explode(',', $limit);
106
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
107
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
107
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
108 108
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
109 109
 			{
110 110
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		} else {
128 128
 			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
129 129
 		}
130
-		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
130
+		$spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true);
131 131
 
132 132
 		return $spotter_array;
133 133
 	}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		global $globalDBdriver, $globalLiveInterval;
144 144
 		date_default_timezone_set('UTC');
145 145
 
146
-		$filter_query = $this->getFilter($filter,true,true);
146
+		$filter_query = $this->getFilter($filter, true, true);
147 147
 
148 148
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
149 149
 		if ($globalDBdriver == 'mysql') {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute();
164
-		} catch(PDOException $e) {
164
+		} catch (PDOException $e) {
165 165
 			echo $e->getMessage();
166 166
 			die;
167 167
 		}
@@ -176,25 +176,25 @@  discard block
 block discarded – undo
176 176
 	* @return Array the spotter information
177 177
 	*
178 178
 	*/
179
-	public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false)
179
+	public function getMinLastLiveTrackerData($coord, $filter = array(), $limit = false)
180 180
 	{
181 181
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit;
182 182
 		date_default_timezone_set('UTC');
183 183
 		$usecoord = false;
184 184
 		if (is_array($coord) && !empty($coord)) {
185
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
186
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
187
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
188
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
185
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
186
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
187
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
188
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
189 189
 			$usecoord = true;
190 190
 		}
191
-		$filter_query = $this->getFilter($filter,true,true);
191
+		$filter_query = $this->getFilter($filter, true, true);
192 192
 
193 193
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194 194
 		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
195 195
 		if ($globalDBdriver == 'mysql') {
196 196
 			if (isset($globalArchive) && $globalArchive) {
197
-				$query  = "SELECT * FROM (
197
+				$query = "SELECT * FROM (
198 198
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 199
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200 200
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			}
217 217
 		} else {
218 218
 			if (isset($globalArchive) && $globalArchive) {
219
-				$query  = "SELECT * FROM (
219
+				$query = "SELECT * FROM (
220 220
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 221
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222 222
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		try {
241 241
 			$sth = $this->db->prepare($query);
242 242
 			$sth->execute();
243
-		} catch(PDOException $e) {
243
+		} catch (PDOException $e) {
244 244
 			echo $e->getMessage();
245 245
 			die;
246 246
 		}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	public function getLiveTrackerCount($filter = array())
258 258
 	{
259 259
 		global $globalDBdriver, $globalLiveInterval;
260
-		$filter_query = $this->getFilter($filter,true,true);
260
+		$filter_query = $this->getFilter($filter, true, true);
261 261
 
262 262
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
263 263
 		if ($globalDBdriver == 'mysql') {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		try {
269 269
 			$sth = $this->db->prepare($query);
270 270
 			$sth->execute();
271
-		} catch(PDOException $e) {
271
+		} catch (PDOException $e) {
272 272
 			echo $e->getMessage();
273 273
 			die;
274 274
 		}
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 		$filter_query = $this->getFilter($filter);
292 292
 
293 293
 		if (is_array($coord)) {
294
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
295
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
294
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
295
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
296
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
297
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
298 298
 		} else return array();
299 299
 		if ($globalDBdriver == 'mysql') {
300 300
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 317
 		$Tracker = new Tracker($this->db);
318 318
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
319
-		$filter_query = $this->getFilter($filter,true,true);
319
+		$filter_query = $this->getFilter($filter, true, true);
320 320
 
321 321
 		if (is_array($coord)) {
322
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
323
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
322
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
323
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
324
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
325
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
326 326
 		} else return array();
327 327
 		/*
328 328
 		if ($globalDBdriver == 'mysql') {
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 		*/
337 337
 		if ($globalDBdriver == 'mysql') {
338 338
 			if (isset($globalArchive) && $globalArchive === TRUE) {
339
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
339
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
340 340
 				    FROM tracker_live 
341 341
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= tracker_live.date 
342 342
 				    AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
343 343
 				    AND tracker_live.latitude <> 0 AND tracker_live.longitude <> 0';
344 344
 			} else {
345
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
345
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
346 346
 				    FROM tracker_live 
347 347
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
348 348
 					FROM tracker_live l 
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
 			}
355 355
 		} else {
356 356
 			if (isset($globalArchive) && $globalArchive === TRUE) {
357
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
357
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
358 358
 				    FROM tracker_live 
359 359
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date 
360 360
 				    AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
361 361
 				    AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
362 362
 				    AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'";
363 363
 			} else {
364
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
364
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
365 365
 				    FROM tracker_live 
366 366
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
367 367
 					FROM tracker_live l 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                 if ($interval == '1m')
419 419
                 {
420 420
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
421
-                } else if ($interval == '15m'){
421
+                } else if ($interval == '15m') {
422 422
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
423 423
                 } 
424 424
             }
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
427 427
         }
428 428
 
429
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
429
+                $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
430 430
                    WHERE tracker_live.latitude <> '' 
431 431
                                    AND tracker_live.longitude <> '' 
432 432
                    ".$additional_query."
433 433
                    HAVING distance < :radius  
434 434
                                    ORDER BY distance";
435 435
 
436
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
436
+                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
437 437
 
438 438
                 return $spotter_array;
439 439
         }
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
 		date_default_timezone_set('UTC');
452 452
 
453 453
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
454
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
454
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
455 455
 
456
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
456
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true);
457 457
 
458 458
 		return $spotter_array;
459 459
 	}
@@ -464,16 +464,16 @@  discard block
 block discarded – undo
464 464
 	* @return Array the spotter information
465 465
 	*
466 466
 	*/
467
-	public function getDateLiveTrackerDataByIdent($ident,$date)
467
+	public function getDateLiveTrackerDataByIdent($ident, $date)
468 468
 	{
469 469
 		$Tracker = new Tracker($this->db);
470 470
 		date_default_timezone_set('UTC');
471 471
 
472 472
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
473
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
473
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
474 474
 
475
-                $date = date('c',$date);
476
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
475
+                $date = date('c', $date);
476
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
477 477
 
478 478
 		return $spotter_array;
479 479
 	}
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
 		date_default_timezone_set('UTC');
491 491
 
492 492
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
493
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
493
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
494 494
 
495
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
495
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true);
496 496
 
497 497
 		return $spotter_array;
498 498
 	}
@@ -503,15 +503,15 @@  discard block
 block discarded – undo
503 503
 	* @return Array the spotter information
504 504
 	*
505 505
 	*/
506
-	public function getDateLiveTrackerDataById($id,$date)
506
+	public function getDateLiveTrackerDataById($id, $date)
507 507
 	{
508 508
 		$Tracker = new Tracker($this->db);
509 509
 		date_default_timezone_set('UTC');
510 510
 
511 511
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
512
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
-                $date = date('c',$date);
514
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
512
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
+                $date = date('c', $date);
514
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
515 515
 
516 516
 		return $spotter_array;
517 517
 	}
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
 		date_default_timezone_set('UTC');
529 529
 
530 530
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
531
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
531
+                $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
532 532
 
533 533
     		try {
534 534
 			
535 535
 			$sth = $this->db->prepare($query);
536 536
 			$sth->execute(array(':ident' => $ident));
537
-		} catch(PDOException $e) {
537
+		} catch (PDOException $e) {
538 538
 			echo $e->getMessage();
539 539
 			die;
540 540
 		}
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	* @return Array the spotter information
550 550
 	*
551 551
 	*/
552
-	public function getAllLiveTrackerDataById($id,$liveinterval = false)
552
+	public function getAllLiveTrackerDataById($id, $liveinterval = false)
553 553
 	{
554 554
 		global $globalDBdriver, $globalLiveInterval;
555 555
 		date_default_timezone_set('UTC');
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 		try {
569 569
 			$sth = $this->db->prepare($query);
570 570
 			$sth->execute(array(':id' => $id));
571
-		} catch(PDOException $e) {
571
+		} catch (PDOException $e) {
572 572
 			echo $e->getMessage();
573 573
 			die;
574 574
 		}
@@ -586,12 +586,12 @@  discard block
 block discarded – undo
586 586
 	{
587 587
 		date_default_timezone_set('UTC');
588 588
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
589
-		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
589
+		$query = self::$global_query.' WHERE tracker_live.ident = :ident';
590 590
     		try {
591 591
 			
592 592
 			$sth = $this->db->prepare($query);
593 593
 			$sth->execute(array(':ident' => $ident));
594
-		} catch(PDOException $e) {
594
+		} catch (PDOException $e) {
595 595
 			echo $e->getMessage();
596 596
 			die;
597 597
 		}
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 			
622 622
 			$sth = $this->db->prepare($query);
623 623
 			$sth->execute();
624
-		} catch(PDOException $e) {
624
+		} catch (PDOException $e) {
625 625
 			return "error";
626 626
 		}
627 627
 
@@ -644,14 +644,14 @@  discard block
 block discarded – undo
644 644
 				
645 645
 				$sth = $this->db->prepare($query);
646 646
 				$sth->execute();
647
-			} catch(PDOException $e) {
647
+			} catch (PDOException $e) {
648 648
 				return "error";
649 649
 			}
650 650
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
651 651
                         $i = 0;
652
-                        $j =0;
652
+                        $j = 0;
653 653
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
654
-			foreach($all as $row)
654
+			foreach ($all as $row)
655 655
 			{
656 656
 				$i++;
657 657
 				$j++;
@@ -659,9 +659,9 @@  discard block
 block discarded – undo
659 659
 					if ($globalDebug) echo ".";
660 660
 				    	try {
661 661
 						
662
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
662
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
663 663
 						$sth->execute();
664
-					} catch(PDOException $e) {
664
+					} catch (PDOException $e) {
665 665
 						return "error";
666 666
 					}
667 667
                                 	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
 			if ($i > 0) {
673 673
     				try {
674 674
 					
675
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
675
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
676 676
 					$sth->execute();
677
-				} catch(PDOException $e) {
677
+				} catch (PDOException $e) {
678 678
 					return "error";
679 679
 				}
680 680
 			}
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 				
688 688
 				$sth = $this->db->prepare($query);
689 689
 				$sth->execute();
690
-			} catch(PDOException $e) {
690
+			} catch (PDOException $e) {
691 691
 				return "error";
692 692
 			}
693 693
 /*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
@@ -735,13 +735,13 @@  discard block
 block discarded – undo
735 735
 	public function deleteLiveTrackerDataByIdent($ident)
736 736
 	{
737 737
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
738
-		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
738
+		$query = 'DELETE FROM tracker_live WHERE ident = :ident';
739 739
         
740 740
     		try {
741 741
 			
742 742
 			$sth = $this->db->prepare($query);
743 743
 			$sth->execute(array(':ident' => $ident));
744
-		} catch(PDOException $e) {
744
+		} catch (PDOException $e) {
745 745
 			return "error";
746 746
 		}
747 747
 
@@ -757,13 +757,13 @@  discard block
 block discarded – undo
757 757
 	public function deleteLiveTrackerDataById($id)
758 758
 	{
759 759
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
760
-		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
760
+		$query = 'DELETE FROM tracker_live WHERE famtrackid = :id';
761 761
         
762 762
     		try {
763 763
 			
764 764
 			$sth = $this->db->prepare($query);
765 765
 			$sth->execute(array(':id' => $id));
766
-		} catch(PDOException $e) {
766
+		} catch (PDOException $e) {
767 767
 			return "error";
768 768
 		}
769 769
 
@@ -781,13 +781,13 @@  discard block
 block discarded – undo
781 781
 	{
782 782
 		global $globalDBdriver, $globalTimezone;
783 783
 		if ($globalDBdriver == 'mysql') {
784
-			$query  = 'SELECT tracker_live.ident FROM tracker_live 
784
+			$query = 'SELECT tracker_live.ident FROM tracker_live 
785 785
 				WHERE tracker_live.ident = :ident 
786 786
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
787 787
 				AND tracker_live.date < UTC_TIMESTAMP()';
788 788
 			$query_data = array(':ident' => $ident);
789 789
 		} else {
790
-			$query  = "SELECT tracker_live.ident FROM tracker_live 
790
+			$query = "SELECT tracker_live.ident FROM tracker_live 
791 791
 				WHERE tracker_live.ident = :ident 
792 792
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
793 793
 				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -796,8 +796,8 @@  discard block
 block discarded – undo
796 796
 		
797 797
 		$sth = $this->db->prepare($query);
798 798
 		$sth->execute($query_data);
799
-		$ident_result='';
800
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
799
+		$ident_result = '';
800
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
801 801
 		{
802 802
 			$ident_result = $row['ident'];
803 803
 		}
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	{
815 815
 		global $globalDBdriver, $globalTimezone;
816 816
 		if ($globalDBdriver == 'mysql') {
817
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
817
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
818 818
 				WHERE tracker_live.ident = :ident 
819 819
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
820 820
 //				AND tracker_live.date < UTC_TIMESTAMP()";
821 821
 			$query_data = array(':ident' => $ident);
822 822
 		} else {
823
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
823
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
824 824
 				WHERE tracker_live.ident = :ident 
825 825
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
826 826
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
 		
830 830
 		$sth = $this->db->prepare($query);
831 831
 		$sth->execute($query_data);
832
-		$ident_result='';
833
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
832
+		$ident_result = '';
833
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
834 834
 		{
835 835
 			$ident_result = $row['famtrackid'];
836 836
 		}
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
 	{
848 848
 		global $globalDBdriver, $globalTimezone;
849 849
 		if ($globalDBdriver == 'mysql') {
850
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
850
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
851 851
 				WHERE tracker_live.famtrackid = :id 
852 852
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
853 853
 //				AND tracker_live.date < UTC_TIMESTAMP()";
854 854
 			$query_data = array(':id' => $id);
855 855
 		} else {
856
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
856
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
857 857
 				WHERE tracker_live.famtrackid = :id 
858 858
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
859 859
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 		
863 863
 		$sth = $this->db->prepare($query);
864 864
 		$sth->execute($query_data);
865
-		$ident_result='';
866
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
865
+		$ident_result = '';
866
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
867 867
 		{
868 868
 			$ident_result = $row['famtrackid'];
869 869
 		}
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	* @return String success or false
882 882
 	*
883 883
 	*/
884
-	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
884
+	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
885 885
 	{
886 886
 		global $globalURL, $globalArchive, $globalDebug;
887 887
 		$Common = new Common();
@@ -940,21 +940,21 @@  discard block
 block discarded – undo
940 940
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
941 941
 
942 942
         
943
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
944
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
945
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
946
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
947
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
948
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
949
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
950
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
951
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
952
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
953
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
954
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
955
-
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
943
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
944
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
945
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
946
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
947
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
948
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
949
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
950
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
951
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
952
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
953
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
954
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
955
+
956
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
957
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
958 958
             	
959 959
 		$query = '';
960 960
 		if ($globalArchive) {
@@ -964,12 +964,12 @@  discard block
 block discarded – undo
964 964
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
965 965
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
966 966
 
967
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
967
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
968 968
 		try {
969 969
 			$sth = $this->db->prepare($query);
970 970
 			$sth->execute($query_values);
971 971
 			$sth->closeCursor();
972
-		} catch(PDOException $e) {
972
+		} catch (PDOException $e) {
973 973
 			return "error : ".$e->getMessage();
974 974
 		}
975 975
                 /*
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
980 980
 		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
981 981
 		    $TrackerArchive = new TrackerArchive($this->db);
982
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
982
+		    $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country);
983 983
 		    if ($globalDebug) echo $result.')';
984 984
 		}
985 985
 
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 
990 990
 	public function getOrderBy()
991 991
 	{
992
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
992
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
993 993
 		return $orderby;
994 994
 	}
995 995
 
Please login to merge, or discard this patch.
Braces   +110 added lines, -37 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (TrackerLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (TrackerLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -120,7 +127,9 @@  discard block
 block discarded – undo
120 127
 			}
121 128
 		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
126 135
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
151 162
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -190,50 +201,74 @@  discard block
 block discarded – undo
190 201
 		}
191 202
 		$filter_query = $this->getFilter($filter,true,true);
192 203
 
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
-		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
207
+		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') {
208
+			$globalMap3DTrackersLimit = '300';
209
+		}
195 210
 		if ($globalDBdriver == 'mysql') {
196 211
 			if (isset($globalArchive) && $globalArchive) {
197 212
 				$query  = "SELECT * FROM (
198 213
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 214
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
215
+				if ($usecoord) {
216
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
217
+				}
201 218
 				$query .= "UNION
202 219
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
203 220
 					FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
204
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
221
+				if ($usecoord) {
222
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
223
+				}
205 224
 				$query .= ") AS tracker
206 225
 				    WHERE latitude <> '0' AND longitude <> '0' 
207 226
 				    ORDER BY famtrackid, date";
208
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
227
+				if ($limit) {
228
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
229
+				}
209 230
 			} else {
210 231
 				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
211 232
 				    FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
212
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
233
+				if ($usecoord) {
234
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
235
+				}
213 236
 				$query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
214 237
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
215
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
238
+				if ($limit) {
239
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
240
+				}
216 241
 			}
217 242
 		} else {
218 243
 			if (isset($globalArchive) && $globalArchive) {
219 244
 				$query  = "SELECT * FROM (
220 245
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 246
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
247
+				if ($usecoord) {
248
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
223 250
 				$query .= "UNION
224 251
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
225 252
 					FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date";
226
-				if ($usecoord) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
253
+				if ($usecoord) {
254
+					$query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
255
+				}
227 256
 				$query .= ") AS tracker
228 257
 				    WHERE latitude <> '0' AND longitude <> '0' 
229 258
 				    ORDER BY famtrackid, date";
230
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
259
+				if ($limit) {
260
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
261
+				}
231 262
 			} else {
232 263
 				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
233 264
 				    FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ";
234
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
265
+				if ($usecoord) {
266
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
267
+				}
235 268
 				$query .= "ORDER BY tracker_live.famtrackid, tracker_live.date";
236
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
269
+				if ($limit) {
270
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
271
+				}
237 272
 			}
238 273
 		}
239 274
 
@@ -259,7 +294,9 @@  discard block
 block discarded – undo
259 294
 		global $globalDBdriver, $globalLiveInterval;
260 295
 		$filter_query = $this->getFilter($filter,true,true);
261 296
 
262
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
297
+		if (!isset($globalLiveInterval)) {
298
+			$globalLiveInterval = '200';
299
+		}
263 300
 		if ($globalDBdriver == 'mysql') {
264 301
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
265 302
 		} else {
@@ -287,7 +324,9 @@  discard block
 block discarded – undo
287 324
 	{
288 325
 		global $globalDBdriver, $globalLiveInterval;
289 326
 		$Tracker = new Tracker($this->db);
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
327
+		if (!isset($globalLiveInterval)) {
328
+			$globalLiveInterval = '200';
329
+		}
291 330
 		$filter_query = $this->getFilter($filter);
292 331
 
293 332
 		if (is_array($coord)) {
@@ -295,7 +334,9 @@  discard block
 block discarded – undo
295 334
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296 335
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297 336
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
298
-		} else return array();
337
+		} else {
338
+			return array();
339
+		}
299 340
 		if ($globalDBdriver == 'mysql') {
300 341
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
301 342
 		} else {
@@ -315,7 +356,9 @@  discard block
 block discarded – undo
315 356
 	{
316 357
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 358
 		$Tracker = new Tracker($this->db);
318
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
+		if (!isset($globalLiveInterval)) {
360
+			$globalLiveInterval = '200';
361
+		}
319 362
 		$filter_query = $this->getFilter($filter,true,true);
320 363
 
321 364
 		if (is_array($coord)) {
@@ -323,7 +366,9 @@  discard block
 block discarded – undo
323 366
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324 367
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325 368
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-		} else return array();
369
+		} else {
370
+			return array();
371
+		}
327 372
 		/*
328 373
 		if ($globalDBdriver == 'mysql') {
329 374
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
@@ -557,11 +602,15 @@  discard block
 block discarded – undo
557 602
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
558 603
 		if ($globalDBdriver == 'mysql') {
559 604
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
560
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
605
+			if ($liveinterval) {
606
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
607
+			}
561 608
 			$query .= ' ORDER BY date';
562 609
 		} else {
563 610
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
564
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
611
+			if ($liveinterval) {
612
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
613
+			}
565 614
 			$query .= ' ORDER BY date';
566 615
 		}
567 616
 
@@ -656,7 +705,9 @@  discard block
 block discarded – undo
656 705
 				$i++;
657 706
 				$j++;
658 707
 				if ($j == 30) {
659
-					if ($globalDebug) echo ".";
708
+					if ($globalDebug) {
709
+						echo ".";
710
+					}
660 711
 				    	try {
661 712
 						
662 713
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -903,7 +954,9 @@  discard block
 block discarded – undo
903 954
 			{
904 955
 				return false;
905 956
 			}
906
-		} else return '';
957
+		} else {
958
+			return '';
959
+		}
907 960
 
908 961
 		if ($longitude != '')
909 962
 		{
@@ -911,7 +964,9 @@  discard block
 block discarded – undo
911 964
 			{
912 965
 				return false;
913 966
 			}
914
-		} else return '';
967
+		} else {
968
+			return '';
969
+		}
915 970
 
916 971
 		if ($altitude != '')
917 972
 		{
@@ -919,7 +974,9 @@  discard block
 block discarded – undo
919 974
 			{
920 975
 				return false;
921 976
 			}
922
-		} else $altitude = 0;
977
+		} else {
978
+			$altitude = 0;
979
+		}
923 980
 
924 981
 		if ($heading != '')
925 982
 		{
@@ -927,7 +984,9 @@  discard block
 block discarded – undo
927 984
 			{
928 985
 				return false;
929 986
 			}
930
-		} else $heading = 0;
987
+		} else {
988
+			$heading = 0;
989
+		}
931 990
 
932 991
 		if ($groundspeed != '')
933 992
 		{
@@ -935,9 +994,13 @@  discard block
 block discarded – undo
935 994
 			{
936 995
 				return false;
937 996
 			}
938
-		} else $groundspeed = 0;
997
+		} else {
998
+			$groundspeed = 0;
999
+		}
939 1000
 		date_default_timezone_set('UTC');
940
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1001
+		if ($date == '') {
1002
+			$date = date("Y-m-d H:i:s", time());
1003
+		}
941 1004
 
942 1005
         
943 1006
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -953,12 +1016,18 @@  discard block
 block discarded – undo
953 1016
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
954 1017
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
955 1018
 
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1019
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1020
+            		$groundspeed = 0;
1021
+            	}
1022
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1023
+            		$heading = 0;
1024
+            	}
958 1025
             	
959 1026
 		$query = '';
960 1027
 		if ($globalArchive) {
961
-			if ($globalDebug) echo '-- Delete previous data -- ';
1028
+			if ($globalDebug) {
1029
+				echo '-- Delete previous data -- ';
1030
+			}
962 1031
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
963 1032
 		}
964 1033
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -977,10 +1046,14 @@  discard block
 block discarded – undo
977 1046
                 echo 'noarchive : '.$noarchive."\n";
978 1047
                 */
979 1048
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
980
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
1049
+		    if ($globalDebug) {
1050
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
1051
+		    }
981 1052
 		    $TrackerArchive = new TrackerArchive($this->db);
982 1053
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
983
-		    if ($globalDebug) echo $result.')';
1054
+		    if ($globalDebug) {
1055
+		    	echo $result.')';
1056
+		    }
984 1057
 		}
985 1058
 
986 1059
 		return "success";
Please login to merge, or discard this patch.
js/map-aircraft.2d.js.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 if (!isset($globalJsonCompress)) $compress = true;
7 7
 else $compress = $globalJsonCompress;
8 8
 
9
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
10
-if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
9
+if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
10
+if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
11 11
 ?>
12 12
 
13 13
 
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 	};
177 177
 	archive.update = function (props) {
178 178
 		if (typeof props != 'undefined') {
179
-			//this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
180
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
179
+			//this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
180
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
181 181
 		} else {
182
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
182
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
183 183
 		}
184 184
 
185 185
 	};
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 <?php
341 341
 		} else {
342 342
 ?>
343
-					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
343
+					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
344 344
 					return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
345 345
 <?php
346 346
 		}
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 							/*
357 357
 							shadowUrl: iconURLShadowpath,
358 358
 							shadowSize: [<?php print $globalAircraftSize; ?>, <?php print $globalAircraftSize; ?>],
359
-							shadowAnchor: [<?php print ($globalAircraftSize/2)+1; ?>, <?php print $globalAircraftSize; ?>]
359
+							shadowAnchor: [<?php print ($globalAircraftSize/2) + 1; ?>, <?php print $globalAircraftSize; ?>]
360 360
 							*/
361 361
 						})
362 362
 					})
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 <?php
383 383
 		} else {
384 384
 ?>
385
-						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
385
+						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
386 386
 						return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
387 387
 <?php
388 388
 		}
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 <?php
423 423
 		} else {
424 424
 ?>
425
-							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
425
+							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
426 426
 							return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
427 427
 <?php
428 428
 		}
Please login to merge, or discard this patch.
Braces   +66 added lines, -17 removed lines patch added patch discarded remove patch
@@ -3,11 +3,18 @@  discard block
 block discarded – undo
3 3
 require_once('../require/class.Language.php'); 
4 4
 
5 5
 // Compressed GeoJson is used if true
6
-if (!isset($globalJsonCompress)) $compress = true;
7
-else $compress = $globalJsonCompress;
6
+if (!isset($globalJsonCompress)) {
7
+	$compress = true;
8
+} else {
9
+	$compress = $globalJsonCompress;
10
+}
8 11
 
9
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
10
-if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
12
+if (isset($_GET['ident'])) {
13
+	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
14
+}
15
+if (isset($_GET['flightaware_id'])) {
16
+	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
17
+}
11 18
 ?>
12 19
 
13 20
 
@@ -72,9 +79,12 @@  discard block
 block discarded – undo
72 79
 
73 80
 function update_airportsLayer() {
74 81
 <?php
75
-	if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom'];
76
-	else $getZoom = '7';
77
-?>
82
+	if (isset($_COOKIE['AirportZoom'])) {
83
+		$getZoom = $_COOKIE['AirportZoom'];
84
+	} else {
85
+		$getZoom = '7';
86
+	}
87
+	?>
78 88
 	if (typeof airportsLayer != 'undefined') {
79 89
 		if (map.hasLayer(airportsLayer) == true) {
80 90
 			map.removeLayer(airportsLayer);
@@ -320,9 +330,13 @@  discard block
 block discarded – undo
320 330
 					if (callsign != ""){ markerLabel += callsign; }
321 331
 					if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; }
322 332
 <?php
323
-	if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor'];
324
-	elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor;
325
-	else $IconColor = '1a3151';
333
+	if (isset($_COOKIE['IconColor'])) {
334
+		$IconColor = $_COOKIE['IconColor'];
335
+	} elseif (isset($globalAircraftIconColor)) {
336
+		$IconColor = $globalAircraftIconColor;
337
+	} else {
338
+		$IconColor = '1a3151';
339
+	}
326 340
 	if (!isset($ident) && !isset($flightaware_id)) {
327 341
 ?>
328 342
 					//info_update(feature.properties.fc);
@@ -370,7 +384,12 @@  discard block
 block discarded – undo
370 384
 <?php
371 385
 		} else {
372 386
 ?>
373
-					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
387
+					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
388
+	print $archiveupdatetime*1000;
389
+} else {
390
+	print $globalMapRefresh*1000+20000;
391
+}
392
+?>+feature.properties.sqt*1000);
374 393
 					return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
375 394
 <?php
376 395
 		}
@@ -419,7 +438,12 @@  discard block
 block discarded – undo
419 438
 <?php
420 439
 		} else {
421 440
 ?>
422
-						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
441
+						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
442
+	print $archiveupdatetime*1000;
443
+} else {
444
+	print $globalMapRefresh*1000+20000;
445
+}
446
+?>+feature.properties.sqt*1000);
423 447
 						return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
424 448
 <?php
425 449
 		}
@@ -466,7 +490,12 @@  discard block
 block discarded – undo
466 490
 <?php
467 491
 		} else {
468 492
 ?>
469
-							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
493
+							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
494
+	print $archiveupdatetime*1000;
495
+} else {
496
+	print $globalMapRefresh*1000+20000;
497
+}
498
+?>+feature.properties.sqt*1000);
470 499
 							return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
471 500
 <?php
472 501
 		}
@@ -820,13 +849,23 @@  discard block
 block discarded – undo
820 849
 	if (isset($archive) && $archive) {
821 850
 ?>
822 851
 	//then load it again every 30 seconds
823
-	//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
852
+	//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
853
+	print ($globalMapRefresh*1000)/2;
854
+} else {
855
+	print '15000';
856
+}
857
+?>);
824 858
 	reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>);
825 859
 <?php
826 860
 	} else {
827 861
 ?>
828 862
 	//then load it again every 30 seconds
829
-	reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
863
+	reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
864
+	print $globalMapRefresh*1000;
865
+} else {
866
+	print '30000';
867
+}
868
+?>);
830 869
 	var currentdate = new Date();
831 870
 	var currentyear = new Date().getFullYear();
832 871
 	var begindate = new Date(Date.UTC(currentyear,11,24,2,0,0,0));
@@ -838,7 +877,12 @@  discard block
 block discarded – undo
838 877
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
839 878
 ?>
840 879
 	update_polarLayer();
841
-	setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
880
+	setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) {
881
+	print $globalMapRefresh*1000*2;
882
+} else {
883
+	print '60000';
884
+}
885
+?>);
842 886
 <?php
843 887
 		}
844 888
 ?>
@@ -853,7 +897,12 @@  discard block
 block discarded – undo
853 897
 	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
854 898
 ?>
855 899
 	update_atcLayer();
856
-	setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
900
+	setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) {
901
+	print $globalMapRefresh*1000*2;
902
+} else {
903
+	print '60000';
904
+}
905
+?>);
857 906
 <?php
858 907
 	}
859 908
 ?>
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -662,9 +662,9 @@
 block discarded – undo
662 662
 //	var timeline = new Cesium.Timeline(viewer);
663 663
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
664 664
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
665
-	//this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
666
-	$(".archivebox").html('<h4><?php echo str_replace("'","\'",_("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
667
-	//		this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
665
+	//this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
666
+	$(".archivebox").html('<h4><?php echo str_replace("'", "\'", _("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
667
+	//		this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
668 668
 
669 669
 }
670 670
 
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -209,21 +209,21 @@  discard block
 block discarded – undo
209 209
 			var entityid = entity.id;
210 210
 			var lastupdateentity = entity.properties.valueOf('lastupdate')._lastupdate._value;
211 211
 			<?php 
212
-			    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
212
+				if (isset($globalMapUseBbox) && $globalMapUseBbox) {
213 213
 			?>
214 214
 			if (lastupdateentity != lastupdate) {
215 215
 				viewer.dataSources.get(dsn).entities.remove(entity);
216 216
 				czmlds.entities.removeById(entityid);
217 217
 			}
218 218
 			<?php
219
-			    } else {
219
+				} else {
220 220
 			?>
221 221
 			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
222 222
 				viewer.dataSources.get(dsn).entities.remove(entity);
223 223
 				czmlds.entities.removeById(entityid);
224 224
 			}
225 225
 			<?php
226
-			    }
226
+				}
227 227
 			?>
228 228
 		}
229 229
 	}
@@ -629,12 +629,12 @@  discard block
 block discarded – undo
629 629
 	update_airportsLayer();
630 630
 }
631 631
 <?php
632
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
632
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
633 633
 ?>
634 634
 update_atcLayer();
635 635
 setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
636 636
 <?php
637
-    }
637
+	}
638 638
 ?>
639 639
 
640 640
 function iconColor(color) {
Please login to merge, or discard this patch.
Braces   +24 added lines, -4 removed lines patch added patch discarded remove patch
@@ -218,7 +218,12 @@  discard block
 block discarded – undo
218 218
 			<?php
219 219
 			    } else {
220 220
 			?>
221
-			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
221
+			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
222
+	print $globalMapRefresh*2000;
223
+} else {
224
+	print '60000';
225
+}
226
+?>)) {
222 227
 				viewer.dataSources.get(dsn).entities.remove(entity);
223 228
 				czmlds.entities.removeById(entityid);
224 229
 			}
@@ -502,7 +507,12 @@  discard block
 block discarded – undo
502 507
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
503 508
 ?>
504 509
 update_polarLayer();
505
-setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
510
+setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) {
511
+	print $globalMapRefresh*1000*2;
512
+} else {
513
+	print '60000';
514
+}
515
+?>);
506 516
 <?php
507 517
 		}
508 518
 ?>
@@ -613,7 +623,12 @@  discard block
 block discarded – undo
613 623
 				}
614 624
 			}
615 625
 		}
616
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
626
+	,<?php if (isset($globalMapRefresh)) {
627
+	print $globalMapRefresh*1000;
628
+} else {
629
+	print '30000';
630
+}
631
+?>);
617 632
 } else {
618 633
 	//var widget = new Cesium.CesiumWidget('archivebox');
619 634
 //	var timeline = new Cesium.Timeline(viewer);
@@ -632,7 +647,12 @@  discard block
 block discarded – undo
632 647
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
633 648
 ?>
634 649
 update_atcLayer();
635
-setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
650
+setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) {
651
+	print $globalMapRefresh*1000*2;
652
+} else {
653
+	print '60000';
654
+}
655
+?>);
636 656
 <?php
637 657
     }
638 658
 ?>
Please login to merge, or discard this patch.
marine-data.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
 
10 10
 $from_archive = false;
11 11
 if (isset($_GET['ident'])) {
12
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
13 13
 	if (isset($_GET['currenttime'])) {
14
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
14
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
15 15
 		$currenttime = round($currenttime/1000);
16
-		$spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident,$currenttime);
16
+		$spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident, $currenttime);
17 17
 		
18 18
 		if (empty($spotter_array)) {
19 19
 			$from_archive = true;
20
-			$spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident,$currenttime);
20
+			$spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident, $currenttime);
21 21
 		}
22 22
 		
23 23
 	} else {
@@ -31,16 +31,16 @@  discard block
 block discarded – undo
31 31
 	}
32 32
 }
33 33
 if (isset($_GET['fammarine_id'])) {
34
-	$fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING);
34
+	$fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING);
35 35
 	if (isset($_GET['currenttime'])) {
36
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
36
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
37 37
 		$currenttime = round($currenttime/1000);
38
-		$spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id,$currenttime);
38
+		$spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id, $currenttime);
39 39
 		
40 40
 		if (empty($spotter_array)) {
41 41
 			$from_archive = true;
42 42
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
43
-			$spotter_array = $MarineArchive->getDateArchiveMarineDataById($flightaware_id,$currenttime);
43
+			$spotter_array = $MarineArchive->getDateArchiveMarineDataById($flightaware_id, $currenttime);
44 44
 		}
45 45
 		
46 46
 	} else {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
65
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
66 66
 	} else $image = $spotter_item['image_thumbnail'];
67 67
 
68 68
 }
Please login to merge, or discard this patch.
tracker-data.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 print '<div class="details">';
79 79
 print '<div><span>'._("Altitude").'</span>';
80 80
 if (isset($globalGroundAltitude) && $globalGroundAltitude) {
81
-    try {
81
+	try {
82 82
 	$groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
83
-    } catch(Exception $e) {
84
-    }
83
+	} catch(Exception $e) {
84
+	}
85 85
 }
86 86
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
87 87
 	print $spotter_item['altitude'].' feet (FL'.$spotter_item['altitude'].')';
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 	print round($spotter_item['altitude']*0.3048).' m (FL'.round($spotter_item['altitude']/100).')';
90 90
 }
91 91
 if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*0.3048) {
92
-    print '<br>';
93
-    print '<span>'._("Ground Altitude").'</span>';
94
-    if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
92
+	print '<br>';
93
+	print '<span>'._("Ground Altitude").'</span>';
94
+	if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
95 95
 	print round($groundAltitude*3.28084).' feet';
96
-    } else {
96
+	} else {
97 97
 	print round($groundAltitude).' m';
98
-    }
99
-    print '</i>';
98
+	}
99
+	print '</i>';
100 100
 }
101 101
 print '</div>';
102 102
 print '<div><span>'._("Speed").'</span>';
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 $from_archive = false;
13 13
 if (isset($_GET['ident'])) {
14
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
14
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
15 15
 	if (isset($_GET['currenttime'])) {
16
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
16
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
17 17
 		$currenttime = round($currenttime/1000);
18
-		$spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident,$currenttime);
18
+		$spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident, $currenttime);
19 19
 		if (empty($spotter_array)) {
20 20
 			$from_archive = true;
21
-			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident,$currenttime);
21
+			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident, $currenttime);
22 22
 		}
23 23
 		
24 24
 	} else {
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 	}
31 31
 }
32 32
 if (isset($_GET['famtrackid'])) {
33
-	$famtrackid = urldecode(filter_input(INPUT_GET,'famtrackid',FILTER_SANITIZE_STRING));
33
+	$famtrackid = urldecode(filter_input(INPUT_GET, 'famtrackid', FILTER_SANITIZE_STRING));
34 34
 	if (isset($_GET['currenttime'])) {
35
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
35
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
36 36
 		$currenttime = round($currenttime/1000);
37
-		$spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid,$currenttime);
37
+		$spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid, $currenttime);
38 38
 		
39 39
 		if (empty($spotter_array)) {
40 40
 			$from_archive = true;
41 41
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
42
-			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($famtrackid,$currenttime);
42
+			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($famtrackid, $currenttime);
43 43
 		}
44 44
 		
45 45
 	} else {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
60 60
 {
61 61
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
62
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
62
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
63 63
 	} else $image = $spotter_item['image_thumbnail'];
64 64
 
65 65
 }
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 print '<div><span>'._("Altitude").'</span>';
80 80
 if (isset($globalGroundAltitude) && $globalGroundAltitude) {
81 81
     try {
82
-	$groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
83
-    } catch(Exception $e) {
82
+	$groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']);
83
+    } catch (Exception $e) {
84 84
     }
85 85
 }
86 86
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
Please login to merge, or discard this patch.
require/class.AIS.php 4 patches
Doc Comments   +25 added lines patch added patch discarded remove patch
@@ -68,6 +68,10 @@  discard block
 block discarded – undo
68 68
        't', 'u', 'v', 'w' // 119
69 69
     ); // char 64
70 70
     */
71
+
72
+	/**
73
+	 * @param integer $ascii
74
+	 */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73 77
 		if ($ascii < 48) { }
@@ -93,6 +97,10 @@  discard block
 block discarded – undo
93 97
 		return(substr($bin, -6)); 
94 98
 	}
95 99
 
100
+	/**
101
+	 * @param integer $_start
102
+	 * @param integer $_size
103
+	 */
96 104
 	private function binchar($_str, $_start, $_size) {
97 105
 		//  ' ' --- '?', // 0x20 - 0x3F
98 106
 		//  '@' --- '_', // 0x40 - 0x5F
@@ -118,6 +126,10 @@  discard block
 block discarded – undo
118 126
 	}
119 127
 
120 128
 	// function for decoding the AIS Message ITU Payload
129
+
130
+	/**
131
+	 * @param string $_aisdata
132
+	 */
121 133
 	private function decode_ais($_aisdata) {
122 134
 		$ro = new stdClass(); // return object
123 135
 		$ro->cls = 0; // AIS class undefined, also indicate unparsed msg
@@ -351,6 +363,12 @@  discard block
 block discarded – undo
351 363
 		elseif ($code == 99) return 'Other Type, no additional information';
352 364
 	}
353 365
 
366
+	/**
367
+	 * @param string $_itu
368
+	 * @param integer $_len
369
+	 * @param integer $_filler
370
+	 * @param string $aux
371
+	 */
354 372
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
355 373
 		global $port; // tcpip port...
356 374
 		
@@ -371,6 +389,10 @@  discard block
 block discarded – undo
371 389
 
372 390
 	// char* - AIS \r terminated string
373 391
 	// TCP based streams which send messages in full can use this instead of calling process_ais_buf
392
+
393
+	/**
394
+	 * @param string $rawdata
395
+	 */
374 396
 	public function process_ais_raw($rawdata, $aux = '') { // return int
375 397
 		static $num_seq; // 1 to 9
376 398
 		static $seq; // 1 to 9
@@ -589,6 +611,9 @@  discard block
 block discarded – undo
589 611
 		return $result;
590 612
 	}
591 613
 
614
+	/**
615
+	 * @param string $mmsi
616
+	 */
592 617
 	public function mmsitype($mmsi) {
593 618
 		if (strlen($mmsi) == 9) {
594 619
 			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		return ($dec);
58 58
 	}
59 59
 	
60
-    /*
60
+	/*
61 61
     $ais_map64 = array(
62 62
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48
63 63
        ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C',
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 		//  ' ' --- '?', // 0x20 - 0x3F
98 98
 		//  '@' --- '_', // 0x40 - 0x5F
99 99
 		$ais_chars = array(
100
-		    '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
-		    'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
-		    'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
-		    '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
-		    '(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
-		    '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
-		    '<', '=', '>', '?'
100
+			'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
+			'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
+			'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
+			'^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
+			'(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
+			'2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
+			'<', '=', '>', '?'
107 107
 		);
108 108
 		// "
109 109
 		$rv = '';
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 				}
420 420
 				if ($num_seq > 1) { // for multipart messages
421 421
 					if ($cmsg_sid != $msg_sid // different msg_sid
422
-					    || $msg_sid == -1 // invalid initial msg_sid
423
-					    || ($seq - $pseq) != 1 // not insequence
422
+						|| $msg_sid == -1 // invalid initial msg_sid
423
+						|| ($seq - $pseq) != 1 // not insequence
424 424
 					) {  // invalid for multipart message
425 425
 						$msg_sid = -1;
426 426
 						$cmsg_sid = -1;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 				$itu = $itu.$pcs[5]; // get itu message
434 434
 				$filler += (int)$pcs[6][0]; // get filler
435 435
 				if ($num_seq == 1 // valid single message
436
-				    || $num_seq == $pseq // valid multi-part message
436
+					|| $num_seq == $pseq // valid multi-part message
437 437
 				) {
438 438
 					if ($num_seq != 1) { // test
439 439
 						//echo $rawdata;
@@ -516,13 +516,13 @@  discard block
 block discarded – undo
516 516
 		else $pad = '';
517 517
 		$rv = '';
518 518
 		$ais_chars = array(
519
-		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
520
-		    'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
521
-		    'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
522
-		    '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
523
-		    '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
524
-		    '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
525
-		    '<'=>60, '='=>61, '>'=>62, '?'=>63
519
+			'@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
520
+			'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
521
+			'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
522
+			'^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
523
+			'('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
524
+			'2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
525
+			'<'=>60, '='=>61, '>'=>62, '?'=>63
526 526
 		);
527 527
 		// "
528 528
 		$_a = str_split($name);
Please login to merge, or discard this patch.
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
 
30 30
 	private function make_latf($temp) { // unsigned long 
31 31
 		$flat = 0.0; // float
32
-		$temp = $temp & 0x07FFFFFF;
33
-		if ($temp & 0x04000000) {
34
-			$temp = $temp ^ 0x07FFFFFF;
32
+		$temp = $temp&0x07FFFFFF;
33
+		if ($temp&0x04000000) {
34
+			$temp = $temp^0x07FFFFFF;
35 35
 			$temp += 1;
36
-			$flat = (float)($temp / (60.0 * 10000.0));
36
+			$flat = (float) ($temp/(60.0*10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else $flat = (float) ($temp/(60.0*10000.0));
39 39
 		return $flat; // float
40 40
 	}
41 41
 
42 42
 	private function make_lonf($temp) { // unsigned long
43 43
 		$flon = 0.0; // float
44
-		$temp = $temp & 0x0FFFFFFF;
45
-		if ($temp & 0x08000000) {
46
-			$temp = $temp ^ 0x0FFFFFFF;
44
+		$temp = $temp&0x0FFFFFFF;
45
+		if ($temp&0x08000000) {
46
+			$temp = $temp^0x0FFFFFFF;
47 47
 			$temp += 1;
48
-			$flon = (float)($temp / (60.0 * 10000.0));
48
+			$flon = (float) ($temp/(60.0*10000.0));
49 49
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
50
+		} else $flon = (float) ($temp/(60.0*10000.0));
51 51
 		return $flon;
52 52
 	}
53 53
 
54 54
 	private function ascii_2_dec($chr) {
55
-		$dec=ord($chr);//get decimal ascii code
56
-		$hex=dechex($dec);//convert decimal to hex
55
+		$dec = ord($chr); //get decimal ascii code
56
+		$hex = dechex($dec); //convert decimal to hex
57 57
 		return ($dec);
58 58
 	}
59 59
 	
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 		//only process in the following range: 48-87, 96-119
73 73
 		if ($ascii < 48) { }
74 74
 		else {
75
-			if($ascii>119) { }
75
+			if ($ascii > 119) { }
76 76
 			else {
77
-				if ($ascii>87 && $ascii<96) ;
77
+				if ($ascii > 87 && $ascii < 96);
78 78
 				else {
79
-					$ascii=$ascii+40;
80
-					if ($ascii>128){
81
-						$ascii=$ascii+32;
79
+					$ascii = $ascii + 40;
80
+					if ($ascii > 128) {
81
+						$ascii = $ascii + 32;
82 82
 					} else {
83
-						$ascii=$ascii+40;
83
+						$ascii = $ascii + 40;
84 84
 					}
85 85
 				}
86 86
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	}
90 90
 
91 91
 	private function dec_2_6bit($dec) {
92
-		$bin=decbin($dec);
92
+		$bin = decbin($dec);
93 93
 		return(substr($bin, -6)); 
94 94
 	}
95 95
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 		);
108 108
 		// "
109 109
 		$rv = '';
110
-		if ($_size % 6 == 0) {
111
-			$len = $_size / 6;
112
-			for ($i=0; $i<$len; $i++) {
113
-				$offset = $i * 6;
114
-				$rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ];
110
+		if ($_size%6 == 0) {
111
+			$len = $_size/6;
112
+			for ($i = 0; $i < $len; $i++) {
113
+				$offset = $i*6;
114
+				$rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))];
115 115
 			}
116 116
 		}
117 117
 		return $rv;
@@ -138,93 +138,93 @@  discard block
 block discarded – undo
138 138
 		$ro->eta_hour = '';
139 139
 		$ro->eta_minute = '';
140 140
 		$ro->ts = time();
141
-		$ro->id = bindec(substr($_aisdata,0,6));
142
-		$ro->mmsi = bindec(substr($_aisdata,8,30));
141
+		$ro->id = bindec(substr($_aisdata, 0, 6));
142
+		$ro->mmsi = bindec(substr($_aisdata, 8, 30));
143 143
 		if ($ro->id >= 1 && $ro->id <= 3) {
144
-			$ro->cog = bindec(substr($_aisdata,116,12))/10;
145
-			$ro->sog = bindec(substr($_aisdata,50,10))/10;
146
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
147
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
144
+			$ro->cog = bindec(substr($_aisdata, 116, 12))/10;
145
+			$ro->sog = bindec(substr($_aisdata, 50, 10))/10;
146
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
147
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
148 148
 			$ro->cls = 1; // class A
149 149
 		} else if ($ro->id == 4) {
150
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28)));
151
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27)));
150
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28)));
151
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27)));
152 152
 			$ro->cls = 1; // class A
153 153
 		} else if ($ro->id == 5) {
154
-			$ro->imo = bindec(substr($_aisdata,40,30));
155
-			$ro->callsign = $this->binchar($_aisdata,70,42);
156
-			$ro->name = $this->binchar($_aisdata,112,120);
157
-			$ro->typeid = bindec(substr($_aisdata,232,8));
154
+			$ro->imo = bindec(substr($_aisdata, 40, 30));
155
+			$ro->callsign = $this->binchar($_aisdata, 70, 42);
156
+			$ro->name = $this->binchar($_aisdata, 112, 120);
157
+			$ro->typeid = bindec(substr($_aisdata, 232, 8));
158 158
 			$ro->type = $this->getShipType($ro->typeid);
159 159
 			//$ro->to_bow = bindec(substr($_aisdata,240,9));
160 160
 			//$ro->to_stern = bindec(substr($_aisdata,249,9));
161 161
 			//$ro->to_port = bindec(substr($_aisdata,258,6));
162 162
 			//$ro->to_starboard = bindec(substr($_aisdata,264,6));
163
-			$ro->eta_month = bindec(substr($_aisdata,274,4));
164
-			$ro->eta_day = bindec(substr($_aisdata,278,5));
165
-			$ro->eta_hour = bindec(substr($_aisdata,283,5));
166
-			$ro->eta_minute = bindec(substr($_aisdata,288,6));
163
+			$ro->eta_month = bindec(substr($_aisdata, 274, 4));
164
+			$ro->eta_day = bindec(substr($_aisdata, 278, 5));
165
+			$ro->eta_hour = bindec(substr($_aisdata, 283, 5));
166
+			$ro->eta_minute = bindec(substr($_aisdata, 288, 6));
167 167
 			//$ro->draught = bindec(substr($_aisdata,294,8));
168
-			$ro->destination = $this->binchar($_aisdata,302,120);
168
+			$ro->destination = $this->binchar($_aisdata, 302, 120);
169 169
 			$ro->cls = 1; // class A
170 170
 		} else if ($ro->id == 9) {
171 171
 			// Search and Rescue aircraft position report
172 172
 		} else if ($ro->id == 18) {
173
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
174
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
175
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177
-			$ro->heading = bindec(substr($_aisdata,124,9));
173
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
174
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
175
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28)));
176
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27)));
177
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
178 178
 			if ($ro->heading == 511) $ro->heading = '';
179 179
 			$ro->cls = 2; // class B
180 180
 		} else if ($ro->id == 19) {
181
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
182
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
183
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
184
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
185
-			$ro->name = $this->binchar($_aisdata,143,120);
181
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
182
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
183
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
184
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
185
+			$ro->name = $this->binchar($_aisdata, 143, 120);
186 186
 			$ro->cls = 2; // class B
187
-			$ro->heading = bindec(substr($_aisdata,124,9));
187
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
188 188
 			if ($ro->heading == 511) $ro->heading = '';
189
-			$ro->typeid = bindec(substr($_aisdata,263,8));
189
+			$ro->typeid = bindec(substr($_aisdata, 263, 8));
190 190
 			$ro->type = $this->getShipType($ro->typeid);
191 191
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
192 192
 			//$ro->to_stern = bindec(substr($_aisdata,280,9));
193 193
 			//$ro->to_port = bindec(substr($_aisdata,289,6));
194 194
 			//$ro->to_starboard = bindec(substr($_aisdata,295,6));
195 195
 		} else if ($ro->id == 21) {
196
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28)));
197
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27)));
198
-			$ro->name = $this->binchar($_aisdata,43,120);
196
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28)));
197
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27)));
198
+			$ro->name = $this->binchar($_aisdata, 43, 120);
199 199
 			//$ro->to_bow = bindec(substr($_aisdata,219,9));
200 200
 			//$ro->to_stern = bindec(substr($_aisdata,228,9));
201 201
 			//$ro->to_port = bindec(substr($_aisdata,237,6));
202 202
 			//$ro->to_starboard = bindec(substr($_aisdata,243,6));
203 203
 			$ro->cls = 2; // class B
204 204
 		} else if ($ro->id == 24) {
205
-			$pn = bindec(substr($_aisdata,38,2));
205
+			$pn = bindec(substr($_aisdata, 38, 2));
206 206
 			if ($pn == 0) {
207
-				$ro->name = $this->binchar($_aisdata,40,120);
207
+				$ro->name = $this->binchar($_aisdata, 40, 120);
208 208
 			}
209
-			$ro->typeid = bindec(substr($_aisdata,40,8));
209
+			$ro->typeid = bindec(substr($_aisdata, 40, 8));
210 210
 			$ro->type = $this->getShipType($ro->typeid);
211
-			$ro->callsign = $this->binchar($_aisdata,90,42);
211
+			$ro->callsign = $this->binchar($_aisdata, 90, 42);
212 212
 			//$ro->to_bow = bindec(substr($_aisdata,132,9));
213 213
 			//$ro->to_stern = bindec(substr($_aisdata,141,9));
214 214
 			//$ro->to_port = bindec(substr($_aisdata,150,6));
215 215
 			//$ro->to_starboard = bindec(substr($_aisdata,156,6));
216 216
 			$ro->cls = 2; // class B
217 217
 		} else if ($ro->id == 27) {
218
-			$ro->cog = bindec(substr($_aisdata,85,9));
218
+			$ro->cog = bindec(substr($_aisdata, 85, 9));
219 219
 			if ($ro->cog == 511) $ro->cog = 0.0;
220
-			$ro->sog = bindec(substr($_aisdata,79,6));
220
+			$ro->sog = bindec(substr($_aisdata, 79, 6));
221 221
 			if ($ro->sog == 63) $ro->sog = 0.0;
222
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
222
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10);
223
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10);
224 224
 			$ro->cls = 1; // class A
225 225
 		
226 226
 		}
227
-		$ro->statusid = bindec(substr($_aisdata,38,4));
227
+		$ro->statusid = bindec(substr($_aisdata, 38, 4));
228 228
 		$ro->status = $this->getStatus($ro->statusid);
229 229
 		//var_dump($ro); // dump results here for demo purpose
230 230
 		return $ro;
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 		global $port; // tcpip port...
356 356
 		
357 357
 		static $debug_counter = 0;
358
-		$aisdata168='';//six bit array of ascii characters
358
+		$aisdata168 = ''; //six bit array of ascii characters
359 359
 		$ais_nmea_array = str_split($_itu); // convert to an array
360 360
 		foreach ($ais_nmea_array as $value) {
361 361
 			$dec = $this->ascii_2_dec($value);
362 362
 			$bit8 = $this->asciidec_2_8bit($dec);
363 363
 			$bit6 = $this->dec_2_6bit($bit8);
364 364
 			//echo $value ."-" .$bit6 ."";
365
-			$aisdata168 .=$bit6;
365
+			$aisdata168 .= $bit6;
366 366
 		}
367 367
 		//echo $aisdata168 . "<br/>";
368 368
 		//return $this->decode_ais($aisdata168, $aux);
@@ -385,24 +385,24 @@  discard block
 block discarded – undo
385 385
 		// calculate checksum after ! till *
386 386
 		// assume 1st ! is valid
387 387
 		// find * ensure that it is at correct position
388
-		$end = strrpos ( $rawdata , '*' );
388
+		$end = strrpos($rawdata, '*');
389 389
 		if ($end === FALSE) return -1; // check for NULLS!!!
390
-		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
392
-		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
394
-		if ( $chksum == $dcs ) { // NMEA checksum pass
390
+		$cs = substr($rawdata, $end + 1);
391
+		if (strlen($cs) != 2) return -1; // correct cs length
392
+		$dcs = (int) hexdec($cs);
393
+		for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum
394
+		if ($chksum == $dcs) { // NMEA checksum pass
395 395
 			$pcs = explode(',', $rawdata);
396 396
 			// !AI??? identifier
397 397
 			if (!isset($pcs[1])) {
398 398
 				echo "ERROR,INVALID_DATA ".time()." $rawdata\n";
399 399
 				return -1;
400 400
 			}
401
-			$num_seq = (int)$pcs[1]; // number of sequences
402
-			$seq = (int)$pcs[2]; // get sequence
401
+			$num_seq = (int) $pcs[1]; // number of sequences
402
+			$seq = (int) $pcs[2]; // get sequence
403 403
 			// get msg sequence id
404 404
 			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
405
-			else $msg_sid = (int)$pcs[3]; // multipart message
405
+			else $msg_sid = (int) $pcs[3]; // multipart message
406 406
 			$ais_ch = $pcs[4]; // get AIS channel
407 407
 			// message sequence checking
408 408
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 					}
436 436
 				}
437 437
 				$itu = $itu.$pcs[5]; // get itu message
438
-				$filler += (int)$pcs[6][0]; // get filler
438
+				$filler += (int) $pcs[6][0]; // get filler
439 439
 				if ($num_seq == 1 // valid single message
440 440
 				    || $num_seq == $pseq // valid multi-part message
441 441
 				) {
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
 		$cbuf = $cbuf.$ibuf;
456 456
 		$last_pos = 0;
457 457
 		$result = new stdClass();
458
-		while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) {
458
+		while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) {
459 459
 		//while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) {
460 460
 			//DEBUG echo $cbuf;
461
-			if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim?
461
+			if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim?
462 462
 				$tst = substr($cbuf, $start - 3, ($end - $start + 3));
463 463
 				//DEBUG echo "[$start $end $tst]\n";
464
-				$result = $this->process_ais_raw( $tst, "" );
464
+				$result = $this->process_ais_raw($tst, "");
465 465
 				$last_pos = $end + 1;
466 466
 			} else break;
467 467
 		}
@@ -473,41 +473,41 @@  discard block
 block discarded – undo
473 473
 	// incoming data from serial or IP comms
474 474
 	public function process_ais_line($cbuf) {
475 475
 		$result = new stdClass();
476
-		$start = strpos($cbuf,"VDM");
476
+		$start = strpos($cbuf, "VDM");
477 477
 		$tst = substr($cbuf, $start - 3);
478
-		$result = $this->process_ais_raw( $tst, "" );
478
+		$result = $this->process_ais_raw($tst, "");
479 479
 		return $result;
480 480
 	}
481 481
 
482 482
 	/* AIS Encoding
483 483
 	*/
484
-	private function mk_ais_lat( $lat ) {
484
+	private function mk_ais_lat($lat) {
485 485
 		//$lat = 1.2569;
486
-		if ($lat<0.0) {
486
+		if ($lat < 0.0) {
487 487
 			$lat = -$lat;
488
-			$neg=true;
489
-		} else $neg=false;
488
+			$neg = true;
489
+		} else $neg = false;
490 490
 		$latd = 0x00000000;
491
-		$latd = intval ($lat * 600000.0);
492
-		if ($neg==true) {
491
+		$latd = intval($lat*600000.0);
492
+		if ($neg == true) {
493 493
 			$latd = ~$latd;
494
-			$latd+=1;
494
+			$latd += 1;
495 495
 			$latd &= 0x07FFFFFF;
496 496
 		}
497 497
 		return $latd;
498 498
 	}
499 499
 
500
-	private function mk_ais_lon( $lon ) {
500
+	private function mk_ais_lon($lon) {
501 501
 		//$lon = 103.851;
502
-		if ($lon<0.0) {
502
+		if ($lon < 0.0) {
503 503
 			$lon = -$lon;
504
-			$neg=true;
505
-		} else $neg=false;
504
+			$neg = true;
505
+		} else $neg = false;
506 506
 		$lond = 0x00000000;
507
-		$lond = intval ($lon * 600000.0);
508
-		if ($neg==true) {
507
+		$lond = intval($lon*600000.0);
508
+		if ($neg == true) {
509 509
 			$lond = ~$lond;
510
-			$lond+=1;
510
+			$lond += 1;
511 511
 			$lond &= 0x0FFFFFFF;
512 512
 		}
513 513
 		return $lond;
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
 
516 516
 	private function char2bin($name, $max_len) {
517 517
 		$len = strlen($name);
518
-		if ($len > $max_len) $name = substr($name,0,$max_len);
519
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
518
+		if ($len > $max_len) $name = substr($name, 0, $max_len);
519
+		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6);
520 520
 		else $pad = '';
521 521
 		$rv = '';
522 522
 		$ais_chars = array(
@@ -533,26 +533,26 @@  discard block
 block discarded – undo
533 533
 		if ($_a) foreach ($_a as $_1) {
534 534
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
535 535
 			else $dec = 0;
536
-			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
536
+			$bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT);
537 537
 			$rv .= $bin;
538 538
 			//echo "$_1 $dec ($bin)<br/>";
539 539
 		}
540 540
 		return $rv.$pad;
541 541
 	}
542 542
 
543
-	private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') {
543
+	private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') {
544 544
 		$len_bit = strlen($_enc);
545
-		$rem6 = $len_bit % 6;
545
+		$rem6 = $len_bit%6;
546 546
 		$pad6_len = 0;
547 547
 		if ($rem6) $pad6_len = 6 - $rem6;
548 548
 		//echo  $pad6_len.'<br>';
549 549
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
550
-		$len_enc = strlen($_enc) / 6;
550
+		$len_enc = strlen($_enc)/6;
551 551
 		//echo $_enc.' '.$len_enc.'<br/>';
552 552
 		$itu = '';
553
-		for ($i=0; $i<$len_enc; $i++) {
554
-			$offset = $i * 6;
555
-			$dec = bindec(substr($_enc,$offset,6));
553
+		for ($i = 0; $i < $len_enc; $i++) {
554
+			$offset = $i*6;
555
+			$dec = bindec(substr($_enc, $offset, 6));
556 556
 			if ($dec < 40) $dec += 48;
557 557
 			else $dec += 56;
558 558
 			//echo chr($dec)." $dec<br/>";
@@ -562,15 +562,15 @@  discard block
 block discarded – undo
562 562
 		$chksum = 0;
563 563
 		$itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0";
564 564
 		$len_itu = strlen($itu);
565
-		for ($i=0; $i<$len_itu; $i++) {
566
-			$chksum ^= ord( $itu[$i] );
565
+		for ($i = 0; $i < $len_itu; $i++) {
566
+			$chksum ^= ord($itu[$i]);
567 567
 		}
568
-		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
569
-		$lsb = $chksum & 0x0F;
570
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
568
+		$hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
569
+		$lsb = $chksum&0x0F;
570
+		if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb];
571 571
 		else $lsbc = '0';
572
-		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
573
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
572
+		$msb = (($chksum&0xF0) >> 4)&0x0F;
573
+		if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb];
574 574
 		else $msbc = '0';
575 575
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
576 576
 		return $itu;
@@ -595,14 +595,14 @@  discard block
 block discarded – undo
595 595
 
596 596
 	public function mmsitype($mmsi) {
597 597
 		if (strlen($mmsi) == 9) {
598
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
599
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
600
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
601
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
602
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
603
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
604
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
605
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
598
+			if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
599
+			elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device';
600
+			elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
601
+			elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft';
602
+			elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship';
603
+			elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation';
604
+			elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations';
605
+			elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships';
606 606
 			else return 'Ship';
607 607
 		}
608 608
 
@@ -613,19 +613,19 @@  discard block
 block discarded – undo
613 613
 		global $globalDebug;
614 614
 		$result = array();
615 615
 		$data = new stdClass();
616
-		$start = strpos($buffer,"VDM");
616
+		$start = strpos($buffer, "VDM");
617 617
 		$tst = substr($buffer, $start - 3);
618
-		$data = $this->process_ais_raw( $tst, "" );
618
+		$data = $this->process_ais_raw($tst, "");
619 619
 		if (!is_object($data)) {
620 620
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
621 621
 			return array();
622 622
 		}
623 623
 		if ($data->lon != 0) $result['longitude'] = $data->lon;
624 624
 		if ($data->lat != 0) $result['latitude'] = $data->lat;
625
-		$result['ident'] = trim(str_replace('@','',$data->name));
625
+		$result['ident'] = trim(str_replace('@', '', $data->name));
626 626
 		$result['timestamp'] = $data->ts;
627 627
 		$result['mmsi'] = $data->mmsi;
628
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
628
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
629 629
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
630 630
 		if ($data->sog != -1.0) $result['speed'] = $data->sog;
631 631
 		if ($data->heading !== '') $result['heading'] = $data->heading;
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
 		if ($data->type !== '') $result['type'] = $data->type;
636 636
 		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
637 637
 		if ($data->imo !== '') $result['imo'] = $data->imo;
638
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
638
+		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign));
639 639
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
640
-			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
640
+			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
641 641
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
642 642
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
643
-			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
643
+			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
644 644
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
645 645
 		}
646 646
 		if ($data->destination != '') {
647
-			$dest = trim(str_replace('@','',$data->destination));
647
+			$dest = trim(str_replace('@', '', $data->destination));
648 648
 			if ($dest != '') $result['destination'] = $dest;
649 649
 		}
650 650
 		$result['all'] = (array) $data;
Please login to merge, or discard this patch.
Braces   +331 added lines, -143 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 			$temp += 1;
36 36
 			$flat = (float)($temp / (60.0 * 10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else {
39
+			$flat = (float)($temp / (60.0 * 10000.0));
40
+		}
39 41
 		return $flat; // float
40 42
 	}
41 43
 
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 			$temp += 1;
48 50
 			$flon = (float)($temp / (60.0 * 10000.0));
49 51
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
52
+		} else {
53
+			$flon = (float)($temp / (60.0 * 10000.0));
54
+		}
51 55
 		return $flon;
52 56
 	}
53 57
 
@@ -70,10 +74,8 @@  discard block
 block discarded – undo
70 74
     */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73
-		if ($ascii < 48) { }
74
-		else {
75
-			if($ascii>119) { }
76
-			else {
77
+		if ($ascii < 48) { } else {
78
+			if($ascii>119) { } else {
77 79
 				if ($ascii>87 && $ascii<96) ;
78 80
 				else {
79 81
 					$ascii=$ascii+40;
@@ -175,7 +177,9 @@  discard block
 block discarded – undo
175 177
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176 178
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177 179
 			$ro->heading = bindec(substr($_aisdata,124,9));
178
-			if ($ro->heading == 511) $ro->heading = '';
180
+			if ($ro->heading == 511) {
181
+				$ro->heading = '';
182
+			}
179 183
 			$ro->cls = 2; // class B
180 184
 		} else if ($ro->id == 19) {
181 185
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -185,7 +189,9 @@  discard block
 block discarded – undo
185 189
 			$ro->name = $this->binchar($_aisdata,143,120);
186 190
 			$ro->cls = 2; // class B
187 191
 			$ro->heading = bindec(substr($_aisdata,124,9));
188
-			if ($ro->heading == 511) $ro->heading = '';
192
+			if ($ro->heading == 511) {
193
+				$ro->heading = '';
194
+			}
189 195
 			$ro->typeid = bindec(substr($_aisdata,263,8));
190 196
 			$ro->type = $this->getShipType($ro->typeid);
191 197
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -216,9 +222,13 @@  discard block
 block discarded – undo
216 222
 			$ro->cls = 2; // class B
217 223
 		} else if ($ro->id == 27) {
218 224
 			$ro->cog = bindec(substr($_aisdata,85,9));
219
-			if ($ro->cog == 511) $ro->cog = 0.0;
225
+			if ($ro->cog == 511) {
226
+				$ro->cog = 0.0;
227
+			}
220 228
 			$ro->sog = bindec(substr($_aisdata,79,6));
221
-			if ($ro->sog == 63) $ro->sog = 0.0;
229
+			if ($ro->sog == 63) {
230
+				$ro->sog = 0.0;
231
+			}
222 232
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223 233
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
224 234
 			$ro->cls = 1; // class A
@@ -267,88 +277,171 @@  discard block
 block discarded – undo
267 277
 	}
268 278
 	
269 279
 	public function getShipType($code) {
270
-		if ($code == 0) return 'Not available (default)';
271
-		elseif ($code >= 1 && $code <= 19) return 'Reserved for future use';
272
-		elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type';
273
-		elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A';
274
-		elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B';
275
-		elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C';
276
-		elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D';
277
-		elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use';
278
-		elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use';
279
-		elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use';
280
-		elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use';
281
-		elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use';
282
-		elseif ($code == 30) return 'Fishing';
283
-		elseif ($code == 31) return 'Towing';
284
-		elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m';
285
-		elseif ($code == 33) return 'Dredging or underwater ops';
286
-		elseif ($code == 34) return 'Diving ops';
287
-		elseif ($code == 35) return 'Military ops';
288
-		elseif ($code == 36) return 'Sailing';
289
-		elseif ($code == 37) return 'Pleasure Craft';
290
-		elseif ($code == 38) return 'Reserved';
291
-		elseif ($code == 39) return 'Reserved';
292
-		elseif ($code == 40) return 'High speed craft (HSC), all ships of this type';
293
-		elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A';
294
-		elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B';
295
-		elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C';
296
-		elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D';
297
-		elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use';
298
-		elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use';
299
-		elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use';
300
-		elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use';
301
-		elseif ($code == 49) return 'High speed craft (HSC), No additional information';
302
-		elseif ($code == 50) return 'Pilot Vessel';
303
-		elseif ($code == 51) return 'Search and Rescue vessel';
304
-		elseif ($code == 52) return 'Tug';
305
-		elseif ($code == 53) return 'Port Tender';
306
-		elseif ($code == 54) return 'Anti-pollution equipment';
307
-		elseif ($code == 55) return 'Law Enforcement';
308
-		elseif ($code == 56) return 'Spare - Local Vessel';
309
-		elseif ($code == 57) return 'Spare - Local Vessel';
310
-		elseif ($code == 58) return 'Medical Transport';
311
-		elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18';
312
-		elseif ($code == 60) return 'Passenger, all ships of this type';
313
-		elseif ($code == 61) return 'Passenger, Hazardous category A';
314
-		elseif ($code == 62) return 'Passenger, Hazardous category B';
315
-		elseif ($code == 63) return 'Passenger, Hazardous category C';
316
-		elseif ($code == 64) return 'Passenger, Hazardous category D';
317
-		elseif ($code == 65) return 'Passenger, Reserved for future use';
318
-		elseif ($code == 66) return 'Passenger, Reserved for future use';
319
-		elseif ($code == 67) return 'Passenger, Reserved for future use';
320
-		elseif ($code == 68) return 'Passenger, Reserved for future use';
321
-		elseif ($code == 69) return 'Passenger, No additional information';
322
-		elseif ($code == 70) return 'Cargo, all ships of this type';
323
-		elseif ($code == 71) return 'Cargo, Hazardous category A';
324
-		elseif ($code == 72) return 'Cargo, Hazardous category B';
325
-		elseif ($code == 73) return 'Cargo, Hazardous category C';
326
-		elseif ($code == 74) return 'Cargo, Hazardous category D';
327
-		elseif ($code == 75) return 'Cargo, Reserved for future use';
328
-		elseif ($code == 76) return 'Cargo, Reserved for future use';
329
-		elseif ($code == 77) return 'Cargo, Reserved for future use';
330
-		elseif ($code == 78) return 'Cargo, Reserved for future use';
331
-		elseif ($code == 79) return 'Cargo, No additional information';
332
-		elseif ($code == 80) return 'Tanker, all ships of this type';
333
-		elseif ($code == 81) return 'Tanker, Hazardous category A';
334
-		elseif ($code == 82) return 'Tanker, Hazardous category B';
335
-		elseif ($code == 83) return 'Tanker, Hazardous category C';
336
-		elseif ($code == 84) return 'Tanker, Hazardous category D';
337
-		elseif ($code == 85) return 'Tanker, Reserved for future use';
338
-		elseif ($code == 86) return 'Tanker, Reserved for future use';
339
-		elseif ($code == 87) return 'Tanker, Reserved for future use';
340
-		elseif ($code == 88) return 'Tanker, Reserved for future use';
341
-		elseif ($code == 89) return 'Tanker, No additional information';
342
-		elseif ($code == 90) return 'Other Type, all ships of this type';
343
-		elseif ($code == 91) return 'Other Type, Hazardous category A';
344
-		elseif ($code == 92) return 'Other Type, Hazardous category B';
345
-		elseif ($code == 93) return 'Other Type, Hazardous category C';
346
-		elseif ($code == 94) return 'Other Type, Hazardous category D';
347
-		elseif ($code == 95) return 'Other Type, Reserved for future use';
348
-		elseif ($code == 96) return 'Other Type, Reserved for future use';
349
-		elseif ($code == 97) return 'Other Type, Reserved for future use';
350
-		elseif ($code == 98) return 'Other Type, Reserved for future use';
351
-		elseif ($code == 99) return 'Other Type, no additional information';
280
+		if ($code == 0) {
281
+			return 'Not available (default)';
282
+		} elseif ($code >= 1 && $code <= 19) {
283
+			return 'Reserved for future use';
284
+		} elseif ($code == 20) {
285
+			return 'Wing in ground (WIG), all ships of this type';
286
+		} elseif ($code == 21) {
287
+			return 'Wing in ground (WIG), Hazardous category A';
288
+		} elseif ($code == 22) {
289
+			return 'Wing in ground (WIG), Hazardous category B';
290
+		} elseif ($code == 23) {
291
+			return 'Wing in ground (WIG), Hazardous category C';
292
+		} elseif ($code == 24) {
293
+			return 'Wing in ground (WIG), Hazardous category D';
294
+		} elseif ($code == 25) {
295
+			return 'Wing in ground (WIG), Reserved for future use';
296
+		} elseif ($code == 26) {
297
+			return 'Wing in ground (WIG), Reserved for future use';
298
+		} elseif ($code == 27) {
299
+			return 'Wing in ground (WIG), Reserved for future use';
300
+		} elseif ($code == 28) {
301
+			return 'Wing in ground (WIG), Reserved for future use';
302
+		} elseif ($code == 29) {
303
+			return 'Wing in ground (WIG), Reserved for future use';
304
+		} elseif ($code == 30) {
305
+			return 'Fishing';
306
+		} elseif ($code == 31) {
307
+			return 'Towing';
308
+		} elseif ($code == 32) {
309
+			return 'Towing: length exceeds 200m or breadth exceeds 25m';
310
+		} elseif ($code == 33) {
311
+			return 'Dredging or underwater ops';
312
+		} elseif ($code == 34) {
313
+			return 'Diving ops';
314
+		} elseif ($code == 35) {
315
+			return 'Military ops';
316
+		} elseif ($code == 36) {
317
+			return 'Sailing';
318
+		} elseif ($code == 37) {
319
+			return 'Pleasure Craft';
320
+		} elseif ($code == 38) {
321
+			return 'Reserved';
322
+		} elseif ($code == 39) {
323
+			return 'Reserved';
324
+		} elseif ($code == 40) {
325
+			return 'High speed craft (HSC), all ships of this type';
326
+		} elseif ($code == 41) {
327
+			return 'High speed craft (HSC), Hazardous category A';
328
+		} elseif ($code == 42) {
329
+			return 'High speed craft (HSC), Hazardous category B';
330
+		} elseif ($code == 43) {
331
+			return 'High speed craft (HSC), Hazardous category C';
332
+		} elseif ($code == 44) {
333
+			return 'High speed craft (HSC), Hazardous category D';
334
+		} elseif ($code == 45) {
335
+			return 'High speed craft (HSC), Reserved for future use';
336
+		} elseif ($code == 46) {
337
+			return 'High speed craft (HSC), Reserved for future use';
338
+		} elseif ($code == 47) {
339
+			return 'High speed craft (HSC), Reserved for future use';
340
+		} elseif ($code == 48) {
341
+			return 'High speed craft (HSC), Reserved for future use';
342
+		} elseif ($code == 49) {
343
+			return 'High speed craft (HSC), No additional information';
344
+		} elseif ($code == 50) {
345
+			return 'Pilot Vessel';
346
+		} elseif ($code == 51) {
347
+			return 'Search and Rescue vessel';
348
+		} elseif ($code == 52) {
349
+			return 'Tug';
350
+		} elseif ($code == 53) {
351
+			return 'Port Tender';
352
+		} elseif ($code == 54) {
353
+			return 'Anti-pollution equipment';
354
+		} elseif ($code == 55) {
355
+			return 'Law Enforcement';
356
+		} elseif ($code == 56) {
357
+			return 'Spare - Local Vessel';
358
+		} elseif ($code == 57) {
359
+			return 'Spare - Local Vessel';
360
+		} elseif ($code == 58) {
361
+			return 'Medical Transport';
362
+		} elseif ($code == 59) {
363
+			return 'Noncombatant ship according to RR Resolution No. 18';
364
+		} elseif ($code == 60) {
365
+			return 'Passenger, all ships of this type';
366
+		} elseif ($code == 61) {
367
+			return 'Passenger, Hazardous category A';
368
+		} elseif ($code == 62) {
369
+			return 'Passenger, Hazardous category B';
370
+		} elseif ($code == 63) {
371
+			return 'Passenger, Hazardous category C';
372
+		} elseif ($code == 64) {
373
+			return 'Passenger, Hazardous category D';
374
+		} elseif ($code == 65) {
375
+			return 'Passenger, Reserved for future use';
376
+		} elseif ($code == 66) {
377
+			return 'Passenger, Reserved for future use';
378
+		} elseif ($code == 67) {
379
+			return 'Passenger, Reserved for future use';
380
+		} elseif ($code == 68) {
381
+			return 'Passenger, Reserved for future use';
382
+		} elseif ($code == 69) {
383
+			return 'Passenger, No additional information';
384
+		} elseif ($code == 70) {
385
+			return 'Cargo, all ships of this type';
386
+		} elseif ($code == 71) {
387
+			return 'Cargo, Hazardous category A';
388
+		} elseif ($code == 72) {
389
+			return 'Cargo, Hazardous category B';
390
+		} elseif ($code == 73) {
391
+			return 'Cargo, Hazardous category C';
392
+		} elseif ($code == 74) {
393
+			return 'Cargo, Hazardous category D';
394
+		} elseif ($code == 75) {
395
+			return 'Cargo, Reserved for future use';
396
+		} elseif ($code == 76) {
397
+			return 'Cargo, Reserved for future use';
398
+		} elseif ($code == 77) {
399
+			return 'Cargo, Reserved for future use';
400
+		} elseif ($code == 78) {
401
+			return 'Cargo, Reserved for future use';
402
+		} elseif ($code == 79) {
403
+			return 'Cargo, No additional information';
404
+		} elseif ($code == 80) {
405
+			return 'Tanker, all ships of this type';
406
+		} elseif ($code == 81) {
407
+			return 'Tanker, Hazardous category A';
408
+		} elseif ($code == 82) {
409
+			return 'Tanker, Hazardous category B';
410
+		} elseif ($code == 83) {
411
+			return 'Tanker, Hazardous category C';
412
+		} elseif ($code == 84) {
413
+			return 'Tanker, Hazardous category D';
414
+		} elseif ($code == 85) {
415
+			return 'Tanker, Reserved for future use';
416
+		} elseif ($code == 86) {
417
+			return 'Tanker, Reserved for future use';
418
+		} elseif ($code == 87) {
419
+			return 'Tanker, Reserved for future use';
420
+		} elseif ($code == 88) {
421
+			return 'Tanker, Reserved for future use';
422
+		} elseif ($code == 89) {
423
+			return 'Tanker, No additional information';
424
+		} elseif ($code == 90) {
425
+			return 'Other Type, all ships of this type';
426
+		} elseif ($code == 91) {
427
+			return 'Other Type, Hazardous category A';
428
+		} elseif ($code == 92) {
429
+			return 'Other Type, Hazardous category B';
430
+		} elseif ($code == 93) {
431
+			return 'Other Type, Hazardous category C';
432
+		} elseif ($code == 94) {
433
+			return 'Other Type, Hazardous category D';
434
+		} elseif ($code == 95) {
435
+			return 'Other Type, Reserved for future use';
436
+		} elseif ($code == 96) {
437
+			return 'Other Type, Reserved for future use';
438
+		} elseif ($code == 97) {
439
+			return 'Other Type, Reserved for future use';
440
+		} elseif ($code == 98) {
441
+			return 'Other Type, Reserved for future use';
442
+		} elseif ($code == 99) {
443
+			return 'Other Type, no additional information';
444
+		}
352 445
 	}
353 446
 
354 447
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -386,11 +479,20 @@  discard block
 block discarded – undo
386 479
 		// assume 1st ! is valid
387 480
 		// find * ensure that it is at correct position
388 481
 		$end = strrpos ( $rawdata , '*' );
389
-		if ($end === FALSE) return -1; // check for NULLS!!!
482
+		if ($end === FALSE) {
483
+			return -1;
484
+		}
485
+		// check for NULLS!!!
390 486
 		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
487
+		if ( strlen($cs) != 2 ) {
488
+			return -1;
489
+		}
490
+		// correct cs length
392 491
 		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
492
+		for ( $alias=1; $alias<$end; $alias++) {
493
+			$chksum ^= ord( $rawdata[$alias] );
494
+		}
495
+		// perform XOR for NMEA checksum
394 496
 		if ( $chksum == $dcs ) { // NMEA checksum pass
395 497
 			$pcs = explode(',', $rawdata);
396 498
 			// !AI??? identifier
@@ -401,8 +503,14 @@  discard block
 block discarded – undo
401 503
 			$num_seq = (int)$pcs[1]; // number of sequences
402 504
 			$seq = (int)$pcs[2]; // get sequence
403 505
 			// get msg sequence id
404
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
405
-			else $msg_sid = (int)$pcs[3]; // multipart message
506
+			if ($pcs[3] == '') {
507
+				$msg_sid = -1;
508
+			}
509
+			// non-multipart message, set to -1
510
+			else {
511
+				$msg_sid = (int)$pcs[3];
512
+			}
513
+			// multipart message
406 514
 			$ais_ch = $pcs[4]; // get AIS channel
407 515
 			// message sequence checking
408 516
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -463,10 +571,18 @@  discard block
 block discarded – undo
463 571
 				//DEBUG echo "[$start $end $tst]\n";
464 572
 				$result = $this->process_ais_raw( $tst, "" );
465 573
 				$last_pos = $end + 1;
466
-			} else break;
574
+			} else {
575
+				break;
576
+			}
467 577
 		}
468
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
469
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
578
+		if ($last_pos > 0) {
579
+			$cbuf = substr($cbuf, $last_pos);
580
+		}
581
+		// move...
582
+		if (strlen($cbuf) > 1024) {
583
+			$cbuf = "";
584
+		}
585
+		// prevent overflow simple mode...
470 586
 		return $result;
471 587
 	}
472 588
 
@@ -486,7 +602,9 @@  discard block
 block discarded – undo
486 602
 		if ($lat<0.0) {
487 603
 			$lat = -$lat;
488 604
 			$neg=true;
489
-		} else $neg=false;
605
+		} else {
606
+			$neg=false;
607
+		}
490 608
 		$latd = 0x00000000;
491 609
 		$latd = intval ($lat * 600000.0);
492 610
 		if ($neg==true) {
@@ -502,7 +620,9 @@  discard block
 block discarded – undo
502 620
 		if ($lon<0.0) {
503 621
 			$lon = -$lon;
504 622
 			$neg=true;
505
-		} else $neg=false;
623
+		} else {
624
+			$neg=false;
625
+		}
506 626
 		$lond = 0x00000000;
507 627
 		$lond = intval ($lon * 600000.0);
508 628
 		if ($neg==true) {
@@ -515,9 +635,14 @@  discard block
 block discarded – undo
515 635
 
516 636
 	private function char2bin($name, $max_len) {
517 637
 		$len = strlen($name);
518
-		if ($len > $max_len) $name = substr($name,0,$max_len);
519
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
520
-		else $pad = '';
638
+		if ($len > $max_len) {
639
+			$name = substr($name,0,$max_len);
640
+		}
641
+		if ($len < $max_len) {
642
+			$pad = str_repeat('0', ($max_len - $len) * 6);
643
+		} else {
644
+			$pad = '';
645
+		}
521 646
 		$rv = '';
522 647
 		$ais_chars = array(
523 648
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -530,9 +655,12 @@  discard block
 block discarded – undo
530 655
 		);
531 656
 		// "
532 657
 		$_a = str_split($name);
533
-		if ($_a) foreach ($_a as $_1) {
658
+		if ($_a) {
659
+			foreach ($_a as $_1) {
534 660
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
535
-			else $dec = 0;
661
+		} else {
662
+				$dec = 0;
663
+			}
536 664
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
537 665
 			$rv .= $bin;
538 666
 			//echo "$_1 $dec ($bin)<br/>";
@@ -544,7 +672,9 @@  discard block
 block discarded – undo
544 672
 		$len_bit = strlen($_enc);
545 673
 		$rem6 = $len_bit % 6;
546 674
 		$pad6_len = 0;
547
-		if ($rem6) $pad6_len = 6 - $rem6;
675
+		if ($rem6) {
676
+			$pad6_len = 6 - $rem6;
677
+		}
548 678
 		//echo  $pad6_len.'<br>';
549 679
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
550 680
 		$len_enc = strlen($_enc) / 6;
@@ -553,8 +683,11 @@  discard block
 block discarded – undo
553 683
 		for ($i=0; $i<$len_enc; $i++) {
554 684
 			$offset = $i * 6;
555 685
 			$dec = bindec(substr($_enc,$offset,6));
556
-			if ($dec < 40) $dec += 48;
557
-			else $dec += 56;
686
+			if ($dec < 40) {
687
+				$dec += 48;
688
+			} else {
689
+				$dec += 56;
690
+			}
558 691
 			//echo chr($dec)." $dec<br/>";
559 692
 			$itu .= chr($dec);
560 693
 		}
@@ -567,25 +700,41 @@  discard block
 block discarded – undo
567 700
 		}
568 701
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
569 702
 		$lsb = $chksum & 0x0F;
570
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
571
-		else $lsbc = '0';
703
+		if ($lsb >=0 && $lsb <= 15 ) {
704
+			$lsbc = $hex_arr[$lsb];
705
+		} else {
706
+			$lsbc = '0';
707
+		}
572 708
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
573
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
574
-		else $msbc = '0';
709
+		if ($msb >=0 && $msb <= 15 ) {
710
+			$msbc = $hex_arr[$msb];
711
+		} else {
712
+			$msbc = '0';
713
+		}
575 714
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
576 715
 		return $itu;
577 716
 	}
578 717
 
579 718
 	public function parse($buffer) {
580 719
 		$data = $this->process_ais_buf($buffer);
581
-		if (!is_object($data)) return array();
582
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
583
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
720
+		if (!is_object($data)) {
721
+			return array();
722
+		}
723
+		if ($data->lon != 0) {
724
+			$result['longitude'] = $data->lon;
725
+		}
726
+		if ($data->lat != 0) {
727
+			$result['latitude'] = $data->lat;
728
+		}
584 729
 		$result['ident'] = trim($data->name);
585 730
 		$result['timestamp'] = $data->ts;
586 731
 		$result['mmsi'] = $data->mmsi;
587
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
588
-		if ($data->cog != 0) $result['heading'] = $data->cog;
732
+		if ($data->sog != -1.0) {
733
+			$result['speed'] = $data->sog;
734
+		}
735
+		if ($data->cog != 0) {
736
+			$result['heading'] = $data->cog;
737
+		}
589 738
 		/*
590 739
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
591 740
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -595,15 +744,25 @@  discard block
 block discarded – undo
595 744
 
596 745
 	public function mmsitype($mmsi) {
597 746
 		if (strlen($mmsi) == 9) {
598
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
599
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
600
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
601
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
602
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
603
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
604
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
605
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
606
-			else return 'Ship';
747
+			if (substr($mmsi,0,3) == '974') {
748
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
749
+			} elseif (substr($mmsi,0,3) == '972') {
750
+				return 'MOB (Man Overboard) device';
751
+			} elseif (substr($mmsi,0,3) == '970') {
752
+				return 'AIS SART (Search and Rescue Transmitter)';
753
+			} elseif (substr($mmsi,0,3) == '111') {
754
+				return 'SAR (Search and Rescue) aircraft';
755
+			} elseif (substr($mmsi,0,2) == '98') {
756
+				return 'Auxiliary craft associated with a parent ship';
757
+			} elseif (substr($mmsi,0,2) == '99') {
758
+				return 'Aids to Navigation';
759
+			} elseif (substr($mmsi,0,2) == '00') {
760
+				return 'Coastal stations';
761
+			} elseif (substr($mmsi,0,1) == '0') {
762
+				return 'Group of ships';
763
+			} else {
764
+				return 'Ship';
765
+			}
607 766
 		}
608 767
 
609 768
 	
@@ -620,32 +779,61 @@  discard block
 block discarded – undo
620 779
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
621 780
 			return array();
622 781
 		}
623
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
624
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
782
+		if ($data->lon != 0) {
783
+			$result['longitude'] = $data->lon;
784
+		}
785
+		if ($data->lat != 0) {
786
+			$result['latitude'] = $data->lat;
787
+		}
625 788
 		$result['ident'] = trim(str_replace('@','',$data->name));
626 789
 		$result['timestamp'] = $data->ts;
627 790
 		$result['mmsi'] = $data->mmsi;
628
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
791
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
792
+			$result['mmsi'] = '3'.$result['mmsi'];
793
+		}
629 794
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
630
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
631
-		if ($data->heading !== '') $result['heading'] = $data->heading;
632
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
633
-		if ($data->status != '') $result['status'] = $data->status;
634
-		if ($data->statusid !== '') $result['statusid'] = $data->statusid;
635
-		if ($data->type !== '') $result['type'] = $data->type;
636
-		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
637
-		if ($data->imo !== '') $result['imo'] = $data->imo;
638
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
795
+		if ($data->sog != -1.0) {
796
+			$result['speed'] = $data->sog;
797
+		}
798
+		if ($data->heading !== '') {
799
+			$result['heading'] = $data->heading;
800
+		} elseif ($data->cog != 0) {
801
+			$result['heading'] = $data->cog;
802
+		}
803
+		if ($data->status != '') {
804
+			$result['status'] = $data->status;
805
+		}
806
+		if ($data->statusid !== '') {
807
+			$result['statusid'] = $data->statusid;
808
+		}
809
+		if ($data->type !== '') {
810
+			$result['type'] = $data->type;
811
+		}
812
+		if ($data->typeid !== '') {
813
+			$result['typeid'] = $data->typeid;
814
+		}
815
+		if ($data->imo !== '') {
816
+			$result['imo'] = $data->imo;
817
+		}
818
+		if ($data->callsign !== '') {
819
+			$result['callsign'] = trim(str_replace('@','',$data->callsign));
820
+		}
639 821
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
640 822
 			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
641
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
823
+			if ($eta_ts != '') {
824
+				$result['eta_ts'] = $eta_ts;
825
+			}
642 826
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
643 827
 			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
644
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
828
+			if ($eta_ts != '') {
829
+				$result['eta_ts'] = $eta_ts;
830
+			}
645 831
 		}
646 832
 		if ($data->destination != '') {
647 833
 			$dest = trim(str_replace('@','',$data->destination));
648
-			if ($dest != '') $result['destination'] = $dest;
834
+			if ($dest != '') {
835
+				$result['destination'] = $dest;
836
+			}
649 837
 		}
650 838
 		$result['all'] = (array) $data;
651 839
 		/*
Please login to merge, or discard this patch.