Completed
Push — master ( dd5351...9adbe5 )
by Yannick
53:50
created
statistics-sub-menu.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 ?>
38 38
 	</div>
39 39
 <?php 
40
-    if (!isset($year) || (isset($year) && $year == '') && !isset($month) || (isset($month) && $month == '')) {
40
+	if (!isset($year) || (isset($year) && $year == '') && !isset($month) || (isset($month) && $month == '')) {
41 41
 ?>
42 42
 <div class="sub-menu sub-menu-container">
43 43
 	<ul class="nav">
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		    </ul>
96 96
 		</li>
97 97
 		<?php
98
-		    if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
98
+			if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
99 99
 		?>
100 100
 		<li class="dropdown">
101 101
 		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		    </ul>
108 108
 		</li>
109 109
 		<?php
110
-		    }
110
+			}
111 111
 		?>
112 112
 <?php
113 113
 	} elseif ($type == 'marine' || $type == 'tracker') {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	</ul>
128 128
 </div>
129 129
 <?php
130
-    } else {
130
+	} else {
131 131
 ?>
132 132
 <div class="sub-menu sub-menu-container">
133 133
 	<ul class="nav">
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		</li>
190 190
 		-->
191 191
 		<?php
192
-		    if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
192
+			if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
193 193
 		?>
194 194
 		<!--
195 195
 		<li class="dropdown">
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		</li>
204 204
 		-->
205 205
 		<?php
206
-		    }
206
+			}
207 207
 		?>
208 208
 <?php
209 209
 	} elseif ($type == 'marine' || $type == 'tracker') {
@@ -224,5 +224,5 @@  discard block
 block discarded – undo
224 224
 	</ul>
225 225
 </div>
226 226
 <?php
227
-    }
227
+	}
228 228
 ?>
229 229
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +110 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,7 +6,13 @@  discard block
 block discarded – undo
6 6
 	if (!isset($type) || $type != 'satellite') {
7 7
 ?>
8 8
 		<form id="changedate" method="post">
9
-			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" />
9
+			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') {
10
+	echo $year.'-';
11
+}
12
+?><?php if (isset($month) && $month != '') {
13
+	echo $month;
14
+}
15
+?>" />
10 16
 		</form>
11 17
 <?php
12 18
 	}
@@ -38,7 +44,9 @@  discard block
 block discarded – undo
38 44
 						print '<option disabled>──────────</option>';
39 45
 					}
40 46
 					$Stats = new Stats();
41
-					if (!isset($filter_name)) $filter_name = '';
47
+					if (!isset($filter_name)) {
48
+						$filter_name = '';
49
+					}
42 50
 					$airlines = $Stats->getAllAirlineNames($filter_name);
43 51
 					foreach($airlines as $airline) {
44 52
 						if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) {
@@ -67,10 +75,22 @@  discard block
 block discarded – undo
67 75
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
68 76
 		    </a>
69 77
 		    <ul class="dropdown-menu">
70
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Aircraft"); ?></a></li>
71
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Registration"); ?></a></li>
72
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Manufacturer"); ?></a></li>
73
-			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Country"); ?></a></li>
78
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
79
+	echo '/'.$airline_icao;
80
+}
81
+?>"><?php echo _("Aircraft"); ?></a></li>
82
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
83
+	echo '/'.$airline_icao;
84
+}
85
+?>"><?php echo _("Registration"); ?></a></li>
86
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
87
+	echo '/'.$airline_icao;
88
+}
89
+?>"><?php echo _("Manufacturer"); ?></a></li>
90
+			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
91
+	echo '/'.$airline_icao;
92
+}
93
+?>"><?php echo _("Country"); ?></a></li>
74 94
 		    </ul>
75 95
 		</li>
76 96
 		<li class="dropdown">
@@ -81,12 +101,21 @@  discard block
 block discarded – undo
81 101
 <?php
82 102
 		if (!isset($airline_icao) || $airline_icao == 'all') {
83 103
 ?>
84
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline"); ?></a></li>
85
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline by Country"); ?></a></li>
104
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
105
+	echo '/'.$airline_icao;
106
+}
107
+?>"><?php echo _("Airline"); ?></a></li>
108
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
109
+	echo '/'.$airline_icao;
110
+}
111
+?>"><?php echo _("Airline by Country"); ?></a></li>
86 112
 <?php
87 113
 		}
88 114
 ?>
89
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Callsign"); ?></a></li>
115
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
116
+	echo '/'.$airline_icao;
117
+}
118
+?>"><?php echo _("Callsign"); ?></a></li>
90 119
 		    </ul>
91 120
 		</li>
92 121
 		<li class="dropdown">
@@ -94,10 +123,22 @@  discard block
 block discarded – undo
94 123
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
95 124
 		    </a>
96 125
 		    <ul class="dropdown-menu" role="menu">
97
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport"); ?></a></li>
98
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
99
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport"); ?></a></li>
100
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
126
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
127
+	echo '/'.$airline_icao;
128
+}
129
+?>"><?php echo _("Departure Airport"); ?></a></li>
130
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
131
+	echo '/'.$airline_icao;
132
+}
133
+?>"><?php echo _("Departure Airport by Country"); ?></a></li>
134
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
135
+	echo '/'.$airline_icao;
136
+}
137
+?>"><?php echo _("Arrival Airport"); ?></a></li>
138
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
139
+	echo '/'.$airline_icao;
140
+}
141
+?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
101 142
 		    </ul>
102 143
 		</li>
103 144
 		<li class="dropdown">
@@ -105,8 +146,14 @@  discard block
 block discarded – undo
105 146
 		      <?php echo _("Route"); ?> <span class="caret"></span>
106 147
 		    </a>
107 148
 		    <ul class="dropdown-menu" role="menu">
108
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Airport"); ?></a></li>
109
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Waypoint"); ?></a></li>
149
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
150
+	echo '/'.$airline_icao;
151
+}
152
+?>"><?php echo _("Route by Airport"); ?></a></li>
153
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
154
+	echo '/'.$airline_icao;
155
+}
156
+?>"><?php echo _("Route by Waypoint"); ?></a></li>
110 157
 		    </ul>
111 158
 		</li>
112 159
 		<li class="dropdown">
@@ -114,8 +161,14 @@  discard block
 block discarded – undo
114 161
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
115 162
 		    </a>
116 163
 		    <ul class="dropdown-menu" role="menu">
117
-		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Date"); ?></a></li>
118
-			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Time"); ?></a></li>
164
+		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
165
+	echo '/'.$airline_icao;
166
+}
167
+?>"><?php echo _("Date"); ?></a></li>
168
+			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
169
+	echo '/'.$airline_icao;
170
+}
171
+?>"><?php echo _("Time"); ?></a></li>
119 172
 		    </ul>
120 173
 		</li>
121 174
 		<?php
@@ -163,9 +216,18 @@  discard block
 block discarded – undo
163 216
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
164 217
 		    </a>
165 218
 		    <ul class="dropdown-menu">
166
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
167
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
168
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
219
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
220
+	echo '/'.$airline_icao;
221
+}
222
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
223
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
224
+	echo '/'.$airline_icao;
225
+}
226
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
227
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
228
+	echo '/'.$airline_icao;
229
+}
230
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
169 231
 			<!-- <li><a href="<?php print $globalURL; ?>/statistics/country"><?php echo _("Country"); ?></a></li> -->
170 232
 		    </ul>
171 233
 		</li>
@@ -177,12 +239,21 @@  discard block
 block discarded – undo
177 239
 <?php
178 240
 		if (!isset($airline_icao) || $airline_icao == 'all') {
179 241
 ?>
180
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
181
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
242
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
243
+	echo '/'.$airline_icao;
244
+}
245
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
246
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
247
+	echo '/'.$airline_icao;
248
+}
249
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
182 250
 <?php
183 251
 		}
184 252
 ?>
185
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
253
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
254
+	echo '/'.$airline_icao;
255
+}
256
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
186 257
 		    </ul>
187 258
 		</li>
188 259
 		<li class="dropdown">
@@ -190,10 +261,22 @@  discard block
 block discarded – undo
190 261
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
191 262
 		    </a>
192 263
 		    <ul class="dropdown-menu" role="menu">
193
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
194
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
195
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
196
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
264
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
265
+	echo '/'.$airline_icao;
266
+}
267
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
268
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
269
+	echo '/'.$airline_icao;
270
+}
271
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
272
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
273
+	echo '/'.$airline_icao;
274
+}
275
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
276
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
277
+	echo '/'.$airline_icao;
278
+}
279
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
197 280
 		    </ul>
198 281
 		</li>
199 282
 		<!--
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 					$Spotter = new Spotter();
29 29
 					$alliances = $Spotter->getAllAllianceNames();
30 30
 					if (!empty($alliances)) {
31
-						foreach($alliances as $alliance) {
32
-							if (isset($airline_icao) && str_replace('_',' ',str_replace('alliance_','',$airline_icao)) == $alliance['alliance']) {
33
-								print '<option value="alliance_'.str_replace(' ','_',$alliance['alliance']).'" selected>'.$alliance['alliance'].'</option>';
31
+						foreach ($alliances as $alliance) {
32
+							if (isset($airline_icao) && str_replace('_', ' ', str_replace('alliance_', '', $airline_icao)) == $alliance['alliance']) {
33
+								print '<option value="alliance_'.str_replace(' ', '_', $alliance['alliance']).'" selected>'.$alliance['alliance'].'</option>';
34 34
 							} else {
35
-								print '<option value="alliance_'.str_replace(' ','_',$alliance['alliance']).'">'.$alliance['alliance'].'</option>';
35
+								print '<option value="alliance_'.str_replace(' ', '_', $alliance['alliance']).'">'.$alliance['alliance'].'</option>';
36 36
 							}
37 37
 						}
38 38
 						print '<option disabled>──────────</option>';
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 					$Stats = new Stats();
41 41
 					if (!isset($filter_name)) $filter_name = '';
42 42
 					$airlines = $Stats->getAllAirlineNames($filter_name);
43
-					foreach($airlines as $airline) {
43
+					foreach ($airlines as $airline) {
44 44
 						if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) {
45 45
 							print '<option value="'.$airline['airline_icao'].'" selected>'.$airline['airline_name'].'</option>';
46 46
 						} else {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	if (!isset($type) || $type == 'aircraft') {
64 64
 ?>
65 65
 		<li class="dropdown">
66
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" >
66
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" >
67 67
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
68 68
 		    </a>
69 69
 		    <ul class="dropdown-menu">
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		    </ul>
75 75
 		</li>
76 76
 		<li class="dropdown">
77
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
77
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#">
78 78
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
79 79
 		    </a>
80 80
 		    <ul class="dropdown-menu" role="menu">
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		    </ul>
91 91
 		</li>
92 92
 		<li class="dropdown">
93
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
93
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
94 94
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
95 95
 		    </a>
96 96
 		    <ul class="dropdown-menu" role="menu">
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		    </ul>
102 102
 		</li>
103 103
 		<li class="dropdown">
104
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
104
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#">
105 105
 		      <?php echo _("Route"); ?> <span class="caret"></span>
106 106
 		    </a>
107 107
 		    <ul class="dropdown-menu" role="menu">
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		    </ul>
111 111
 		</li>
112 112
 		<li class="dropdown">
113
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
113
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
114 114
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
115 115
 		    </a>
116 116
 		    <ul class="dropdown-menu" role="menu">
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		    if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
123 123
 		?>
124 124
 		<li class="dropdown">
125
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
125
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#">
126 126
 		      <?php echo _("Fatalities"); ?> <span class="caret"></span>
127 127
 		    </a>
128 128
 		    <ul class="dropdown-menu" role="menu">
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	} elseif ($type == 'marine' || $type == 'tracker') {
138 138
 ?>
139 139
 		<li class="dropdown">
140
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
140
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
141 141
 			<?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
142 142
 		    </a>
143 143
 		    <ul class="dropdown-menu" role="menu">
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	if (!isset($type) || $type == 'aircraft') {
162 162
 ?>
163 163
 		<li class="dropdown">
164
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" >
164
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" >
165 165
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
166 166
 		    </a>
167 167
 		    <ul class="dropdown-menu">
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		    </ul>
173 173
 		</li>
174 174
 		<li class="dropdown">
175
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
175
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#">
176 176
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
177 177
 		    </a>
178 178
 		    <ul class="dropdown-menu" role="menu">
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		    </ul>
189 189
 		</li>
190 190
 		<li class="dropdown">
191
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
191
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
192 192
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
193 193
 		    </a>
194 194
 		    <ul class="dropdown-menu" role="menu">
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		</li>
201 201
 		<!--
202 202
 		<li class="dropdown">
203
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
203
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#">
204 204
 		      <?php echo _("Route"); ?> <span class="caret"></span>
205 205
 		    </a>
206 206
 		    <ul class="dropdown-menu" role="menu">
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		-->
212 212
 		<!--
213 213
 		<li class="dropdown">
214
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
214
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
215 215
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
216 216
 		    </a>
217 217
 		    <ul class="dropdown-menu" role="menu">
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		?>
226 226
 		<!--
227 227
 		<li class="dropdown">
228
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
228
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#">
229 229
 		      <?php echo _("Fatalities"); ?> <span class="caret"></span>
230 230
 		    </a>
231 231
 		    <ul class="dropdown-menu" role="menu">
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	} elseif ($type == 'marine' || $type == 'tracker') {
242 242
 ?>
243 243
 		<li class="dropdown">
244
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
244
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
245 245
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
246 246
 		    </a>
247 247
 		    <ul class="dropdown-menu" role="menu">
Please login to merge, or discard this patch.
atc-data.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@
 block discarded – undo
40 40
 //print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41 41
 print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
42 42
 if ($spotter_item['atc_range'] > 0) {
43
-    print '<div><span>'._("Range").'</span>';
44
-    print $spotter_item['atc_range'];
45
-    print '</div>';
43
+	print '<div><span>'._("Range").'</span>';
44
+	print $spotter_item['atc_range'];
45
+	print '</div>';
46 46
 }
47 47
 print '</div>';
48 48
 if ($spotter_item['info'] != '') {
49
-    print '<div class="notamtext"><span>'._("Info").'</span>';
50
-    print $spotter_item['info'];
51
-    print '</div>';
49
+	print '<div class="notamtext"><span>'._("Info").'</span>';
50
+	print $spotter_item['info'];
51
+	print '</div>';
52 52
 }
53 53
 print '</div>';
54 54
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 $ATC = new ATC();
6 6
 
7 7
 if (isset($_GET['atcid'])) {
8
-	$atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT);
9
-	$atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING);
8
+	$atcid = filter_input(INPUT_GET, 'atcid', FILTER_SANITIZE_NUMBER_INT);
9
+	$atcident = filter_input(INPUT_GET, 'atcident', FILTER_SANITIZE_STRING);
10 10
 	$atc_data = $ATC->getById($atcid);
11 11
 	if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident);
12 12
  ?>
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 print '</div>';
39 39
 
40 40
 //print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41
-print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
41
+print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 3).', '.round($spotter_item['longitude'], 3).'</div>';
42 42
 if ($spotter_item['atc_range'] > 0) {
43 43
     print '<div><span>'._("Range").'</span>';
44 44
     print $spotter_item['atc_range'];
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@
 block discarded – undo
8 8
 	$atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT);
9 9
 	$atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING);
10 10
 	$atc_data = $ATC->getById($atcid);
11
-	if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident);
11
+	if (!isset($atc_data[0])) {
12
+		$atc_data = $ATC->getByIdent($atcident);
13
+	}
12 14
  ?>
13 15
 <div class="alldetails">
14 16
 <button type="button" class="close">&times;</button>
Please login to merge, or discard this patch.
require/class.Elevation.php 3 patches
Doc Comments   +11 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,6 +52,10 @@  discard block
 block discarded – undo
52 52
 		$this->openedFiles = [];
53 53
 	}
54 54
 
55
+	/**
56
+	 * @param double $row
57
+	 * @param double $column
58
+	 */
55 59
 	private function getElevationAtPosition($fileName, $row, $column) {
56 60
 		if (!array_key_exists($fileName, $this->openedFiles)) {
57 61
 			if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) {
@@ -85,7 +89,7 @@  discard block
 block discarded – undo
85 89
 	 * @param float $lon
86 90
 	 * @param null  $fName
87 91
 	 *
88
-	 * @return mixed
92
+	 * @return double
89 93
 	 * @throws \Exception
90 94
 	 */
91 95
 	public function getElevation($lat, $lon, &$fName = null) {
@@ -142,6 +146,9 @@  discard block
 block discarded – undo
142 146
 		return $zN;
143 147
 	}
144 148
 
149
+	/**
150
+	 * @param integer $numPrefix
151
+	 */
145 152
 	private function getDeg($deg, $numPrefix) {
146 153
 		$deg = abs($deg);
147 154
 		$d   = floor($deg);     // round degrees
@@ -156,6 +163,9 @@  discard block
 block discarded – undo
156 163
 		return $d;
157 164
 	}
158 165
 
166
+	/**
167
+	 * @param double $deg
168
+	 */
159 169
 	private function getSec($deg) {
160 170
 		$deg = abs($deg);
161 171
 		$sec = round($deg * 3600, 4);
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@  discard block
 block discarded – undo
28 28
 	private $openedFiles = [];
29 29
 
30 30
 	public function __construct($htgFilesDestination = '', $resolution = 3) {
31
-		if ($htgFilesDestination == '') $htgFilesDestination = dirname(__FILE__).'/../data/';
31
+		if ($htgFilesDestination == '') {
32
+			$htgFilesDestination = dirname(__FILE__).'/../data/';
33
+		}
32 34
 		$this->htgFilesDestination = $htgFilesDestination;
33 35
 		$this->resolution          = $resolution;
34 36
 		switch ($resolution) {
@@ -171,16 +173,26 @@  discard block
 block discarded – undo
171 173
 		$fileName  = "N{$N}E{$E}.hgt";
172 174
 		if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) {
173 175
 			$Common = new Common();
174
-			if ($debug) echo 'Downloading '.$fileName.'.gz ...';
176
+			if ($debug) {
177
+				echo 'Downloading '.$fileName.'.gz ...';
178
+			}
175 179
 			$Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
176 180
 			if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz')) {
177
-				if ($debug) echo "File '{$fileName}.gz' not exists.";
181
+				if ($debug) {
182
+					echo "File '{$fileName}.gz' not exists.";
183
+				}
178 184
 				return false;
179 185
 			}
180
-			if ($debug) echo 'Done'."\n";
181
-			if ($debug) echo 'Decompress '.$fileName.' ....';
186
+			if ($debug) {
187
+				echo 'Done'."\n";
188
+			}
189
+			if ($debug) {
190
+				echo 'Decompress '.$fileName.' ....';
191
+			}
182 192
 			$Common->gunzip($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName);
183
-			if ($debug) echo 'Done'."\n";
193
+			if ($debug) {
194
+				echo 'Done'."\n";
195
+			}
184 196
 			unlink($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
185 197
 		}
186 198
 		return true;
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			default:
42 42
 				throw new \Exception("bad resolution can be only one of 1,3");
43 43
 		}
44
-		register_shutdown_function(function () {
44
+		register_shutdown_function(function() {
45 45
 			$this->closeAllFiles();
46 46
 		});
47 47
 	}
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 
56 56
 	private function getElevationAtPosition($fileName, $row, $column) {
57 57
 		if (!array_key_exists($fileName, $this->openedFiles)) {
58
-			if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) {
58
+			if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName)) {
59 59
 				throw new \Exception("File '{$fileName}' not exists.");
60 60
 			}
61
-			$file = fopen($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName, "r");
61
+			$file = fopen($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName, "r");
62 62
 			if ($file === false) {
63 63
 				throw new \Exception("Cant open file '{$fileName}' for reading.");
64 64
 			}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			throw new \Exception("Not implemented yet");
73 73
 		}
74 74
 		$aRow     = $this->measPerDeg - $row;
75
-		$position = ($this->measPerDeg * ($aRow - 1)) + $column;
75
+		$position = ($this->measPerDeg*($aRow - 1)) + $column;
76 76
 		$position *= 2;
77 77
 		fseek($file, $position);
78 78
 		$short  = fread($file, 2);
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 		$latSec = $this->getSec($lat);
101 101
 		$lonSec = $this->getSec($lon);
102 102
 
103
-		$Xn = round($latSec / $this->resolution, 3);
104
-		$Yn = round($lonSec / $this->resolution, 3);
103
+		$Xn = round($latSec/$this->resolution, 3);
104
+		$Yn = round($lonSec/$this->resolution, 3);
105 105
 
106 106
 		$a1 = round($Xn);
107 107
 		$a2 = round($Yn);
@@ -133,55 +133,55 @@  discard block
 block discarded – undo
133 133
 		$b3 = $this->getElevationAtPosition($fName, $b1, $b2);
134 134
 		$c3 = $this->getElevationAtPosition($fName, $c1, $c2);
135 135
 
136
-		$n1 = ($c2 - $a2) * ($b3 - $a3) - ($c3 - $a3) * ($b2 - $a2);
137
-		$n2 = ($c3 - $a3) * ($b1 - $a1) - ($c1 - $a1) * ($b3 - $a3);
138
-		$n3 = ($c1 - $a1) * ($b2 - $a2) - ($c2 - $a2) * ($b1 - $a1);
136
+		$n1 = ($c2 - $a2)*($b3 - $a3) - ($c3 - $a3)*($b2 - $a2);
137
+		$n2 = ($c3 - $a3)*($b1 - $a1) - ($c1 - $a1)*($b3 - $a3);
138
+		$n3 = ($c1 - $a1)*($b2 - $a2) - ($c2 - $a2)*($b1 - $a1);
139 139
 
140
-		$d  = -$n1 * $a1 - $n2 * $a2 - $n3 * $a3;
141
-		$zN = (-$n1 * $Xn - $n2 * $Yn - $d) / $n3;
140
+		$d  = -$n1*$a1 - $n2*$a2 - $n3*$a3;
141
+		$zN = (-$n1*$Xn - $n2*$Yn - $d)/$n3;
142 142
 
143 143
 		return $zN;
144 144
 	}
145 145
 
146 146
 	private function getDeg($deg, $numPrefix) {
147 147
 		$deg = abs($deg);
148
-		$d   = floor($deg);     // round degrees
148
+		$d   = floor($deg); // round degrees
149 149
 		if ($numPrefix >= 3) {
150 150
 			if ($d < 100) {
151
-				$d = '0' . $d;
151
+				$d = '0'.$d;
152 152
 			}
153 153
 		} // pad with leading zeros
154 154
 		if ($d < 10) {
155
-			$d = '0' . $d;
155
+			$d = '0'.$d;
156 156
 		}
157 157
 		return $d;
158 158
 	}
159 159
 
160 160
 	private function getSec($deg) {
161 161
 		$deg = abs($deg);
162
-		$sec = round($deg * 3600, 4);
163
-		$m   = fmod(floor($sec / 60), 60);
162
+		$sec = round($deg*3600, 4);
163
+		$m   = fmod(floor($sec/60), 60);
164 164
 		$s   = round(fmod($sec, 60), 4);
165
-		return ($m * 60) + $s;
165
+		return ($m*60) + $s;
166 166
 	}
167 167
 
168
-	public function download($lat,$lon, $debug = false) {
168
+	public function download($lat, $lon, $debug = false) {
169 169
 		$N      = $this->getDeg($lat, 2);
170 170
 		$E      = $this->getDeg($lon, 3);
171
-		$fileName  = "N{$N}E{$E}.hgt";
172
-		if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) {
171
+		$fileName = "N{$N}E{$E}.hgt";
172
+		if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName)) {
173 173
 			$Common = new Common();
174 174
 			if ($debug) echo 'Downloading '.$fileName.'.gz ...';
175
-			$Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
176
-			if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz')) {
175
+			$Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz', $this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz');
176
+			if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz')) {
177 177
 				if ($debug) echo "File '{$fileName}.gz' not exists.";
178 178
 				return false;
179 179
 			}
180 180
 			if ($debug) echo 'Done'."\n";
181 181
 			if ($debug) echo 'Decompress '.$fileName.' ....';
182
-			$Common->gunzip($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName);
182
+			$Common->gunzip($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz', $this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName);
183 183
 			if ($debug) echo 'Done'."\n";
184
-			unlink($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
184
+			unlink($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz');
185 185
 		}
186 186
 		return true;
187 187
 	}
@@ -194,22 +194,22 @@  discard block
 block discarded – undo
194 194
 		try {
195 195
 			$sth = $db->prepare($query);
196 196
 			$sth->execute($query_values);
197
-		} catch(PDOException $e) {
197
+		} catch (PDOException $e) {
198 198
 			return "error : ".$e->getMessage();
199 199
 		}
200 200
 		while ($data = $sth->fetch(PDO::FETCH_ASSOC)) {
201
-			$this->download($data['latitude'],$data['longitude'],true);
201
+			$this->download($data['latitude'], $data['longitude'], true);
202 202
 		}
203 203
 		$query = 'SELECT latitude, longitude FROM tracker_output WHERE latitude <> 0 AND longitude <> 0 ORDER BY date DESC LIMIT 10';
204 204
 		$query_values = array();
205 205
 		try {
206 206
 			$sth = $db->prepare($query);
207 207
 			$sth->execute($query_values);
208
-		} catch(PDOException $e) {
208
+		} catch (PDOException $e) {
209 209
 			return "error : ".$e->getMessage();
210 210
 		}
211 211
 		while ($data = $sth->fetch(PDO::FETCH_ASSOC)) {
212
-			$this->download($data['latitude'],$data['longitude'],true);
212
+			$this->download($data['latitude'], $data['longitude'], true);
213 213
 		}
214 214
 	}
215 215
 }
Please login to merge, or discard this patch.
require/class.Common.php 4 patches
Doc Comments   +15 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,6 +90,10 @@  discard block
 block discarded – undo
90 90
 		return strlen($headerLine); // Needed by curl
91 91
 	}
92 92
 
93
+	/**
94
+	 * @param string $url
95
+	 * @param string $file
96
+	 */
93 97
 	public static function download($url, $file, $referer = '') {
94 98
 		global $globalDebug;
95 99
 		$fp = fopen($file, 'w');
@@ -106,6 +110,9 @@  discard block
 block discarded – undo
106 110
 		fclose($fp);
107 111
 	}
108 112
 
113
+	/**
114
+	 * @param string $in_file
115
+	 */
109 116
 	public static function gunzip($in_file,$out_file_name = '') {
110 117
 		//echo $in_file.' -> '.$out_file_name."\n";
111 118
 		$buffer_size = 4096; // read 4kb at a time
@@ -211,7 +218,7 @@  discard block
 block discarded – undo
211 218
 	* Check is distance realistic
212 219
 	* @param int $timeDifference the time between the reception of both messages
213 220
 	* @param float $distance distance covered
214
-	* @return whether distance is realistic
221
+	* @return boolean distance is realistic
215 222
 	*/
216 223
 	public function withinThreshold ($timeDifference, $distance) {
217 224
 		$x = abs($timeDifference);
@@ -234,6 +241,9 @@  discard block
 block discarded – undo
234 241
 	}
235 242
 
236 243
 
244
+	/**
245
+	 * @param string $latlong
246
+	 */
237 247
 	public function convertDec($dms,$latlong) {
238 248
 		if ($latlong == 'latitude') {
239 249
 			$deg = substr($dms, 0, 2);
@@ -245,6 +255,9 @@  discard block
 block discarded – undo
245 255
 		return $deg+(($min*60)/3600);
246 256
 	}
247 257
 	
258
+	/**
259
+	 * @param string $latlong
260
+	 */
248 261
 	public function convertDM($coord,$latlong) {
249 262
 		if ($latlong == 'latitude') {
250 263
 			if ($coord < 0) $NSEW = 'S';
@@ -382,7 +395,7 @@  discard block
 block discarded – undo
382 395
 	/**
383 396
 	* Returns list of available locales
384 397
 	*
385
-	* @return array
398
+	* @return string[]
386 399
 	 */
387 400
 	public function listLocaleDir()
388 401
 	{
Please login to merge, or discard this patch.
Braces   +98 added lines, -44 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
 	private function curlResponseHeaderCallback($ch, $headerLine) {
86 89
 		//global $cookies;
87 90
 		$cookies = array();
88
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
89
-			$cookies[] = $cookie;
91
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
92
+					$cookies[] = $cookie;
93
+		}
90 94
 		return strlen($headerLine); // Needed by curl
91 95
 	}
92 96
 
@@ -97,11 +101,15 @@  discard block
 block discarded – undo
97 101
 		curl_setopt($ch, CURLOPT_URL, $url);
98 102
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
99 103
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
100
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
104
+		if ($referer != '') {
105
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
106
+		}
101 107
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
102 108
 		curl_setopt($ch, CURLOPT_FILE, $fp);
103 109
 		curl_exec($ch);
104
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
110
+		if (curl_errno($ch) && $globalDebug) {
111
+			echo 'Download error: '.curl_error($ch);
112
+		}
105 113
 		curl_close($ch);
106 114
 		fclose($fp);
107 115
 	}
@@ -109,12 +117,16 @@  discard block
 block discarded – undo
109 117
 	public static function gunzip($in_file,$out_file_name = '') {
110 118
 		//echo $in_file.' -> '.$out_file_name."\n";
111 119
 		$buffer_size = 4096; // read 4kb at a time
112
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
120
+		if ($out_file_name == '') {
121
+			$out_file_name = str_replace('.gz', '', $in_file);
122
+		}
113 123
 		if ($in_file != '' && file_exists($in_file)) {
114 124
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
115
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
116
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
117
-			else {
125
+			if (function_exists('gzopen')) {
126
+				$file = gzopen($in_file,'rb');
127
+			} elseif (function_exists('gzopen64')) {
128
+				$file = gzopen64($in_file,'rb');
129
+			} else {
118 130
 				echo 'gzopen not available';
119 131
 				die;
120 132
 			}
@@ -130,11 +142,14 @@  discard block
 block discarded – undo
130 142
 	public static function bunzip2($in_file,$out_file_name = '') {
131 143
 		//echo $in_file.' -> '.$out_file_name."\n";
132 144
 		$buffer_size = 4096; // read 4kb at a time
133
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
145
+		if ($out_file_name == '') {
146
+			$out_file_name = str_replace('.bz2', '', $in_file);
147
+		}
134 148
 		if ($in_file != '' && file_exists($in_file)) {
135 149
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
136
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
137
-			else {
150
+			if (function_exists('bzopen')) {
151
+				$file = bzopen($in_file,'rb');
152
+			} else {
138 153
 				echo 'bzopen not available';
139 154
 				die;
140 155
 			}
@@ -153,10 +168,16 @@  discard block
 block discarded – undo
153 168
 	* @return Array array of the tables in HTML page
154 169
 	*/
155 170
 	public function table2array($data) {
156
-		if (!is_string($data)) return array();
157
-		if ($data == '') return array();
171
+		if (!is_string($data)) {
172
+			return array();
173
+		}
174
+		if ($data == '') {
175
+			return array();
176
+		}
158 177
 		$html = str_get_html($data);
159
-		if ($html === false) return array();
178
+		if ($html === false) {
179
+			return array();
180
+		}
160 181
 		$tabledata=array();
161 182
 		foreach($html->find('tr') as $element)
162 183
 		{
@@ -191,7 +212,9 @@  discard block
 block discarded – undo
191 212
 	*/
192 213
 	public function text2array($data) {
193 214
 		$html = str_get_html($data);
194
-		if ($html === false) return array();
215
+		if ($html === false) {
216
+			return array();
217
+		}
195 218
 		$tabledata=array();
196 219
 		foreach($html->find('p') as $element)
197 220
 		{
@@ -212,7 +235,9 @@  discard block
 block discarded – undo
212 235
 	* @return Float Distance in $unit
213 236
 	*/
214 237
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
215
-		if ($lat == $latc && $lon == $lonc) return 0;
238
+		if ($lat == $latc && $lon == $lonc) {
239
+			return 0;
240
+		}
216 241
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
217 242
 		if ($unit == "km") {
218 243
 			return round($dist * 1.609344);
@@ -236,10 +261,16 @@  discard block
 block discarded – undo
236 261
 	public function withinThreshold ($timeDifference, $distance) {
237 262
 		$x = abs($timeDifference);
238 263
 		$d = abs($distance);
239
-		if ($x == 0 || $d == 0) return true;
264
+		if ($x == 0 || $d == 0) {
265
+			return true;
266
+		}
240 267
 		// may be due to Internet jitter; distance is realistic
241
-		if ($x < 0.7 && $d < 2000) return true;
242
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
268
+		if ($x < 0.7 && $d < 2000) {
269
+			return true;
270
+		} else {
271
+			return $d/$x < 1500*0.27778;
272
+		}
273
+		// 1500 km/h max
243 274
 	}
244 275
 
245 276
 
@@ -267,11 +298,17 @@  discard block
 block discarded – undo
267 298
 	
268 299
 	public function convertDM($coord,$latlong) {
269 300
 		if ($latlong == 'latitude') {
270
-			if ($coord < 0) $NSEW = 'S';
271
-			else $NSEW = 'N';
301
+			if ($coord < 0) {
302
+				$NSEW = 'S';
303
+			} else {
304
+				$NSEW = 'N';
305
+			}
272 306
 		} else {
273
-			if ($coord < 0) $NSEW = 'W';
274
-			else $NSEW = 'E';
307
+			if ($coord < 0) {
308
+				$NSEW = 'W';
309
+			} else {
310
+				$NSEW = 'E';
311
+			}
275 312
 		}
276 313
 		$coord = abs($coord);
277 314
 		$deg = floor($coord);
@@ -314,7 +351,9 @@  discard block
 block discarded – undo
314 351
 	public function hex2str($hex) {
315 352
 		$str = '';
316 353
 		$hexln = strlen($hex);
317
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
354
+		for($i=0;$i<$hexln;$i+=2) {
355
+			$str .= chr(hexdec(substr($hex,$i,2)));
356
+		}
318 357
 		return $str;
319 358
 	}
320 359
 	
@@ -351,8 +390,11 @@  discard block
 block discarded – undo
351 390
 		$b = $lat2 - $lat1;
352 391
 		$c = -($a*$lat1+$b*$lon1);
353 392
 		$d = $a*$lat3+$b*$lon3+$c;
354
-		if ($d > -$approx && $d < $approx) return true;
355
-		else return false;
393
+		if ($d > -$approx && $d < $approx) {
394
+			return true;
395
+		} else {
396
+			return false;
397
+		}
356 398
 	}
357 399
 	
358 400
 	public function array_merge_noappend() {
@@ -411,7 +453,9 @@  discard block
 block discarded – undo
411 453
 			return $result;
412 454
 		}
413 455
 		$handle = @opendir('./locale');
414
-		if ($handle === false) return $result;
456
+		if ($handle === false) {
457
+			return $result;
458
+		}
415 459
 		while (false !== ($file = readdir($handle))) {
416 460
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
417 461
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -478,8 +522,9 @@  discard block
 block discarded – undo
478 522
 		$error = false; 
479 523
 		if ($fp_out = gzopen($dest, $mode)) { 
480 524
 			if ($fp_in = fopen($source,'rb')) { 
481
-				while (!feof($fp_in)) 
482
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
525
+				while (!feof($fp_in)) {
526
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
527
+				}
483 528
 				fclose($fp_in); 
484 529
 			} else {
485 530
 				$error = true; 
@@ -488,14 +533,17 @@  discard block
 block discarded – undo
488 533
 		} else {
489 534
 			$error = true; 
490 535
 		}
491
-		if ($error)
492
-			return false; 
493
-		else
494
-			return $dest; 
536
+		if ($error) {
537
+					return false;
538
+		} else {
539
+					return $dest;
540
+		}
495 541
 	} 
496 542
 	
497 543
 	public function remove_accents($string) {
498
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
544
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
545
+			return $string;
546
+		}
499 547
 		$chars = array(
500 548
 		    // Decompositions for Latin-1 Supplement
501 549
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -619,7 +667,9 @@  discard block
 block discarded – undo
619 667
 		$ip = gethostbyname($host);
620 668
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
621 669
 		$r = @socket_connect($s, $ip, $port);
622
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
670
+		if (!socket_set_nonblock($s)) {
671
+			echo "Unable to set nonblock on socket\n";
672
+		}
623 673
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
624 674
 			return $s;
625 675
 		}
@@ -664,18 +714,22 @@  discard block
 block discarded – undo
664 714
 		//NOTE: use a trailing slash for folders!!!
665 715
 		//see http://bugs.php.net/bug.php?id=27609
666 716
 		//see http://bugs.php.net/bug.php?id=30931
667
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
717
+		if ($path{strlen($path)-1}=='/') {
718
+			// recursively return a temporary file path
668 719
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
669
-		else if (is_dir($path))
670
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
720
+		} else if (is_dir($path)) {
721
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
722
+		}
671 723
 		// check tmp file for read/write capabilities
672 724
 		$rm = file_exists($path);
673 725
 		$f = @fopen($path, 'a');
674
-		if ($f===false)
675
-			return false;
726
+		if ($f===false) {
727
+					return false;
728
+		}
676 729
 		fclose($f);
677
-		if (!$rm)
678
-			unlink($path);
730
+		if (!$rm) {
731
+					unlink($path);
732
+		}
679 733
 		return true;
680 734
 	}
681 735
 }
Please login to merge, or discard this patch.
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 	//protected $cookies = array();
8 8
 	
9 9
 	/**
10
-	* Get data from form result
11
-	* @param String $url form URL
12
-	* @param String $type type of submit form method (get or post)
13
-	* @param String|Array $data values form post method
14
-	* @param Array $headers header to submit with the form
15
-	* @return String the result
16
-	*/
10
+	 * Get data from form result
11
+	 * @param String $url form URL
12
+	 * @param String $type type of submit form method (get or post)
13
+	 * @param String|Array $data values form post method
14
+	 * @param Array $headers header to submit with the form
15
+	 * @return String the result
16
+	 */
17 17
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 	}
149 149
 
150 150
 	/**
151
-	* Convert a HTML table to an array
152
-	* @param String $data HTML page
153
-	* @return Array array of the tables in HTML page
154
-	*/
151
+	 * Convert a HTML table to an array
152
+	 * @param String $data HTML page
153
+	 * @return Array array of the tables in HTML page
154
+	 */
155 155
 	public function table2array($data) {
156 156
 		if (!is_string($data)) return array();
157 157
 		if ($data == '') return array();
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 	}
186 186
 	
187 187
 	/**
188
-	* Convert <p> part of a HTML page to an array
189
-	* @param String $data HTML page
190
-	* @return Array array of the <p> in HTML page
191
-	*/
188
+	 * Convert <p> part of a HTML page to an array
189
+	 * @param String $data HTML page
190
+	 * @return Array array of the <p> in HTML page
191
+	 */
192 192
 	public function text2array($data) {
193 193
 		$html = str_get_html($data);
194 194
 		if ($html === false) return array();
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 	}
204 204
 
205 205
 	/**
206
-	* Give distance between 2 coordonnates
207
-	* @param Float $lat latitude of first point
208
-	* @param Float $lon longitude of first point
209
-	* @param Float $latc latitude of second point
210
-	* @param Float $lonc longitude of second point
211
-	* @param String $unit km else no unit used
212
-	* @return Float Distance in $unit
213
-	*/
206
+	 * Give distance between 2 coordonnates
207
+	 * @param Float $lat latitude of first point
208
+	 * @param Float $lon longitude of first point
209
+	 * @param Float $latc latitude of second point
210
+	 * @param Float $lonc longitude of second point
211
+	 * @param String $unit km else no unit used
212
+	 * @return Float Distance in $unit
213
+	 */
214 214
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
215 215
 		if ($lat == $latc && $lon == $lonc) return 0;
216 216
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
@@ -228,25 +228,25 @@  discard block
 block discarded – undo
228 228
 	}
229 229
 
230 230
 	/**
231
-	* Give plunge between 2 altitudes and distance
232
-	* @param Float $initial_altitude altitude of first point in m
233
-	* @param Float $final_altitude altitude of second point in m
234
-	* @param String $distance distance between two points in m
235
-	* @return Float plunge
236
-	*/
231
+	 * Give plunge between 2 altitudes and distance
232
+	 * @param Float $initial_altitude altitude of first point in m
233
+	 * @param Float $final_altitude altitude of second point in m
234
+	 * @param String $distance distance between two points in m
235
+	 * @return Float plunge
236
+	 */
237 237
 	public function plunge($initial_altitude,$final_altitude,$distance) {
238 238
 		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
239 239
 		return $plunge;
240 240
 	}
241 241
 
242 242
 	/**
243
-	* Give azimuth between 2 coordonnates
244
-	* @param Float $lat latitude of first point
245
-	* @param Float $lon longitude of first point
246
-	* @param Float $latc latitude of second point
247
-	* @param Float $lonc longitude of second point
248
-	* @return Float Azimuth
249
-	*/
243
+	 * Give azimuth between 2 coordonnates
244
+	 * @param Float $lat latitude of first point
245
+	 * @param Float $lon longitude of first point
246
+	 * @param Float $latc latitude of second point
247
+	 * @param Float $lonc longitude of second point
248
+	 * @return Float Azimuth
249
+	 */
250 250
 	public function azimuth($lat, $lon, $latc, $lonc) {
251 251
 		$azimuth = rad2deg(atan(($latc - $lat)/($lonc - $lon)));
252 252
 		return 360+$azimuth;
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 	
255 255
 	
256 256
 	/**
257
-	* Check is distance realistic
258
-	* @param int $timeDifference the time between the reception of both messages
259
-	* @param float $distance distance covered
260
-	* @return whether distance is realistic
261
-	*/
257
+	 * Check is distance realistic
258
+	 * @param int $timeDifference the time between the reception of both messages
259
+	 * @param float $distance distance covered
260
+	 * @return whether distance is realistic
261
+	 */
262 262
 	public function withinThreshold ($timeDifference, $distance) {
263 263
 		$x = abs($timeDifference);
264 264
 		$d = abs($distance);
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	}
277 277
 
278 278
 	public function isInteger($input){
279
-	    return(ctype_digit(strval($input)));
279
+		return(ctype_digit(strval($input)));
280 280
 	}
281 281
 
282 282
 
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
 	}
308 308
 	
309 309
 	/**
310
-	* Copy folder contents
311
-	* @param       string   $source    Source path
312
-	* @param       string   $dest      Destination path
313
-	* @return      bool     Returns true on success, false on failure
314
-	*/
310
+	 * Copy folder contents
311
+	 * @param       string   $source    Source path
312
+	 * @param       string   $dest      Destination path
313
+	 * @return      bool     Returns true on success, false on failure
314
+	 */
315 315
 	public function xcopy($source, $dest)
316 316
 	{
317 317
 		$files = glob($source.'*.*');
@@ -323,20 +323,20 @@  discard block
 block discarded – undo
323 323
 	}
324 324
 	
325 325
 	/**
326
-	* Check if an url exist
327
-	* @param	String $url url to check
328
-	* @return	bool Return true on succes false on failure
329
-	*/
326
+	 * Check if an url exist
327
+	 * @param	String $url url to check
328
+	 * @return	bool Return true on succes false on failure
329
+	 */
330 330
 	public function urlexist($url){
331 331
 		$headers=get_headers($url);
332 332
 		return stripos($headers[0],"200 OK")?true:false;
333 333
 	}
334 334
 	
335 335
 	/**
336
-	* Convert hexa to string
337
-	* @param	String $hex data in hexa
338
-	* @return	String Return result
339
-	*/
336
+	 * Convert hexa to string
337
+	 * @param	String $hex data in hexa
338
+	 * @return	String Return result
339
+	 */
340 340
 	public function hex2str($hex) {
341 341
 		$str = '';
342 342
 		$hexln = strlen($hex);
@@ -345,10 +345,10 @@  discard block
 block discarded – undo
345 345
 	}
346 346
 	
347 347
 	/**
348
-	* Convert hexa color to rgb
349
-	* @param	String $hex data in hexa
350
-	* @return	String Return result
351
-	*/
348
+	 * Convert hexa color to rgb
349
+	 * @param	String $hex data in hexa
350
+	 * @return	String Return result
351
+	 */
352 352
 	public function hex2rgb($hex) {
353 353
 		$hex = str_replace('#','',$hex);
354 354
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
 	}
427 427
 	
428 428
 	/**
429
-	* Returns list of available locales
430
-	*
431
-	* @return array
429
+	 * Returns list of available locales
430
+	 *
431
+	 * @return array
432 432
 	 */
433 433
 	public function listLocaleDir()
434 434
 	{
@@ -527,100 +527,100 @@  discard block
 block discarded – undo
527 527
 	public function remove_accents($string) {
528 528
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
529 529
 		$chars = array(
530
-		    // Decompositions for Latin-1 Supplement
531
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
532
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
533
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
534
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
535
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
536
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
537
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
538
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
539
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
540
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
541
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
542
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
543
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
544
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
545
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
546
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
547
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
548
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
549
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
550
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
551
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
552
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
553
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
554
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
555
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
556
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
557
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
558
-		    chr(195).chr(191) => 'y',
559
-		    // Decompositions for Latin Extended-A
560
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
561
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
562
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
563
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
564
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
565
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
566
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
567
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
568
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
569
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
570
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
571
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
572
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
573
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
574
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
575
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
576
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
577
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
578
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
579
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
580
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
581
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
582
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
583
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
584
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
585
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
586
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
587
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
588
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
589
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
590
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
591
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
592
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
593
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
594
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
595
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
596
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
597
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
598
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
599
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
600
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
601
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
602
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
603
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
604
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
605
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
606
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
607
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
608
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
609
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
610
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
611
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
612
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
613
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
614
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
615
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
616
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
617
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
618
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
619
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
620
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
621
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
622
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
623
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
530
+			// Decompositions for Latin-1 Supplement
531
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
532
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
533
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
534
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
535
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
536
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
537
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
538
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
539
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
540
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
541
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
542
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
543
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
544
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
545
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
546
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
547
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
548
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
549
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
550
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
551
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
552
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
553
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
554
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
555
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
556
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
557
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
558
+			chr(195).chr(191) => 'y',
559
+			// Decompositions for Latin Extended-A
560
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
561
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
562
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
563
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
564
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
565
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
566
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
567
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
568
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
569
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
570
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
571
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
572
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
573
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
574
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
575
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
576
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
577
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
578
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
579
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
580
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
581
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
582
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
583
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
584
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
585
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
586
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
587
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
588
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
589
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
590
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
591
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
592
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
593
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
594
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
595
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
596
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
597
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
598
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
599
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
600
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
601
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
602
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
603
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
604
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
605
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
606
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
607
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
608
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
609
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
610
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
611
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
612
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
613
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
614
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
615
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
616
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
617
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
618
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
619
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
620
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
621
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
622
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
623
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
624 624
 		);
625 625
 		$string = strtr($string, $chars);
626 626
 		return $string;
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 		$info = curl_getinfo($ch);
70 70
 		//var_dump($info);
71 71
 		curl_close($ch);
72
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
72
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
73 73
 			echo "Cloudflare Detected\n";
74 74
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
75 75
 			$useragent = UAgent::random();
76 76
 			cloudflare::useUserAgent($useragent);
77 77
 			if ($clearanceCookie = cloudflare::bypass($url)) {
78
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
78
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
79 79
 			}
80 80
 		} else {
81 81
 			return $result;
@@ -106,20 +106,20 @@  discard block
 block discarded – undo
106 106
 		fclose($fp);
107 107
 	}
108 108
 
109
-	public static function gunzip($in_file,$out_file_name = '') {
109
+	public static function gunzip($in_file, $out_file_name = '') {
110 110
 		//echo $in_file.' -> '.$out_file_name."\n";
111 111
 		$buffer_size = 4096; // read 4kb at a time
112 112
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
113 113
 		if ($in_file != '' && file_exists($in_file)) {
114 114
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
115
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
116
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
115
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
116
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
117 117
 			else {
118 118
 				echo 'gzopen not available';
119 119
 				die;
120 120
 			}
121 121
 			$out_file = fopen($out_file_name, 'wb'); 
122
-			while(!gzeof($file)) {
122
+			while (!gzeof($file)) {
123 123
 				fwrite($out_file, gzread($file, $buffer_size));
124 124
 			}  
125 125
 			fclose($out_file);
@@ -127,19 +127,19 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 	}
129 129
 
130
-	public static function bunzip2($in_file,$out_file_name = '') {
130
+	public static function bunzip2($in_file, $out_file_name = '') {
131 131
 		//echo $in_file.' -> '.$out_file_name."\n";
132 132
 		$buffer_size = 4096; // read 4kb at a time
133 133
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
134 134
 		if ($in_file != '' && file_exists($in_file)) {
135 135
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
136
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
136
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
137 137
 			else {
138 138
 				echo 'bzopen not available';
139 139
 				die;
140 140
 			}
141 141
 			$out_file = fopen($out_file_name, 'wb'); 
142
-			while(!feof($file)) {
142
+			while (!feof($file)) {
143 143
 				fwrite($out_file, bzread($file, $buffer_size));
144 144
 			}  
145 145
 			fclose($out_file);
@@ -157,27 +157,27 @@  discard block
 block discarded – undo
157 157
 		if ($data == '') return array();
158 158
 		$html = str_get_html($data);
159 159
 		if ($html === false) return array();
160
-		$tabledata=array();
161
-		foreach($html->find('tr') as $element)
160
+		$tabledata = array();
161
+		foreach ($html->find('tr') as $element)
162 162
 		{
163 163
 			$td = array();
164
-			foreach( $element->find('th') as $row)
164
+			foreach ($element->find('th') as $row)
165 165
 			{
166 166
 				$td [] = trim($row->plaintext);
167 167
 			}
168
-			$td=array_filter($td);
168
+			$td = array_filter($td);
169 169
 			$tabledata[] = $td;
170 170
 
171 171
 			$td = array();
172 172
 			$tdi = array();
173
-			foreach( $element->find('td') as $row)
173
+			foreach ($element->find('td') as $row)
174 174
 			{
175 175
 				$td [] = trim($row->plaintext);
176 176
 				$tdi [] = trim($row->innertext);
177 177
 			}
178
-			$td=array_filter($td);
179
-			$tdi=array_filter($tdi);
180
-			$tabledata[]=array_merge($td,$tdi);
178
+			$td = array_filter($td);
179
+			$tdi = array_filter($tdi);
180
+			$tabledata[] = array_merge($td, $tdi);
181 181
 		}
182 182
 		$html->clear();
183 183
 		unset($html);
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	public function text2array($data) {
193 193
 		$html = str_get_html($data);
194 194
 		if ($html === false) return array();
195
-		$tabledata=array();
196
-		foreach($html->find('p') as $element)
195
+		$tabledata = array();
196
+		foreach ($html->find('p') as $element)
197 197
 		{
198 198
 			$tabledata [] = trim($element->plaintext);
199 199
 		}
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	*/
214 214
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
215 215
 		if ($lat == $latc && $lon == $lonc) return 0;
216
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
216
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
217 217
 		if ($unit == "km") {
218
-			return round($dist * 1.609344);
218
+			return round($dist*1.609344);
219 219
 		} elseif ($unit == "m") {
220
-			return round($dist * 1.609344 * 1000);
220
+			return round($dist*1.609344*1000);
221 221
 		} elseif ($unit == "mile" || $unit == "mi") {
222 222
 			return round($dist);
223 223
 		} elseif ($unit == "nm") {
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 	* @param String $distance distance between two points in m
235 235
 	* @return Float plunge
236 236
 	*/
237
-	public function plunge($initial_altitude,$final_altitude,$distance) {
238
-		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
237
+	public function plunge($initial_altitude, $final_altitude, $distance) {
238
+		$plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance));
239 239
 		return $plunge;
240 240
 	}
241 241
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	*/
250 250
 	public function azimuth($lat, $lon, $latc, $lonc) {
251 251
 		$azimuth = rad2deg(atan(($latc - $lat)/($lonc - $lon)));
252
-		return 360+$azimuth;
252
+		return 360 + $azimuth;
253 253
 	}
254 254
 	
255 255
 	
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	* @param float $distance distance covered
260 260
 	* @return whether distance is realistic
261 261
 	*/
262
-	public function withinThreshold ($timeDifference, $distance) {
262
+	public function withinThreshold($timeDifference, $distance) {
263 263
 		$x = abs($timeDifference);
264 264
 		$d = abs($distance);
265 265
 		if ($x == 0 || $d == 0) return true;
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
 		return ($array !== array_values($array));
276 276
 	}
277 277
 
278
-	public function isInteger($input){
278
+	public function isInteger($input) {
279 279
 	    return(ctype_digit(strval($input)));
280 280
 	}
281 281
 
282 282
 
283
-	public function convertDec($dms,$latlong) {
283
+	public function convertDec($dms, $latlong) {
284 284
 		if ($latlong == 'latitude') {
285 285
 			$deg = substr($dms, 0, 2);
286 286
 			$min = substr($dms, 2, 4);
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 			$deg = substr($dms, 0, 3);
289 289
 			$min = substr($dms, 3, 5);
290 290
 		}
291
-		return $deg+(($min*60)/3600);
291
+		return $deg + (($min*60)/3600);
292 292
 	}
293 293
 	
294
-	public function convertDM($coord,$latlong) {
294
+	public function convertDM($coord, $latlong) {
295 295
 		if ($latlong == 'latitude') {
296 296
 			if ($coord < 0) $NSEW = 'S';
297 297
 			else $NSEW = 'N';
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
 		}
302 302
 		$coord = abs($coord);
303 303
 		$deg = floor($coord);
304
-		$coord = ($coord-$deg)*60;
304
+		$coord = ($coord - $deg)*60;
305 305
 		$min = $coord;
306
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
306
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
307 307
 	}
308 308
 	
309 309
 	/**
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
 	public function xcopy($source, $dest)
316 316
 	{
317 317
 		$files = glob($source.'*.*');
318
-		foreach($files as $file){
319
-			$file_to_go = str_replace($source,$dest,$file);
318
+		foreach ($files as $file) {
319
+			$file_to_go = str_replace($source, $dest, $file);
320 320
 			copy($file, $file_to_go);
321 321
 		}
322 322
 		return true;
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 	* @param	String $url url to check
328 328
 	* @return	bool Return true on succes false on failure
329 329
 	*/
330
-	public function urlexist($url){
331
-		$headers=get_headers($url);
332
-		return stripos($headers[0],"200 OK")?true:false;
330
+	public function urlexist($url) {
331
+		$headers = get_headers($url);
332
+		return stripos($headers[0], "200 OK") ?true:false;
333 333
 	}
334 334
 	
335 335
 	/**
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	public function hex2str($hex) {
341 341
 		$str = '';
342 342
 		$hexln = strlen($hex);
343
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
343
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
344 344
 		return $str;
345 345
 	}
346 346
 	
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	* @return	String Return result
351 351
 	*/
352 352
 	public function hex2rgb($hex) {
353
-		$hex = str_replace('#','',$hex);
353
+		$hex = str_replace('#', '', $hex);
354 354
 		return sscanf($hex, "%02x%02x%02x"); 
355 355
 	}
356 356
 	
@@ -358,33 +358,33 @@  discard block
 block discarded – undo
358 358
 		//difference in longitudinal coordinates
359 359
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
360 360
 		//difference in the phi of latitudinal coordinates
361
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
361
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
362 362
 		//we need to recalculate $dLon if it is greater than pi
363
-		if(abs($dLon) > pi()) {
364
-			if($dLon > 0) {
365
-				$dLon = (2 * pi() - $dLon) * -1;
363
+		if (abs($dLon) > pi()) {
364
+			if ($dLon > 0) {
365
+				$dLon = (2*pi() - $dLon)*-1;
366 366
 			} else {
367
-				$dLon = 2 * pi() + $dLon;
367
+				$dLon = 2*pi() + $dLon;
368 368
 			}
369 369
 		}
370 370
 		//return the angle, normalized
371
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
371
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
372 372
 	}
373 373
 	
374
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
374
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
375 375
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
376
-		$a = -($lon2-$lon1);
376
+		$a = -($lon2 - $lon1);
377 377
 		$b = $lat2 - $lat1;
378
-		$c = -($a*$lat1+$b*$lon1);
379
-		$d = $a*$lat3+$b*$lon3+$c;
378
+		$c = -($a*$lat1 + $b*$lon1);
379
+		$d = $a*$lat3 + $b*$lon3 + $c;
380 380
 		if ($d > -$approx && $d < $approx) return true;
381 381
 		else return false;
382 382
 	}
383 383
 	
384 384
 	public function array_merge_noappend() {
385 385
 		$output = array();
386
-		foreach(func_get_args() as $array) {
387
-			foreach($array as $key => $value) {
386
+		foreach (func_get_args() as $array) {
387
+			foreach ($array as $key => $value) {
388 388
 				$output[$key] = isset($output[$key]) ?
389 389
 				array_merge($output[$key], $value) : $value;
390 390
 			}
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 		return $result;
449 449
 	}
450 450
 
451
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
451
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
452 452
 		global $globalMapRefresh;
453 453
 		if ($seconds == '') {
454 454
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -459,27 +459,27 @@  discard block
 block discarded – undo
459 459
 		$latitude = deg2rad($latitude);
460 460
 		$longitude = deg2rad($longitude);
461 461
 		$bearing = deg2rad($heading); 
462
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
463
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
464
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
462
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
463
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
464
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
465 465
 	}
466 466
 	
467
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
467
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
468 468
 		// distance in meter
469 469
 		$R = 6378.14;
470
-		$latitude1 = $latitude * (M_PI/180);
471
-		$longitude1 = $longitude * (M_PI/180);
472
-		$brng = $bearing * (M_PI/180);
470
+		$latitude1 = $latitude*(M_PI/180);
471
+		$longitude1 = $longitude*(M_PI/180);
472
+		$brng = $bearing*(M_PI/180);
473 473
 		$d = $distance;
474 474
 
475 475
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
476
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
476
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
477 477
 
478
-		$latitude2 = $latitude2 * (180/M_PI);
479
-		$longitude2 = $longitude2 * (180/M_PI);
478
+		$latitude2 = $latitude2*(180/M_PI);
479
+		$longitude2 = $longitude2*(180/M_PI);
480 480
 
481
-		$flat = round ($latitude2,6);
482
-		$flong = round ($longitude2,6);
481
+		$flat = round($latitude2, 6);
482
+		$flong = round($longitude2, 6);
483 483
 /*
484 484
 		$dx = $distance*cos($bearing);
485 485
 		$dy = $distance*sin($bearing);
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 		$flong = $longitude + $dlong;
489 489
 		$flat = $latitude + $dlat;
490 490
 */
491
-		return array('latitude' => $flat,'longitude' => $flong);
491
+		return array('latitude' => $flat, 'longitude' => $flong);
492 492
 	}
493 493
 
494 494
 	/**
@@ -502,14 +502,14 @@  discard block
 block discarded – undo
502 502
 	 * @param integer $level GZIP compression level (default: 9)
503 503
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
504 504
 	 */
505
-	public function gzCompressFile($source, $level = 9){ 
506
-		$dest = $source . '.gz'; 
507
-		$mode = 'wb' . $level; 
505
+	public function gzCompressFile($source, $level = 9) { 
506
+		$dest = $source.'.gz'; 
507
+		$mode = 'wb'.$level; 
508 508
 		$error = false; 
509 509
 		if ($fp_out = gzopen($dest, $mode)) { 
510
-			if ($fp_in = fopen($source,'rb')) { 
510
+			if ($fp_in = fopen($source, 'rb')) { 
511 511
 				while (!feof($fp_in)) 
512
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
512
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
513 513
 				fclose($fp_in); 
514 514
 			} else {
515 515
 				$error = true; 
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 	} 
526 526
 	
527 527
 	public function remove_accents($string) {
528
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
528
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
529 529
 		$chars = array(
530 530
 		    // Decompositions for Latin-1 Supplement
531 531
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
583 583
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
584 584
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
585
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
585
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
586 586
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
587 587
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
588 588
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -598,13 +598,13 @@  discard block
 block discarded – undo
598 598
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
599 599
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
600 600
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
601
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
602
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
603
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
604
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
605
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
606
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
607
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
601
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
602
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
603
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
604
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
605
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
606
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
607
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
608 608
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
609 609
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
610 610
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
639 639
 			if (is_numeric($string[$i]) && $concat_flag) {
640 640
 				$int .= $string[$i];
641
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
641
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
642 642
 				$concat_flag = false;
643 643
 			}
644 644
 		}
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 			$slice = array_slice($arr, $offset + 1, $length);
685 685
 			return implode("", $slice);
686 686
 		} else {
687
-			return mb_substr($string,$offset,$length,'UTF-8');
687
+			return mb_substr($string, $offset, $length, 'UTF-8');
688 688
 		}
689 689
 	}
690 690
 
@@ -694,14 +694,14 @@  discard block
 block discarded – undo
694 694
 		//NOTE: use a trailing slash for folders!!!
695 695
 		//see http://bugs.php.net/bug.php?id=27609
696 696
 		//see http://bugs.php.net/bug.php?id=30931
697
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
697
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
698 698
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
699 699
 		else if (is_dir($path))
700 700
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
701 701
 		// check tmp file for read/write capabilities
702 702
 		$rm = file_exists($path);
703 703
 		$f = @fopen($path, 'a');
704
-		if ($f===false)
704
+		if ($f === false)
705 705
 			return false;
706 706
 		fclose($f);
707 707
 		if (!$rm)
Please login to merge, or discard this patch.
require/class.GeoidHeight.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -91,6 +91,10 @@
 block discarded – undo
91 91
 		$this->rlatres = (($this->height - 1) / 180.0);
92 92
 	}
93 93
 
94
+	/**
95
+	 * @param integer $ix
96
+	 * @param integer $iy
97
+	 */
94 98
 	private function _rawval($ix,$iy) {
95 99
 		if (($iy < 0)) {
96 100
 			$iy = -$iy;
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 * Translated to PHP of GeographicLib/src/Geoid.cpp
12 12
 * by Ycarus <[email protected]> in 2017
13 13
 */
14
-class GeoidHeight  {
14
+class GeoidHeight {
15 15
 	private $c0 = 240;
16 16
 	private $c3 = [[9, -18, -88, 0, 96, 90, 0, 0, -60, -20], [-9, 18, 8, 0, -96, 30, 0, 0, 60, -20], [9, -88, -18, 90, 96, 0, -20, -60, 0, 0], [186, -42, -42, -150, -96, -150, 60, 60, 60, 60], [54, 162, -78, 30, -24, -90, -60, 60, -60, 60], [-9, -32, 18, 30, 24, 0, 20, -60, 0, 0], [-9, 8, 18, 30, -96, 0, -20, 60, 0, 0], [54, -78, 162, -90, -24, 30, 60, -60, 60, -60], [-54, 78, 78, 90, 144, 90, -60, -60, -60, -60], [9, -8, -18, -30, -24, 0, 20, 60, 0, 0], [-9, 18, -32, 0, 24, 30, 0, 0, -60, 20], [9, -18, -8, 0, -24, -30, 0, 0, 60, 20]];
17 17
 	private $c0n = 372;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	private $v10 = null;
35 35
 	private $v11 = null;
36 36
 
37
-	public function __construct($name='') {
37
+	public function __construct($name = '') {
38 38
 		global $globalGeoidSource;
39 39
 		//if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm';
40 40
 		if ($name == '') {
@@ -42,35 +42,35 @@  discard block
 block discarded – undo
42 42
 			else $name = dirname(__FILE__).'/../data/egm96-15.pgm';
43 43
 		}
44 44
 
45
-		$f = @fopen($name,"r");
45
+		$f = @fopen($name, "r");
46 46
 		if ($f === FALSE) {
47 47
 			throw new Exception("Can't open ".$name);
48 48
 		}
49
-		$line = fgets($f,4096);
49
+		$line = fgets($f, 4096);
50 50
 		if (trim($line) != 'P5') {
51 51
 			throw new Exception('No PGM header');
52 52
 		}
53 53
 		$headerlen = strlen($line);
54 54
 		while (true) {
55
-			$line = fgets($f,4096);
55
+			$line = fgets($f, 4096);
56 56
 			if ((strlen($line) == 0)) {
57 57
 				throw new Exception('EOF before end of file header');
58 58
 			}
59 59
 			$headerlen += strlen($line);
60
-			if (strpos($line,'# Offset ') !== FALSE) {
60
+			if (strpos($line, '# Offset ') !== FALSE) {
61 61
 				$this->offset = substr($line, 9);
62
-			} else if (strpos($line,'# Scale ') !== FALSE) {
62
+			} else if (strpos($line, '# Scale ') !== FALSE) {
63 63
 				$this->scale = substr($line, 8);
64
-			} else if ((strpos($line,'#') === FALSE)) {
65
-				list($this->width, $this->height) = preg_split('/\s+/',$line);
64
+			} else if ((strpos($line, '#') === FALSE)) {
65
+				list($this->width, $this->height) = preg_split('/\s+/', $line);
66 66
 				break;
67 67
 			}
68 68
 		}
69
-		$line = fgets($f,4096);
69
+		$line = fgets($f, 4096);
70 70
 		$headerlen += strlen($line);
71
-		$levels = (int)$line;
72
-		$this->width = (int)$this->width;
73
-		$this->height = (int)$this->height;
71
+		$levels = (int) $line;
72
+		$this->width = (int) $this->width;
73
+		$this->height = (int) $this->height;
74 74
 		if (($levels != 65535)) {
75 75
 			throw new Exception('PGM file must have 65535 gray levels ('.$levels.')');
76 76
 		}
@@ -85,42 +85,42 @@  discard block
 block discarded – undo
85 85
 		}
86 86
 
87 87
 		$fullsize = filesize($name);
88
-		if ((($fullsize - $headerlen) != (($this->width * $this->height) * 2))) {
88
+		if ((($fullsize - $headerlen) != (($this->width*$this->height)*2))) {
89 89
 			throw new Exception('File has the wrong length');
90 90
 		}
91 91
 
92 92
 		$this->headerlen = $headerlen;
93
-		$this->raw= $f;
94
-		$this->rlonres = ($this->width / 360.0);
95
-		$this->rlatres = (($this->height - 1) / 180.0);
93
+		$this->raw = $f;
94
+		$this->rlonres = ($this->width/360.0);
95
+		$this->rlatres = (($this->height - 1)/180.0);
96 96
 	}
97 97
 
98
-	private function _rawval($ix,$iy) {
98
+	private function _rawval($ix, $iy) {
99 99
 		if (($iy < 0)) {
100 100
 			$iy = -$iy;
101
-			$ix += ($this->width / 2);
101
+			$ix += ($this->width/2);
102 102
 		} else if (($iy >= $this->height)) {
103
-			$iy = ((2 * ($this->height - 1)) - $iy);
104
-			$ix += ($this->width / 2);
103
+			$iy = ((2*($this->height - 1)) - $iy);
104
+			$ix += ($this->width/2);
105 105
 		}
106 106
 		if (($ix < 0)) {
107 107
 			$ix += $this->width;
108 108
 		} else if (($ix >= $this->width)) {
109 109
 			$ix -= $this->width;
110 110
 		}
111
-		$k = ((($iy * $this->width) + $ix) * 2) + $this->headerlen;
112
-		fseek($this->raw,$k);
113
-		return unpack('n',fread($this->raw,2))[1];
111
+		$k = ((($iy*$this->width) + $ix)*2) + $this->headerlen;
112
+		fseek($this->raw, $k);
113
+		return unpack('n', fread($this->raw, 2))[1];
114 114
 	}
115 115
 
116
-	public function get($lat,$lon,$cubic=true) {
116
+	public function get($lat, $lon, $cubic = true) {
117 117
 		if (($lon < 0)) {
118 118
 			$lon += 360;
119 119
 		}
120
-		$fy = ((90 - $lat) * $this->rlatres);
121
-		$fx = ($lon * $this->rlonres);
122
-		$iy = (int)$fy;
123
-		$ix = (int)$fx;
120
+		$fy = ((90 - $lat)*$this->rlatres);
121
+		$fx = ($lon*$this->rlonres);
122
+		$iy = (int) $fy;
123
+		$ix = (int) $fx;
124 124
 		$fx -= $ix;
125 125
 		$fy -= $iy;
126 126
 		$t = array();
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 					$c3x = $this->c3;
148 148
 					$c0x = $this->c0;
149 149
 				}
150
-				for ($i = 0; $i < 10;++$i) {
150
+				for ($i = 0; $i < 10; ++$i) {
151 151
 					$t[$i] = 0;
152 152
 					for ($j = 0; $j < 12; ++$j) {
153 153
 						$t[$i] += $v[$j]*$c3x[$j][$i];
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
 			$this->t = $t;
159 159
 		} else $t = $this->t;
160 160
 		if (!($cubic)) {
161
-			$a = (((1 - $fx) * $this->v00) + ($fx * $this->v01));
162
-			$b = (((1 - $fx) * $this->v10) + ($fx * $this->v11));
163
-			$h = (((1 - $fy) * $a) + ($fy * $b));
161
+			$a = (((1 - $fx)*$this->v00) + ($fx*$this->v01));
162
+			$b = (((1 - $fx)*$this->v10) + ($fx*$this->v11));
163
+			$h = (((1 - $fy)*$a) + ($fy*$b));
164 164
 		} else {
165
-			$h = (($t[0] + ($fx * ($t[1] + ($fx * ($t[3] + ($fx * $t[6])))))) + ($fy * (($t[2] + ($fx * ($t[4] + ($fx * $t[7])))) + ($fy * (($t[5] + ($fx * $t[8])) + ($fy * $t[9]))))));
165
+			$h = (($t[0] + ($fx*($t[1] + ($fx*($t[3] + ($fx*$t[6])))))) + ($fy*(($t[2] + ($fx*($t[4] + ($fx*$t[7])))) + ($fy*(($t[5] + ($fx*$t[8])) + ($fy*$t[9]))))));
166 166
 		}
167
-		return ((float)$this->offset + ((float)$this->scale * (float)$h));
167
+		return ((float) $this->offset + ((float) $this->scale*(float) $h));
168 168
 	}
169 169
 }
170 170
 /*
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,8 +38,11 @@  discard block
 block discarded – undo
38 38
 		global $globalGeoidSource;
39 39
 		//if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm';
40 40
 		if ($name == '') {
41
-			if (isset($globalGeoidSource) && $globalGeoidSource != '') $name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm';
42
-			else $name = dirname(__FILE__).'/../data/egm96-15.pgm';
41
+			if (isset($globalGeoidSource) && $globalGeoidSource != '') {
42
+				$name = dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm';
43
+			} else {
44
+				$name = dirname(__FILE__).'/../data/egm96-15.pgm';
45
+			}
43 46
 		}
44 47
 
45 48
 		$f = @fopen($name,"r");
@@ -156,7 +159,9 @@  discard block
 block discarded – undo
156 159
 				}
157 160
 			}
158 161
 			$this->t = $t;
159
-		} else $t = $this->t;
162
+		} else {
163
+			$t = $this->t;
164
+		}
160 165
 		if (!($cubic)) {
161 166
 			$a = (((1 - $fx) * $this->v00) + ($fx * $this->v01));
162 167
 			$b = (((1 - $fx) * $this->v10) + ($fx * $this->v11));
Please login to merge, or discard this patch.
require/settings.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $globalLongitudeMin = '1.0'; //the minimum longitude (east)
43 43
 
44 44
 $globalCenterLatitude = '46.38'; //the latitude center of your coverage area
45
-$globalCenterLongitude = '5.29';//the longitude center of your coverage area
45
+$globalCenterLongitude = '5.29'; //the longitude center of your coverage area
46 46
 
47 47
 $globalLiveZoom = '9'; //default zoom on Live Map
48 48
 $globalAirportZoom = '7'; //default zoom to begin to display airports icons
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 $globalACARS = FALSE;
152 152
 $globalACARSHost = '0.0.0.0'; // Local IP to listen
153 153
 $globalACARSPort = '9999';
154
-$globalACARSArchive = array('10','80','81','82','3F'); // labels of messages to archive
154
+$globalACARSArchive = array('10', '80', '81', '82', '3F'); // labels of messages to archive
155 155
 $globalACARSArchiveKeepMonths = '0';
156 156
 
157 157
 //APRS configuration (for glidernet)
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 //Check by aircraft ICAO if image is not found by registration
249 249
 $globalAircraftImageCheckICAO = TRUE;
250 250
 //Sources for Aircraft image
251
-$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters','customsources');
251
+$globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters', 'customsources');
252 252
 // Custom source configuration {registration} will be replaced by aircraft registration (exif get copyright from exif data for each pic)
253 253
 // example of config : $globalAircraftImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{registration}.jpg','original' => 'http://myurl/original/{registration}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'copyright' => 'myself','exif' => true);
254 254
 // ************************
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 //Retrieve Image from externals sources
258 258
 $globalMarineImageFetch = TRUE;
259 259
 //Sources for Marine image
260
-$globalMarineImageSources = array('wikimedia','flickr','deviantart','bing','customsources');
260
+$globalMarineImageSources = array('wikimedia', 'flickr', 'deviantart', 'bing', 'customsources');
261 261
 // Custom source configuration {mmsi} will be replaced by vessel mmsi, {name} by it's name (exif get copyright from exif data for each pic)
262 262
 // example of config : $globalMarineImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{name}.jpg','original' => 'http://myurl/original/{name}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'copyright' => 'myself','exif' => true);
263 263
 // ************************
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 //Retrieve schedules from externals sources (set to FALSE for IVAO or if $globalFork = FALSE)
266 266
 $globalSchedulesFetch = TRUE;
267 267
 //Sources for airline schedule if not official airline site
268
-$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
268
+$globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
269 269
 
270 270
 //Retrieve translation from external sources (set to FALSE for IVAO)
271 271
 $globalTranslationFetch = TRUE;
Please login to merge, or discard this patch.
import/callback.php 2 patches
Braces   +39 added lines, -13 removed lines patch added patch discarded remove patch
@@ -27,15 +27,21 @@  discard block
 block discarded – undo
27 27
 		}
28 28
 	}
29 29
 }
30
-if ($authorize === false) die;
30
+if ($authorize === false) {
31
+	die;
32
+}
31 33
 
32
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
34
+if (isset($globalTracker) && $globalTracker) {
35
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
36
+}
33 37
 if (isset($globalMarine) && $globalMarine) {
34 38
 	require_once(dirname(__FILE__).'/../require/class.AIS.php');
35 39
 	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
36 40
 }
37 41
 
38
-if (!isset($globalDebug)) $globalDebug = FALSE;
42
+if (!isset($globalDebug)) {
43
+	$globalDebug = FALSE;
44
+}
39 45
 
40 46
 // Check if schema is at latest version
41 47
 $Connection = new Connection();
@@ -45,10 +51,16 @@  discard block
 block discarded – undo
45 51
 }
46 52
 
47 53
 if (isset($globalServer) && $globalServer) {
48
-	if ($globalDebug) echo "Using Server Mode\n";
54
+	if ($globalDebug) {
55
+		echo "Using Server Mode\n";
56
+	}
49 57
 	$SI=new SpotterServer();
50
-} else $SI=new SpotterImport($Connection->db);
51
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
58
+} else {
59
+	$SI=new SpotterImport($Connection->db);
60
+}
61
+if (isset($globalTracker) && $globalTracker) {
62
+	$TI = new TrackerImport($Connection->db);
63
+}
52 64
 if (isset($globalMarine) && $globalMarine) {
53 65
 	$AIS = new AIS();
54 66
 	$MI = new MarineImport($Connection->db);
@@ -57,7 +69,9 @@  discard block
 block discarded – undo
57 69
 date_default_timezone_set('UTC');
58 70
 
59 71
 $buffer = '';
60
-if (isset($_POST)) $buffer = $_POST;
72
+if (isset($_POST)) {
73
+	$buffer = $_POST;
74
+}
61 75
 $data = array();
62 76
 if (isset($buffer['type_event']) && isset($buffer['lat']) && isset($buffer['lon'])) {
63 77
 	$data['ident'] = $buffer['device_id'];
@@ -68,15 +82,27 @@  discard block
 block discarded – undo
68 82
 	//$data['heading'] = $buffer['cap']; // Only N/S/E/W
69 83
 	$data['datetime'] = date('Y-m-d H:i:s',$buffer['timestamp']);
70 84
 	$data['comment'] = '';
71
-	if (isset($buffer['battery']) && $buffer['battery'] != '') $data['comment'] .= 'Battery: '.$buffer['battery'].'% ';
85
+	if (isset($buffer['battery']) && $buffer['battery'] != '') {
86
+		$data['comment'] .= 'Battery: '.$buffer['battery'].'% ';
87
+	}
72 88
 	//if (isset($buffer['snr']) && $buffer['snr'] != '') $data['comment'] .= 'SNR: '.$buffer['snr'].' ';
73
-	if (isset($buffer['temp']) && $buffer['temp'] != '') $data['comment'] .= 'Temperature: '.$buffer['temp'].'°C ';
74
-	if (isset($buffer['press']) && $buffer['press'] != '') $data['comment'] .= 'Pressure: '.$buffer['press'].'hPa ';
89
+	if (isset($buffer['temp']) && $buffer['temp'] != '') {
90
+		$data['comment'] .= 'Temperature: '.$buffer['temp'].'°C ';
91
+	}
92
+	if (isset($buffer['press']) && $buffer['press'] != '') {
93
+		$data['comment'] .= 'Pressure: '.$buffer['press'].'hPa ';
94
+	}
75 95
 	$TI->add($data);
76 96
 	unset($data);
77 97
 }
78
-if (isset($SI)) $SI->checkAll();
79
-if (isset($MI)) $MI->checkAll();
80
-if (isset($TI)) $TI->checkAll();
98
+if (isset($SI)) {
99
+	$SI->checkAll();
100
+}
101
+if (isset($MI)) {
102
+	$MI->checkAll();
103
+}
104
+if (isset($TI)) {
105
+	$TI->checkAll();
106
+}
81 107
 
82 108
 ?>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/../require/class.Source.php');
10 10
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
11 11
 require_once(dirname(__FILE__).'/../require/class.Common.php');
12
-$Common=new Common();
12
+$Common = new Common();
13 13
 $authorize = false;
14 14
 $params = array();
15 15
 $userip = $Common->getUserIP();
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 			$authorize = true;
21 21
 			break;
22 22
 		}
23
-		if ($userip != '' && isset($cb['host']) && in_array($userip,explode(',',$cb['host']))) {
23
+		if ($userip != '' && isset($cb['host']) && in_array($userip, explode(',', $cb['host']))) {
24 24
 			$params = $globalSources[$key];
25 25
 			$authorize = true;
26 26
 			break;
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 
47 47
 if (isset($globalServer) && $globalServer) {
48 48
 	if ($globalDebug) echo "Using Server Mode\n";
49
-	$SI=new SpotterServer();
50
-} else $SI=new SpotterImport($Connection->db);
49
+	$SI = new SpotterServer();
50
+} else $SI = new SpotterImport($Connection->db);
51 51
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
52 52
 if (isset($globalMarine) && $globalMarine) {
53 53
 	$AIS = new AIS();
54 54
 	$MI = new MarineImport($Connection->db);
55 55
 }
56
-$Source=new Source($Connection->db);
56
+$Source = new Source($Connection->db);
57 57
 date_default_timezone_set('UTC');
58 58
 
59 59
 $buffer = '';
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	$data['altitude'] = round($buffer['altitude']*3.28084);
67 67
 	$data['speed'] = $buffer['speed'];
68 68
 	//$data['heading'] = $buffer['cap']; // Only N/S/E/W
69
-	$data['datetime'] = date('Y-m-d H:i:s',$buffer['timestamp']);
69
+	$data['datetime'] = date('Y-m-d H:i:s', $buffer['timestamp']);
70 70
 	$data['comment'] = '';
71 71
 	if (isset($buffer['battery']) && $buffer['battery'] != '') $data['comment'] .= 'Battery: '.$buffer['battery'].'% ';
72 72
 	//if (isset($buffer['snr']) && $buffer['snr'] != '') $data['comment'] .= 'SNR: '.$buffer['snr'].' ';
Please login to merge, or discard this patch.
require/class.APRS.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -165,6 +165,10 @@  discard block
 block discarded – undo
165 165
 	'\~' => 'TNC Stream SW');
166 166
 	
167 167
 
168
+    /**
169
+     * @param integer $n
170
+     * @param integer $s
171
+     */
168 172
     private function urshift($n, $s) {
169 173
 	return ($n >= 0) ? ($n >> $s) :
170 174
 	    (($n & 0x7fffffff) >> $s) | 
@@ -565,6 +569,9 @@  discard block
 block discarded – undo
565 569
 	socket_close($this->socket);
566 570
     }
567 571
     
572
+    /**
573
+     * @param string $data
574
+     */
568 575
     public function send($data) {
569 576
 	global $globalDebug;
570 577
 	if ($this->connected === false) $this->connect();
Please login to merge, or discard this patch.
Braces   +307 added lines, -110 removed lines patch added patch discarded remove patch
@@ -184,17 +184,23 @@  discard block
 block discarded – undo
184 184
 	
185 185
 	/* Check that end was found and body has at least one byte. */
186 186
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
187
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
187
+	    if ($globalDebug) {
188
+	    	echo '!!! APRS invalid : '.$input."\n";
189
+	    }
188 190
 	    return false;
189 191
 	}
190 192
 	
191
-	if ($debug) echo 'input : '.$input."\n";
193
+	if ($debug) {
194
+		echo 'input : '.$input."\n";
195
+	}
192 196
 	/* Save header and body. */
193 197
 	$body = substr($input,$splitpos+1,$input_len);
194 198
 	$body_len = strlen($body);
195 199
 	$header = substr($input,0,$splitpos);
196 200
 	//$header_len = strlen($header);
197
-	if ($debug) echo 'header : '.$header."\n";
201
+	if ($debug) {
202
+		echo 'header : '.$header."\n";
203
+	}
198 204
 	
199 205
 	/* Parse source, target and path. */
200 206
 	//FLRDF0A52>APRS,qAS,LSTB
@@ -208,11 +214,15 @@  discard block
 block discarded – undo
208 214
 		$result['format_source'] = 'famaprs';
209 215
 		$result['source_type'] = 'ais';
210 216
 	    } else {
211
-		if ($debug) echo 'ident : '.$ident."\n";
217
+		if ($debug) {
218
+			echo 'ident : '.$ident."\n";
219
+		}
212 220
 		$result['ident'] = $ident;
213 221
 	    }
214 222
 	} else {
215
-	    if ($debug) 'No ident'."\n";
223
+	    if ($debug) {
224
+	    	'No ident'."\n";
225
+	    }
216 226
 	    return false;
217 227
 	}
218 228
 	$elements = explode(',',$all_elements);
@@ -223,7 +233,9 @@  discard block
 block discarded – undo
223 233
 	        //echo "ok";
224 234
 	        //if ($element == 'TCPIP*') return false;
225 235
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
226
-		if ($debug) echo 'element : '.$element."\n";
236
+		if ($debug) {
237
+			echo 'element : '.$element."\n";
238
+		}
227 239
 		return false;
228 240
 	    }
229 241
 	    /*
@@ -236,13 +248,17 @@  discard block
 block discarded – undo
236 248
 	}
237 249
 	
238 250
 	$type = substr($body,0,1);
239
-	if ($debug) echo 'type : '.$type."\n";
251
+	if ($debug) {
252
+		echo 'type : '.$type."\n";
253
+	}
240 254
 	if ($type == ';') {
241 255
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
242 256
 			$result['address'] = trim(substr($body,1,9));
243 257
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
244 258
 			$result['mmsi'] = trim(substr($body,1,9));
245
-		} else $result['ident'] = trim(substr($body,1,9));
259
+		} else {
260
+			$result['ident'] = trim(substr($body,1,9));
261
+		}
246 262
 	} elseif ($type == ',') {
247 263
 		// Invalid data or test data
248 264
 		return false;
@@ -311,7 +327,9 @@  discard block
 block discarded – undo
311 327
 		//$symbol_table = $matches[4];
312 328
 		$lat = intval($lat_deg);
313 329
 		$lon = intval($lon_deg);
314
-		if ($lat > 89 || $lon > 179) return false;
330
+		if ($lat > 89 || $lon > 179) {
331
+			return false;
332
+		}
315 333
 	    
316 334
 	    /*
317 335
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -321,8 +339,12 @@  discard block
 block discarded – undo
321 339
 	    */
322 340
 		$latitude = $lat + floatval($lat_min)/60;
323 341
 		$longitude = $lon + floatval($lon_min)/60;
324
-		if ($sind == 'S') $latitude = 0-$latitude;
325
-		if ($wind == 'W') $longitude = 0-$longitude;
342
+		if ($sind == 'S') {
343
+			$latitude = 0-$latitude;
344
+		}
345
+		if ($wind == 'W') {
346
+			$longitude = 0-$longitude;
347
+		}
326 348
 		$result['latitude'] = $latitude;
327 349
 		$result['longitude'] = $longitude;
328 350
 		$body_parse = substr($body_parse,18);
@@ -350,8 +372,11 @@  discard block
 block discarded – undo
350 372
 			//echo 'find'."\n";
351 373
 			$body_split = str_split($body_parse);
352 374
 			$symbol_code = $body_split[0];
353
-			if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code;
354
-			else $symbol_code = '\\'.$symbol_code;
375
+			if (!isset($symbolll) || $symbolll == '/') {
376
+				$symbol_code = '/'.$symbol_code;
377
+			} else {
378
+				$symbol_code = '\\'.$symbol_code;
379
+			}
355 380
 		//'
356 381
 		//}
357 382
 		//echo $body_parse;
@@ -360,7 +385,9 @@  discard block
 block discarded – undo
360 385
 			$body_parse = substr($body_parse,1);
361 386
 			$body_parse_len = strlen($body_parse);
362 387
 			$result['symbol_code'] = $symbol_code;
363
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
388
+			if (isset($this->symbols[$symbol_code])) {
389
+				$result['symbol'] = $this->symbols[$symbol_code];
390
+			}
364 391
 			if ($symbol_code != '_') {
365 392
 			}
366 393
 		    //$body_parse = substr($body_parse,1);
@@ -371,7 +398,9 @@  discard block
 block discarded – undo
371 398
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372 399
 		    	    $course = substr($body_parse,0,3);
373 400
 		    	    $tmp_s = intval($course);
374
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
401
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
402
+		    	    	$result['heading'] = intval($course);
403
+		    	    }
375 404
 		    	    $speed = substr($body_parse,4,3);
376 405
 		    	    if ($speed != '...') {
377 406
 		    		//$result['speed'] = round($speed*1.852);
@@ -412,10 +441,16 @@  discard block
 block discarded – undo
412 441
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413 442
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
414 443
 			    
415
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416
-				else $result['latitude'] += $lat_off;
417
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
418
-				else $result['longitude'] += $lon_off;
444
+				if ($result['latitude'] < 0) {
445
+					$result['latitude'] -= $lat_off;
446
+				} else {
447
+					$result['latitude'] += $lat_off;
448
+				}
449
+				if ($result['longitude'] < 0) {
450
+					$result['longitude'] -= $lon_off;
451
+				} else {
452
+					$result['longitude'] += $lon_off;
453
+				}
419 454
 			    }
420 455
 			    
421 456
 		            $body_parse = substr($body_parse,6);
@@ -457,27 +492,48 @@  discard block
 block discarded – undo
457 492
 			$address = substr($id,2);
458 493
 			//print_r($matches);
459 494
 			$addressType = (intval(substr($id,0,2),16))&3;
460
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
461
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
462
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
463
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
495
+			if ($addressType == 0) {
496
+				$result['addresstype'] = "RANDOM";
497
+			} elseif ($addressType == 1) {
498
+				$result['addresstype'] = "ICAO";
499
+			} elseif ($addressType == 2) {
500
+				$result['addresstype'] = "FLARM";
501
+			} elseif ($addressType == 3) {
502
+				$result['addresstype'] = "OGN";
503
+			}
464 504
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
465 505
 			$result['aircrafttype_code'] = $aircraftType;
466
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
467
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
468
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
469
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
470
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
471
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
472
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
473
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
474
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
475
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
476
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
477
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
478
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
479
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
480
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
506
+			if ($aircraftType == 0) {
507
+				$result['aircrafttype'] = "UNKNOWN";
508
+			} elseif ($aircraftType == 1) {
509
+				$result['aircrafttype'] = "GLIDER";
510
+			} elseif ($aircraftType == 2) {
511
+				$result['aircrafttype'] = "TOW_PLANE";
512
+			} elseif ($aircraftType == 3) {
513
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
514
+			} elseif ($aircraftType == 4) {
515
+				$result['aircrafttype'] = "PARACHUTE";
516
+			} elseif ($aircraftType == 5) {
517
+				$result['aircrafttype'] = "DROP_PLANE";
518
+			} elseif ($aircraftType == 6) {
519
+				$result['aircrafttype'] = "HANG_GLIDER";
520
+			} elseif ($aircraftType == 7) {
521
+				$result['aircrafttype'] = "PARA_GLIDER";
522
+			} elseif ($aircraftType == 8) {
523
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
524
+			} elseif ($aircraftType == 9) {
525
+				$result['aircrafttype'] = "JET_AIRCRAFT";
526
+			} elseif ($aircraftType == 10) {
527
+				$result['aircrafttype'] = "UFO";
528
+			} elseif ($aircraftType == 11) {
529
+				$result['aircrafttype'] = "BALLOON";
530
+			} elseif ($aircraftType == 12) {
531
+				$result['aircrafttype'] = "AIRSHIP";
532
+			} elseif ($aircraftType == 13) {
533
+				$result['aircrafttype'] = "UAV";
534
+			} elseif ($aircraftType == 15) {
535
+				$result['aircrafttype'] = "STATIC_OBJECT";
536
+			}
481 537
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
482 538
 			$result['stealth'] = $stealth;
483 539
 			$result['address'] = $address;
@@ -517,79 +573,183 @@  discard block
 block discarded – undo
517 573
 		    //g012t088r000p000P000h38b10110
518 574
 		    //g011t086r000p000P000h29b10198
519 575
 		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
525
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
576
+			if ($matches[1] != '...') {
577
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
578
+			}
579
+			if ($matches[2] != '...') {
580
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
581
+			}
582
+			if ($matches[3] != '...') {
583
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
584
+			}
585
+			if ($matches[4] != '...') {
586
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
587
+			}
588
+			if ($matches[5] != '...') {
589
+				$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
590
+			}
591
+			if ($matches[6] != '...') {
592
+				$result['humidity'] = intval($matches[6]);
593
+			}
594
+			if ($matches[7] != '...') {
595
+				$result['pressure'] = round((intval($matches[7])/10),1);
596
+			}
527 597
 		        $body_parse = substr($body_parse,strlen($matches[0]));
528 598
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
532
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
533
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
534
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
599
+			if ($matches[1] != '...') {
600
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
601
+			}
602
+			if ($matches[2] != '...') {
603
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
604
+			}
605
+			if ($matches[3] != '...') {
606
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
607
+			}
608
+			if ($matches[5] != '...') {
609
+				$result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
610
+			}
611
+			if ($matches[4] != '...') {
612
+				$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
613
+			}
614
+			if ($matches[6] != '...') {
615
+				$result['humidity'] = intval($matches[6]);
616
+			}
617
+			if ($matches[7] != '...') {
618
+				$result['pressure'] = round((intval($matches[7])/10),1);
619
+			}
536 620
 		        $body_parse = substr($body_parse,strlen($matches[0]));
537 621
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
541
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
542
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
543
-			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
622
+			if ($matches[1] != '...') {
623
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
624
+			}
625
+			if ($matches[2] != '...') {
626
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
627
+			}
628
+			if ($matches[3] != '...') {
629
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
630
+			}
631
+			if ($matches[4] != '...') {
632
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
633
+			}
634
+			if ($matches[5] != '...') {
635
+				$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
636
+			}
637
+			if ($matches[7] != '...') {
638
+				$result['humidity'] = intval($matches[7]);
639
+			}
640
+			if ($matches[6] != '...') {
641
+				$result['pressure'] = round((intval($matches[6])/10),1);
642
+			}
545 643
 		        $body_parse = substr($body_parse,strlen($matches[0]));
546 644
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
551
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
645
+			if ($matches[1] != '...') {
646
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
647
+			}
648
+			if ($matches[2] != '...') {
649
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
650
+			}
651
+			if ($matches[3] != '...') {
652
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
653
+			}
654
+			if ($matches[4] != '...') {
655
+				$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
656
+			}
657
+			if ($matches[6] != '...') {
658
+				$result['humidity'] = intval($matches[6]);
659
+			}
660
+			if ($matches[5] != '...') {
661
+				$result['pressure'] = round((intval($matches[5])/10),1);
662
+			}
553 663
 		        $body_parse = substr($body_parse,strlen($matches[0]));
554 664
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
665
+			if ($matches[1] != '...') {
666
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
667
+			}
668
+			if ($matches[2] != '...') {
669
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
670
+			}
671
+			if ($matches[3] != '...') {
672
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
673
+			}
674
+			if ($matches[4] != '...') {
675
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
676
+			}
677
+			if ($matches[6] != '...') {
678
+				$result['humidity'] = intval($matches[6]);
679
+			}
680
+			if ($matches[5] != '...') {
681
+				$result['pressure'] = round((intval($matches[5])/10),1);
682
+			}
561 683
 		        $body_parse = substr($body_parse,strlen($matches[0]));
562 684
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
567
-			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
685
+			if ($matches[1] != '...') {
686
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
687
+			}
688
+			if ($matches[2] != '...') {
689
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
690
+			}
691
+			if ($matches[3] != '...') {
692
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
693
+			}
694
+			if ($matches[4] != '...') {
695
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
696
+			}
697
+			if ($matches[5] != '...') {
698
+				$result['humidity'] = intval($matches[5]);
699
+			}
700
+			if ($matches[6] != '...') {
701
+				$result['pressure'] = round((intval($matches[6])/10),1);
702
+			}
569 703
 		        $body_parse = substr($body_parse,strlen($matches[0]));
570 704
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
573
-			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
705
+			if ($matches[1] != '...') {
706
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
707
+			}
708
+			if ($matches[2] != '...') {
709
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
710
+			}
711
+			if ($matches[2] != '...') {
712
+				$result['humidity'] = intval($matches[3]);
713
+			}
714
+			if ($matches[4] != '...') {
715
+				$result['pressure'] = round((intval($matches[4])/10),1);
716
+			}
575 717
 		        $body_parse = substr($body_parse,strlen($matches[0]));
576 718
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
580
-			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
719
+			if ($matches[1] != '...') {
720
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
721
+			}
722
+			if ($matches[2] != '...') {
723
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
724
+			}
725
+			if ($matches[3] != '...') {
726
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
727
+			}
728
+			if ($matches[4] != '...') {
729
+				$result['humidity'] = intval($matches[4]);
730
+			}
731
+			if ($matches[5] != '...') {
732
+				$result['pressure'] = round((intval($matches[5])/10),1);
733
+			}
582 734
 		        $body_parse = substr($body_parse,strlen($matches[0]));
583 735
 		    }
584 736
 		    $result['comment'] = trim($body_parse);
585 737
 		}
586
-		} else $result['comment'] = trim($body_parse);
738
+		} else {
739
+			$result['comment'] = trim($body_parse);
740
+		}
587 741
 
588 742
 	    }
589 743
 	//}
590
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
592
-	if ($debug) print_r($result);
744
+	if (isset($result['latitude'])) {
745
+		$result['latitude'] = round($result['latitude'],4);
746
+	}
747
+	if (isset($result['longitude'])) {
748
+		$result['longitude'] = round($result['longitude'],4);
749
+	}
750
+	if ($debug) {
751
+		print_r($result);
752
+	}
593 753
 	return $result;
594 754
     }
595 755
     
@@ -598,12 +758,21 @@  discard block
 block discarded – undo
598 758
 	$aprs_connect = 0;
599 759
 	$aprs_keep = 120;
600 760
 	$aprs_last_tx = time();
601
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
602
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
603
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
604
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
605
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
606
-	else $aprs_pass = '-1';
761
+	if (isset($globalAPRSversion)) {
762
+		$aprs_version = $globalAPRSversion;
763
+	} else {
764
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
765
+	}
766
+	if (isset($globalServerAPRSssid)) {
767
+		$aprs_ssid = $globalServerAPRSssid;
768
+	} else {
769
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
770
+	}
771
+	if (isset($globalServerAPRSpass)) {
772
+		$aprs_pass = $globalServerAPRSpass;
773
+	} else {
774
+		$aprs_pass = '-1';
775
+	}
607 776
 	
608 777
 	$aprs_filter  = '';
609 778
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -636,10 +805,14 @@  discard block
 block discarded – undo
636 805
     
637 806
     public function send($data) {
638 807
 	global $globalDebug;
639
-	if ($this->connected === false) $this->connect();
808
+	if ($this->connected === false) {
809
+		$this->connect();
810
+	}
640 811
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
641 812
 	if ($send === FALSE) {
642
-		if ($globalDebug) echo 'Reconnect...';
813
+		if ($globalDebug) {
814
+			echo 'Reconnect...';
815
+		}
643 816
 		socket_close($this->socket);
644 817
 		$this->connect();
645 818
 	}
@@ -661,22 +834,32 @@  discard block
 block discarded – undo
661 834
 			//$w = '00';
662 835
 			$custom = '';
663 836
 			if ($ident != '') {
664
-				if ($custom != '') $custom .= '/';
837
+				if ($custom != '') {
838
+					$custom .= '/';
839
+				}
665 840
 				$custom .= 'CS='.$ident;
666 841
 			}
667 842
 			if ($squawk != '') {
668
-				if ($custom != '') $custom .= '/';
843
+				if ($custom != '') {
844
+					$custom .= '/';
845
+				}
669 846
 				$custom .= 'SQ='.$squawk;
670 847
 			}
671 848
 			if ($verticalrate != '') {
672
-				if ($custom != '') $custom .= '/';
849
+				if ($custom != '') {
850
+					$custom .= '/';
851
+				}
673 852
 				$custom .= 'VR='.$verticalrate;
674 853
 			}
675 854
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
676
-				if ($custom != '') $custom .= '/';
855
+				if ($custom != '') {
856
+					$custom .= '/';
857
+				}
677 858
 				$custom .= 'AI='.$aircraft_icao;
678 859
 			}
679
-			if ($custom != '') $custom = ' '.$custom;
860
+			if ($custom != '') {
861
+				$custom = ' '.$custom;
862
+			}
680 863
 			/*
681 864
 			// Use AMSL altitude
682 865
 			$GeoidClass = new GeoidHeight();
@@ -700,30 +883,44 @@  discard block
 block discarded – undo
700 883
 			//$w = '00';
701 884
 			$custom = '';
702 885
 			if ($ident != '') {
703
-				if ($custom != '') $custom .= '/';
886
+				if ($custom != '') {
887
+					$custom .= '/';
888
+				}
704 889
 				$custom .= 'CS='.str_replace(' ','_',$ident);
705 890
 			}
706 891
 			if ($typeid != '') {
707
-				if ($custom != '') $custom .= '/';
892
+				if ($custom != '') {
893
+					$custom .= '/';
894
+				}
708 895
 				$custom .= 'TI='.$typeid;
709 896
 			}
710 897
 			if ($statusid != '') {
711
-				if ($custom != '') $custom .= '/';
898
+				if ($custom != '') {
899
+					$custom .= '/';
900
+				}
712 901
 				$custom .= 'SI='.$statusid;
713 902
 			}
714 903
 			if ($imo != '') {
715
-				if ($custom != '') $custom .= '/';
904
+				if ($custom != '') {
905
+					$custom .= '/';
906
+				}
716 907
 				$custom .= 'IMO='.$imo;
717 908
 			}
718 909
 			if ($arrival_date != '') {
719
-				if ($custom != '') $custom .= '/';
910
+				if ($custom != '') {
911
+					$custom .= '/';
912
+				}
720 913
 				$custom .= 'AD='.strtotime($arrival_date);
721 914
 			}
722 915
 			if ($arrival_code != '') {
723
-				if ($custom != '') $custom .= '/';
916
+				if ($custom != '') {
917
+					$custom .= '/';
918
+				}
724 919
 				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
725 920
 			}
726
-			if ($custom != '') $custom = ' '.$custom;
921
+			if ($custom != '') {
922
+				$custom = ' '.$custom;
923
+			}
727 924
 			$altitude = 0;
728 925
 			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
729 926
 		}
Please login to merge, or discard this patch.
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@  discard block
 block discarded – undo
3 3
 require_once(dirname(__FILE__).'/class.Common.php');
4 4
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
5 5
 class aprs {
6
-    private $socket;
7
-    private $connected = false;
6
+	private $socket;
7
+	private $connected = false;
8 8
 
9
-    protected $symbols = array('/!' => 'Police',
9
+	protected $symbols = array('/!' => 'Police',
10 10
 	'/#' => 'DIGI',
11 11
 	'/$' => 'Phone',
12 12
 	'/%' => 'DX Cluster',
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
 	'\~' => 'TNC Stream SW');
167 167
 	
168 168
 
169
-    private function urshift($n, $s) {
169
+	private function urshift($n, $s) {
170 170
 	return ($n >= 0) ? ($n >> $s) :
171
-	    (($n & 0x7fffffff) >> $s) | 
171
+		(($n & 0x7fffffff) >> $s) | 
172 172
 		(0x40000000 >> ($s - 1));
173
-    }
173
+	}
174 174
 
175
-    public function parse($input) {
175
+	public function parse($input) {
176 176
 	global $globalDebug;
177 177
 	$debug = false;
178 178
 	$result = array();
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	
185 185
 	/* Check that end was found and body has at least one byte. */
186 186
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
187
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
188
-	    return false;
187
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
188
+		return false;
189 189
 	}
190 190
 	
191 191
 	if ($debug) echo 'input : '.$input."\n";
@@ -199,34 +199,34 @@  discard block
 block discarded – undo
199 199
 	/* Parse source, target and path. */
200 200
 	//FLRDF0A52>APRS,qAS,LSTB
201 201
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
202
-	    $ident = $matches[1];
203
-	    $all_elements = $matches[2];
204
-	    if ($ident == 'AIRCRAFT') {
202
+		$ident = $matches[1];
203
+		$all_elements = $matches[2];
204
+		if ($ident == 'AIRCRAFT') {
205 205
 		$result['format_source'] = 'famaprs';
206 206
 		$result['source_type'] = 'modes';
207
-	    } elseif ($ident == 'MARINE') {
207
+		} elseif ($ident == 'MARINE') {
208 208
 		$result['format_source'] = 'famaprs';
209 209
 		$result['source_type'] = 'ais';
210
-	    } else {
210
+		} else {
211 211
 		if ($debug) echo 'ident : '.$ident."\n";
212 212
 		$result['ident'] = $ident;
213
-	    }
213
+		}
214 214
 	} else {
215
-	    if ($debug) 'No ident'."\n";
216
-	    return false;
215
+		if ($debug) 'No ident'."\n";
216
+		return false;
217 217
 	}
218 218
 	$elements = explode(',',$all_elements);
219 219
 	$source = end($elements);
220 220
 	$result['source'] = $source;
221 221
 	foreach ($elements as $element) {
222
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
223
-	        //echo "ok";
224
-	        //if ($element == 'TCPIP*') return false;
225
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
222
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
223
+			//echo "ok";
224
+			//if ($element == 'TCPIP*') return false;
225
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
226 226
 		if ($debug) echo 'element : '.$element."\n";
227 227
 		return false;
228
-	    }
229
-	    /*
228
+		}
229
+		/*
230 230
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
231 231
 		//echo "ok";
232 232
 	    } else {
@@ -253,48 +253,48 @@  discard block
 block discarded – undo
253 253
 	$body_parse = substr($body,1);
254 254
 	//echo 'Body : '.$body."\n";
255 255
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
256
-	    $body_parse = substr($body_parse,10);
257
-	    $find = true;
258
-	    //echo $body_parse."\n";
256
+		$body_parse = substr($body_parse,10);
257
+		$find = true;
258
+		//echo $body_parse."\n";
259 259
 	}
260 260
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
261
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
262
-	    $find = true;
263
-	    //echo $body_parse."\n";
261
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
262
+		$find = true;
263
+		//echo $body_parse."\n";
264 264
 	}
265 265
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
266
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
267
-	    $find = true;
268
-	    //echo $body_parse."\n";
266
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
267
+		$find = true;
268
+		//echo $body_parse."\n";
269 269
 	}
270 270
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
271
-	    $find = true;
272
-	    //print_r($matches);
273
-	    $timestamp = $matches[0];
274
-	    if ($matches[4] == 'h') {
271
+		$find = true;
272
+		//print_r($matches);
273
+		$timestamp = $matches[0];
274
+		if ($matches[4] == 'h') {
275 275
 		$timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]);
276 276
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
277 277
 		/*
278 278
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
279 279
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
280 280
 		*/
281
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
281
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
282 282
 		// This work or not ?
283 283
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
284
-	    }
285
-	    $body_parse = substr($body_parse,7);
286
-	    $result['timestamp'] = $timestamp;
287
-	    //echo date('Ymd H:i:s',$timestamp);
284
+		}
285
+		$body_parse = substr($body_parse,7);
286
+		$result['timestamp'] = $timestamp;
287
+		//echo date('Ymd H:i:s',$timestamp);
288 288
 	}
289 289
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
290
-	    $find = true;
291
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
-	    $body_parse = substr($body_parse,8);
293
-	    $result['timestamp'] = $timestamp;
294
-	    //echo date('Ymd H:i:s',$timestamp);
290
+		$find = true;
291
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
+		$body_parse = substr($body_parse,8);
293
+		$result['timestamp'] = $timestamp;
294
+		//echo date('Ymd H:i:s',$timestamp);
295 295
 	}
296 296
 	//if (strlen($body_parse) > 19) {
297
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
297
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
298 298
 		$find = true;
299 299
 		// 4658.70N/00707.78Ez
300 300
 		//print_r(str_split($body_parse));
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		$lon = intval($lon_deg);
314 314
 		if ($lat > 89 || $lon > 179) return false;
315 315
 	    
316
-	    /*
316
+		/*
317 317
 	    $tmp_5b = str_replace('.','',$lat_min);
318 318
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
319 319
 	        print_r($matches);
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 		$result['longitude'] = $longitude;
328 328
 		$body_parse = substr($body_parse,18);
329 329
 		$body_parse_len = strlen($body_parse);
330
-	    }
331
-	    $body_parse_len = strlen($body_parse);
332
-	    if ($body_parse_len > 0) {
330
+		}
331
+		$body_parse_len = strlen($body_parse);
332
+		if ($body_parse_len > 0) {
333 333
 		/*
334 334
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
335 335
 			$body_split = str_split($body);
@@ -363,95 +363,95 @@  discard block
 block discarded – undo
363 363
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
364 364
 			if ($symbol_code != '_') {
365 365
 			}
366
-		    //$body_parse = substr($body_parse,1);
367
-		    //$body_parse = trim($body_parse);
368
-		    //$body_parse_len = strlen($body_parse);
369
-		    if ($body_parse_len >= 7) {
366
+			//$body_parse = substr($body_parse,1);
367
+			//$body_parse = trim($body_parse);
368
+			//$body_parse_len = strlen($body_parse);
369
+			if ($body_parse_len >= 7) {
370 370
 			
371
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
-		    	    $course = substr($body_parse,0,3);
373
-		    	    $tmp_s = intval($course);
374
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
-		    	    $speed = substr($body_parse,4,3);
376
-		    	    if ($speed != '...') {
377
-		    		//$result['speed'] = round($speed*1.852);
378
-		    		$result['speed'] = intval($speed);
379
-		    	    }
380
-		    	    $body_parse = substr($body_parse,7);
381
-		        }
382
-		        // Check PHGR, PHG, RNG
383
-		    } 
384
-		    /*
371
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
+					$course = substr($body_parse,0,3);
373
+					$tmp_s = intval($course);
374
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
+					$speed = substr($body_parse,4,3);
376
+					if ($speed != '...') {
377
+					//$result['speed'] = round($speed*1.852);
378
+					$result['speed'] = intval($speed);
379
+					}
380
+					$body_parse = substr($body_parse,7);
381
+				}
382
+				// Check PHGR, PHG, RNG
383
+			} 
384
+			/*
385 385
 		    else if ($body_parse_len > 0) {
386 386
 			$rest = $body_parse;
387 387
 		    }
388 388
 		    */
389
-		    if (strlen($body_parse) > 0) {
390
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
391
-		            $altitude = intval($matches[1]);
392
-		            //$result['altitude'] = round($altitude*0.3048);
393
-		            $result['altitude'] = $altitude;
394
-		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
396
-		        }
397
-		    }
389
+			if (strlen($body_parse) > 0) {
390
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
391
+					$altitude = intval($matches[1]);
392
+					//$result['altitude'] = round($altitude*0.3048);
393
+					$result['altitude'] = $altitude;
394
+					//$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
+					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
396
+				}
397
+			}
398 398
 		    
399
-		    // Telemetry
400
-		    /*
399
+			// Telemetry
400
+			/*
401 401
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
402 402
 		        // Nothing yet...
403 403
 		    }
404 404
 		    */
405
-		    // DAO
405
+			// DAO
406 406
 		    
407
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
407
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
408 408
 			    
409
-			    $dao = $matches[1];
410
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
409
+				$dao = $matches[1];
410
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
411 411
 				$dao_split = str_split($dao);
412
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
412
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
414 414
 			    
415 415
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416 416
 				else $result['latitude'] += $lat_off;
417 417
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
418 418
 				else $result['longitude'] += $lon_off;
419
-			    }
419
+				}
420 420
 			    
421
-		            $body_parse = substr($body_parse,6);
422
-		    }
423
-		    //echo 'bodyparse : '.$body_parse."\n";
424
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
421
+					$body_parse = substr($body_parse,6);
422
+			}
423
+			//echo 'bodyparse : '.$body_parse."\n";
424
+			if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
425 425
 			$result['ident'] = str_replace('_',' ',$matches[1]);
426
-		    }
427
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
426
+			}
427
+			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
428 428
 			$result['squawk'] = $matches[1];
429
-		    }
430
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
429
+			}
430
+			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
431 431
 			$result['aircraft_icao'] = $matches[1];
432
-		    }
433
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
432
+			}
433
+			if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
434 434
 			$result['verticalrate'] = $matches[1];
435
-		    }
436
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
435
+			}
436
+			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
437 437
 			$result['typeid'] = $matches[1];
438
-		    }
439
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
438
+			}
439
+			if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
440 440
 			$result['statusid'] = $matches[1];
441
-		    }
442
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
441
+			}
442
+			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
443 443
 			$result['imo'] = $matches[1];
444
-		    }
445
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
444
+			}
445
+			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
446 446
 			$result['arrival_date'] = $matches[1];
447
-		    }
448
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
447
+			}
448
+			if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
449 449
 			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
450
-		    }
451
-		    // OGN comment
450
+			}
451
+			// OGN comment
452 452
 		   // echo "Before OGN : ".$body_parse."\n";
453
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
453
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
455 455
 			$id = $matches[1];
456 456
 			//$mode = substr($id,0,2);
457 457
 			$address = substr($id,2);
@@ -481,42 +481,42 @@  discard block
 block discarded – undo
481 481
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
482 482
 			$result['stealth'] = $stealth;
483 483
 			$result['address'] = $address;
484
-		    }
484
+			}
485 485
 		    
486
-		    //Comment
487
-		    $result['comment'] = trim($body_parse);
486
+			//Comment
487
+			$result['comment'] = trim($body_parse);
488 488
 		//} else {
489
-		    // parse weather
490
-		    //$body_parse = substr($body_parse,1);
491
-		    //$body_parse_len = strlen($body_parse);
492
-		    //echo 'weather'."\n";
493
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
-			    $result['wind_dir'] = intval($matches[1]);
495
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
499
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
489
+			// parse weather
490
+			//$body_parse = substr($body_parse,1);
491
+			//$body_parse_len = strlen($body_parse);
492
+			//echo 'weather'."\n";
493
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
+				$result['wind_dir'] = intval($matches[1]);
495
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
+				$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
499
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
500 500
 			$result['wind_dir'] = intval($matches[1]);
501 501
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
502 502
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
503 503
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
504
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
505
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
504
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
505
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
506 506
 			$result['wind_dir'] = intval($matches[1]);
507 507
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
508 508
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
509
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
510
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
509
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
510
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
511 511
 			$result['wind_dir'] = intval($matches[1]);
512 512
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
513 513
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
514
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
515
-		    }
516
-		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517
-		    //g012t088r000p000P000h38b10110
518
-		    //g011t086r000p000P000h29b10198
519
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
514
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
515
+			}
516
+			//if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517
+			//g012t088r000p000P000h38b10110
518
+			//g011t086r000p000P000h29b10198
519
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520 520
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521 521
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522 522
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
525 525
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526 526
 			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
527
-		        $body_parse = substr($body_parse,strlen($matches[0]));
528
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
527
+				$body_parse = substr($body_parse,strlen($matches[0]));
528
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529 529
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530 530
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531 531
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
534 534
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535 535
 			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
536
-		        $body_parse = substr($body_parse,strlen($matches[0]));
537
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
536
+				$body_parse = substr($body_parse,strlen($matches[0]));
537
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538 538
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539 539
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540 540
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -542,58 +542,58 @@  discard block
 block discarded – undo
542 542
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
543 543
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544 544
 			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
545
-		        $body_parse = substr($body_parse,strlen($matches[0]));
546
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
545
+				$body_parse = substr($body_parse,strlen($matches[0]));
546
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547 547
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548 548
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549 549
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550 550
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
551 551
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552 552
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
553
-		        $body_parse = substr($body_parse,strlen($matches[0]));
554
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
553
+				$body_parse = substr($body_parse,strlen($matches[0]));
554
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555 555
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556 556
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557 557
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558 558
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559 559
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560 560
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
561
-		        $body_parse = substr($body_parse,strlen($matches[0]));
562
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
561
+				$body_parse = substr($body_parse,strlen($matches[0]));
562
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563 563
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564 564
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565 565
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566 566
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
567 567
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568 568
 			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
569
-		        $body_parse = substr($body_parse,strlen($matches[0]));
570
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
569
+				$body_parse = substr($body_parse,strlen($matches[0]));
570
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571 571
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572 572
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
573 573
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574 574
 			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
575
-		        $body_parse = substr($body_parse,strlen($matches[0]));
576
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
575
+				$body_parse = substr($body_parse,strlen($matches[0]));
576
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577 577
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578 578
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579 579
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
580 580
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581 581
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
582
-		        $body_parse = substr($body_parse,strlen($matches[0]));
583
-		    }
584
-		    $result['comment'] = trim($body_parse);
582
+				$body_parse = substr($body_parse,strlen($matches[0]));
583
+			}
584
+			$result['comment'] = trim($body_parse);
585 585
 		}
586 586
 		} else $result['comment'] = trim($body_parse);
587 587
 
588
-	    }
588
+		}
589 589
 	//}
590 590
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591 591
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
592 592
 	if ($debug) print_r($result);
593 593
 	return $result;
594
-    }
594
+	}
595 595
     
596
-    public function connect() {
596
+	public function connect() {
597 597
 	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
598 598
 	$aprs_connect = 0;
599 599
 	$aprs_keep = 120;
@@ -617,24 +617,24 @@  discard block
 block discarded – undo
617 617
 		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
618 618
 		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
619 619
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
620
-			    echo 'APRS user verified !'."\n";
621
-			    $this->connected = true;
622
-			    return true;
623
-			    break;
620
+				echo 'APRS user verified !'."\n";
621
+				$this->connected = true;
622
+				return true;
623
+				break;
624 624
 			}
625 625
 			if (time()-$authstart > 5) {
626
-			    echo 'APRS timeout'."\n";
627
-			    break;
626
+				echo 'APRS timeout'."\n";
627
+				break;
628 628
 			}
629 629
 		}
630 630
 	}
631
-    }
631
+	}
632 632
 
633
-    public function disconnect() {
633
+	public function disconnect() {
634 634
 	socket_close($this->socket);
635
-    }
635
+	}
636 636
     
637
-    public function send($data) {
637
+	public function send($data) {
638 638
 	global $globalDebug;
639 639
 	if ($this->connected === false) $this->connect();
640 640
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 		socket_close($this->socket);
644 644
 		$this->connect();
645 645
 	}
646
-    }
646
+	}
647 647
 }
648 648
 
649 649
 class APRSSpotter extends APRS {
Please login to merge, or discard this patch.
Spacing   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -167,8 +167,7 @@  discard block
 block discarded – undo
167 167
 	
168 168
 
169 169
     private function urshift($n, $s) {
170
-	return ($n >= 0) ? ($n >> $s) :
171
-	    (($n & 0x7fffffff) >> $s) | 
170
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
172 171
 		(0x40000000 >> ($s - 1));
173 172
     }
174 173
 
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 	//$split_input = str_split($input);
181 180
 
182 181
 	/* Find the end of header checking for NULL bytes while doing it. */
183
-	$splitpos = strpos($input,':');
182
+	$splitpos = strpos($input, ':');
184 183
 	
185 184
 	/* Check that end was found and body has at least one byte. */
186 185
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -190,15 +189,15 @@  discard block
 block discarded – undo
190 189
 	
191 190
 	if ($debug) echo 'input : '.$input."\n";
192 191
 	/* Save header and body. */
193
-	$body = substr($input,$splitpos+1,$input_len);
192
+	$body = substr($input, $splitpos + 1, $input_len);
194 193
 	$body_len = strlen($body);
195
-	$header = substr($input,0,$splitpos);
194
+	$header = substr($input, 0, $splitpos);
196 195
 	//$header_len = strlen($header);
197 196
 	if ($debug) echo 'header : '.$header."\n";
198 197
 	
199 198
 	/* Parse source, target and path. */
200 199
 	//FLRDF0A52>APRS,qAS,LSTB
201
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
200
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
202 201
 	    $ident = $matches[1];
203 202
 	    $all_elements = $matches[2];
204 203
 	    if ($ident == 'AIRCRAFT') {
@@ -215,14 +214,14 @@  discard block
 block discarded – undo
215 214
 	    if ($debug) 'No ident'."\n";
216 215
 	    return false;
217 216
 	}
218
-	$elements = explode(',',$all_elements);
217
+	$elements = explode(',', $all_elements);
219 218
 	$source = end($elements);
220 219
 	$result['source'] = $source;
221 220
 	foreach ($elements as $element) {
222
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
221
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
223 222
 	        //echo "ok";
224 223
 	        //if ($element == 'TCPIP*') return false;
225
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
224
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
226 225
 		if ($debug) echo 'element : '.$element."\n";
227 226
 		return false;
228 227
 	    }
@@ -235,14 +234,14 @@  discard block
 block discarded – undo
235 234
 	    */
236 235
 	}
237 236
 	
238
-	$type = substr($body,0,1);
237
+	$type = substr($body, 0, 1);
239 238
 	if ($debug) echo 'type : '.$type."\n";
240 239
 	if ($type == ';') {
241 240
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
242
-			$result['address'] = trim(substr($body,1,9));
241
+			$result['address'] = trim(substr($body, 1, 9));
243 242
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
244
-			$result['mmsi'] = trim(substr($body,1,9));
245
-		} else $result['ident'] = trim(substr($body,1,9));
243
+			$result['mmsi'] = trim(substr($body, 1, 9));
244
+		} else $result['ident'] = trim(substr($body, 1, 9));
246 245
 	} elseif ($type == ',') {
247 246
 		// Invalid data or test data
248 247
 		return false;
@@ -250,24 +249,24 @@  discard block
 block discarded – undo
250 249
 	
251 250
 	// Check for Timestamp
252 251
 	$find = false;
253
-	$body_parse = substr($body,1);
252
+	$body_parse = substr($body, 1);
254 253
 	//echo 'Body : '.$body."\n";
255
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
256
-	    $body_parse = substr($body_parse,10);
254
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
255
+	    $body_parse = substr($body_parse, 10);
257 256
 	    $find = true;
258 257
 	    //echo $body_parse."\n";
259 258
 	}
260
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
261
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
259
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
260
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
262 261
 	    $find = true;
263 262
 	    //echo $body_parse."\n";
264 263
 	}
265
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
266
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
264
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
265
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
267 266
 	    $find = true;
268 267
 	    //echo $body_parse."\n";
269 268
 	}
270
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
269
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
271 270
 	    $find = true;
272 271
 	    //print_r($matches);
273 272
 	    $timestamp = $matches[0];
@@ -282,19 +281,19 @@  discard block
 block discarded – undo
282 281
 		// This work or not ?
283 282
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
284 283
 	    }
285
-	    $body_parse = substr($body_parse,7);
284
+	    $body_parse = substr($body_parse, 7);
286 285
 	    $result['timestamp'] = $timestamp;
287 286
 	    //echo date('Ymd H:i:s',$timestamp);
288 287
 	}
289
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
288
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
290 289
 	    $find = true;
291 290
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
-	    $body_parse = substr($body_parse,8);
291
+	    $body_parse = substr($body_parse, 8);
293 292
 	    $result['timestamp'] = $timestamp;
294 293
 	    //echo date('Ymd H:i:s',$timestamp);
295 294
 	}
296 295
 	//if (strlen($body_parse) > 19) {
297
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
296
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
298 297
 		$find = true;
299 298
 		// 4658.70N/00707.78Ez
300 299
 		//print_r(str_split($body_parse));
@@ -321,11 +320,11 @@  discard block
 block discarded – undo
321 320
 	    */
322 321
 		$latitude = $lat + floatval($lat_min)/60;
323 322
 		$longitude = $lon + floatval($lon_min)/60;
324
-		if ($sind == 'S') $latitude = 0-$latitude;
325
-		if ($wind == 'W') $longitude = 0-$longitude;
323
+		if ($sind == 'S') $latitude = 0 - $latitude;
324
+		if ($wind == 'W') $longitude = 0 - $longitude;
326 325
 		$result['latitude'] = $latitude;
327 326
 		$result['longitude'] = $longitude;
328
-		$body_parse = substr($body_parse,18);
327
+		$body_parse = substr($body_parse, 18);
329 328
 		$body_parse_len = strlen($body_parse);
330 329
 	    }
331 330
 	    $body_parse_len = strlen($body_parse);
@@ -357,7 +356,7 @@  discard block
 block discarded – undo
357 356
 		//echo $body_parse;
358 357
 			//if ($type != ';' && $type != '>') {
359 358
 			if ($type != '') {
360
-			$body_parse = substr($body_parse,1);
359
+			$body_parse = substr($body_parse, 1);
361 360
 			$body_parse_len = strlen($body_parse);
362 361
 			$result['symbol_code'] = $symbol_code;
363 362
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -368,16 +367,16 @@  discard block
 block discarded – undo
368 367
 		    //$body_parse_len = strlen($body_parse);
369 368
 		    if ($body_parse_len >= 7) {
370 369
 			
371
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
-		    	    $course = substr($body_parse,0,3);
370
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
371
+		    	    $course = substr($body_parse, 0, 3);
373 372
 		    	    $tmp_s = intval($course);
374 373
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
-		    	    $speed = substr($body_parse,4,3);
374
+		    	    $speed = substr($body_parse, 4, 3);
376 375
 		    	    if ($speed != '...') {
377 376
 		    		//$result['speed'] = round($speed*1.852);
378 377
 		    		$result['speed'] = intval($speed);
379 378
 		    	    }
380
-		    	    $body_parse = substr($body_parse,7);
379
+		    	    $body_parse = substr($body_parse, 7);
381 380
 		        }
382 381
 		        // Check PHGR, PHG, RNG
383 382
 		    } 
@@ -387,12 +386,12 @@  discard block
 block discarded – undo
387 386
 		    }
388 387
 		    */
389 388
 		    if (strlen($body_parse) > 0) {
390
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
389
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
391 390
 		            $altitude = intval($matches[1]);
392 391
 		            //$result['altitude'] = round($altitude*0.3048);
393 392
 		            $result['altitude'] = $altitude;
394 393
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
394
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
396 395
 		        }
397 396
 		    }
398 397
 		    
@@ -404,13 +403,13 @@  discard block
 block discarded – undo
404 403
 		    */
405 404
 		    // DAO
406 405
 		    
407
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
406
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
408 407
 			    
409 408
 			    $dao = $matches[1];
410
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
409
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
411 410
 				$dao_split = str_split($dao);
412
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
411
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
412
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
414 413
 			    
415 414
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416 415
 				else $result['latitude'] += $lat_off;
@@ -418,50 +417,50 @@  discard block
 block discarded – undo
418 417
 				else $result['longitude'] += $lon_off;
419 418
 			    }
420 419
 			    
421
-		            $body_parse = substr($body_parse,6);
420
+		            $body_parse = substr($body_parse, 6);
422 421
 		    }
423 422
 		    //echo 'bodyparse : '.$body_parse."\n";
424
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
425
-			$result['ident'] = str_replace('_',' ',$matches[1]);
423
+		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
424
+			$result['ident'] = str_replace('_', ' ', $matches[1]);
426 425
 		    }
427
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
426
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
428 427
 			$result['squawk'] = $matches[1];
429 428
 		    }
430
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
429
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
431 430
 			$result['aircraft_icao'] = $matches[1];
432 431
 		    }
433
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
432
+		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
434 433
 			$result['verticalrate'] = $matches[1];
435 434
 		    }
436
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
435
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
437 436
 			$result['typeid'] = $matches[1];
438 437
 		    }
439
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
438
+		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
440 439
 			$result['statusid'] = $matches[1];
441 440
 		    }
442
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
441
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
443 442
 			$result['imo'] = $matches[1];
444 443
 		    }
445
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
444
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
446 445
 			$result['arrival_date'] = $matches[1];
447 446
 		    }
448
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
449
-			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
447
+		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
448
+			$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
450 449
 		    }
451 450
 		    // OGN comment
452 451
 		   // echo "Before OGN : ".$body_parse."\n";
453 452
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
453
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
455 454
 			$id = $matches[1];
456 455
 			//$mode = substr($id,0,2);
457
-			$address = substr($id,2);
456
+			$address = substr($id, 2);
458 457
 			//print_r($matches);
459
-			$addressType = (intval(substr($id,0,2),16))&3;
458
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
460 459
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
461 460
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
462 461
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
463 462
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
464
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
463
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
465 464
 			$result['aircrafttype_code'] = $aircraftType;
466 465
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
467 466
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -478,7 +477,7 @@  discard block
 block discarded – undo
478 477
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
479 478
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
480 479
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
481
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
480
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
482 481
 			$result['stealth'] = $stealth;
483 482
 			$result['address'] = $address;
484 483
 		    }
@@ -490,96 +489,96 @@  discard block
 block discarded – undo
490 489
 		    //$body_parse = substr($body_parse,1);
491 490
 		    //$body_parse_len = strlen($body_parse);
492 491
 		    //echo 'weather'."\n";
493
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
492
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
494 493
 			    $result['wind_dir'] = intval($matches[1]);
495
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
499
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
495
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
496
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
497
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
498
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
500 499
 			$result['wind_dir'] = intval($matches[1]);
501
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
502
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
503
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
504
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
505
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
500
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
501
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
502
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
503
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
504
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
506 505
 			$result['wind_dir'] = intval($matches[1]);
507
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
508
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
509
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
510
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
506
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
507
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
508
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
509
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
511 510
 			$result['wind_dir'] = intval($matches[1]);
512
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
513
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
514
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
511
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
512
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
513
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
515 514
 		    }
516 515
 		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517 516
 		    //g012t088r000p000P000h38b10110
518 517
 		    //g011t086r000p000P000h29b10198
519
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
518
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
519
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
520
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
521
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
522
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
523
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
525 524
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
527
-		        $body_parse = substr($body_parse,strlen($matches[0]));
528
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
532
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
533
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
525
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
526
+		        $body_parse = substr($body_parse, strlen($matches[0]));
527
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
528
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
529
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
530
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
531
+			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1);
532
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
534 533
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
536
-		        $body_parse = substr($body_parse,strlen($matches[0]));
537
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
541
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
542
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
534
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
535
+		        $body_parse = substr($body_parse, strlen($matches[0]));
536
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
537
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
538
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
539
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
540
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
541
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
543 542
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
545
-		        $body_parse = substr($body_parse,strlen($matches[0]));
546
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
543
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
544
+		        $body_parse = substr($body_parse, strlen($matches[0]));
545
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
546
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
547
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
548
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
549
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
551 550
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
553
-		        $body_parse = substr($body_parse,strlen($matches[0]));
554
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
551
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
552
+		        $body_parse = substr($body_parse, strlen($matches[0]));
553
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
554
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
555
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
556
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
557
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
559 558
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
561
-		        $body_parse = substr($body_parse,strlen($matches[0]));
562
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
560
+		        $body_parse = substr($body_parse, strlen($matches[0]));
561
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
562
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
563
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
564
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
565
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
567 566
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
569
-		        $body_parse = substr($body_parse,strlen($matches[0]));
570
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
567
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
568
+		        $body_parse = substr($body_parse, strlen($matches[0]));
569
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
570
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
571
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
573 572
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
575
-		        $body_parse = substr($body_parse,strlen($matches[0]));
576
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
573
+			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1);
574
+		        $body_parse = substr($body_parse, strlen($matches[0]));
575
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
576
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
577
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
578
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
580 579
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
582
-		        $body_parse = substr($body_parse,strlen($matches[0]));
580
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
581
+		        $body_parse = substr($body_parse, strlen($matches[0]));
583 582
 		    }
584 583
 		    $result['comment'] = trim($body_parse);
585 584
 		}
@@ -587,42 +586,42 @@  discard block
 block discarded – undo
587 586
 
588 587
 	    }
589 588
 	//}
590
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
589
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
590
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
592 591
 	if ($debug) print_r($result);
593 592
 	return $result;
594 593
     }
595 594
     
596 595
     public function connect() {
597
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
596
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
598 597
 	$aprs_connect = 0;
599 598
 	$aprs_keep = 120;
600 599
 	$aprs_last_tx = time();
601 600
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
602
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
601
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
603 602
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
604
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
603
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
605 604
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
606 605
 	else $aprs_pass = '-1';
607 606
 	
608
-	$aprs_filter  = '';
607
+	$aprs_filter = '';
609 608
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
610 609
 	$Common = new Common();
611
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
610
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
612 611
 	if ($s !== false) {
613 612
 		echo 'Connected to APRS server! '."\n";
614 613
 		$authstart = time();
615 614
 		$this->socket = $s;
616
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
617
-		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
618
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
615
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
616
+		socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
617
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
619 618
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
620 619
 			    echo 'APRS user verified !'."\n";
621 620
 			    $this->connected = true;
622 621
 			    return true;
623 622
 			    break;
624 623
 			}
625
-			if (time()-$authstart > 5) {
624
+			if (time() - $authstart > 5) {
626 625
 			    echo 'APRS timeout'."\n";
627 626
 			    break;
628 627
 			}
@@ -637,7 +636,7 @@  discard block
 block discarded – undo
637 636
     public function send($data) {
638 637
 	global $globalDebug;
639 638
 	if ($this->connected === false) $this->connect();
640
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
639
+	$send = socket_send($this->socket, $data, strlen($data), 0);
641 640
 	if ($send === FALSE) {
642 641
 		if ($globalDebug) echo 'Reconnect...';
643 642
 		socket_close($this->socket);
@@ -647,17 +646,17 @@  discard block
 block discarded – undo
647 646
 }
648 647
 
649 648
 class APRSSpotter extends APRS {
650
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
649
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
651 650
 		$Common = new Common();
652 651
 		date_default_timezone_set('UTC');
653 652
 		if ($latitude != '' && $longitude != '') {
654 653
 			$lat = $latitude;
655 654
 			$long = $longitude;
656
-			$latitude = $Common->convertDM($latitude,'latitude');
657
-			$longitude = $Common->convertDM($longitude,'longitude');
658
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
659
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
660
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
655
+			$latitude = $Common->convertDM($latitude, 'latitude');
656
+			$longitude = $Common->convertDM($longitude, 'longitude');
657
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
658
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
659
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
661 660
 			$w = $w1.$w2;
662 661
 			//$w = '00';
663 662
 			$custom = '';
@@ -684,26 +683,26 @@  discard block
 block discarded – undo
684 683
 			$geoid= round($GeoidClass->get($lat,$long)*3.28084,2);
685 684
 			$altitude_real = round($altitude_real + $geoid);
686 685
 			*/
687
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
686
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
688 687
 		}
689 688
 	}
690 689
 }
691 690
 class APRSMarine extends APRS {
692
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
691
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
693 692
 		$Common = new Common();
694 693
 		date_default_timezone_set('UTC');
695 694
 		if ($latitude != '' && $longitude != '') {
696
-			$latitude = $Common->convertDM($latitude,'latitude');
697
-			$longitude = $Common->convertDM($longitude,'longitude');
698
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
699
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
700
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
695
+			$latitude = $Common->convertDM($latitude, 'latitude');
696
+			$longitude = $Common->convertDM($longitude, 'longitude');
697
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
698
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
699
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
701 700
 			$w = $w1.$w2;
702 701
 			//$w = '00';
703 702
 			$custom = '';
704 703
 			if ($ident != '') {
705 704
 				if ($custom != '') $custom .= '/';
706
-				$custom .= 'CS='.str_replace(' ','_',$ident);
705
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
707 706
 			}
708 707
 			if ($typeid != '') {
709 708
 				if ($custom != '') $custom .= '/';
@@ -723,11 +722,11 @@  discard block
 block discarded – undo
723 722
 			}
724 723
 			if ($arrival_code != '') {
725 724
 				if ($custom != '') $custom .= '/';
726
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
725
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
727 726
 			}
728 727
 			if ($custom != '') $custom = ' '.$custom;
729 728
 			$altitude = 0;
730
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
729
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
731 730
 		}
732 731
 	}
733 732
 }
Please login to merge, or discard this patch.
require/class.ATC.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 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;
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	/**
13
-	* Get SQL query part for filter used
14
-	* @param Array $filter the filter
15
-	* @return Array the SQL part
16
-	*/
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17 17
 	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
19 19
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@  discard block
 block discarded – undo
7 7
 	public function __construct($dbc = null) {
8 8
 		$Connection = new Connection($dbc);
9 9
 		$this->db = $Connection->db;
10
-		if ($this->db === null) die('Error: No DB connection. (ATC)');
10
+		if ($this->db === null) {
11
+			die('Error: No DB connection. (ATC)');
12
+		}
11 13
 	}
12 14
 
13 15
 	/**
@@ -20,20 +22,27 @@  discard block
 block discarded – undo
20 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 24
 				foreach($globalStatsFilters[$globalFilterName] as $source) {
23
-					if (isset($source['source'])) $filter['source'][] = $source['source'];
25
+					if (isset($source['source'])) {
26
+						$filter['source'][] = $source['source'];
27
+					}
24 28
 				}
25 29
 			} else {
26 30
 				$filter = $globalStatsFilters[$globalFilterName];
27 31
 			}
28 32
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) {
34
+			$filter = array_merge($filter,$globalFilter);
35
+		}
30 36
 		$filter_query_join = '';
31 37
 		$filter_query_where = '';
32 38
 		if (isset($filter['source']) && !empty($filter['source'])) {
33 39
 			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
34 40
 		}
35
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
41
+		if ($filter_query_where == '' && $where) {
42
+			$filter_query_where = ' WHERE';
43
+		} elseif ($filter_query_where != '' && $and) {
44
+			$filter_query_where .= ' AND';
45
+		}
37 46
 		$filter_query = $filter_query_join.$filter_query_where;
38 47
 		return $filter_query;
39 48
 	}
@@ -90,7 +99,9 @@  discard block
 block discarded – undo
90 99
 		$info = str_replace('^','<br />',$info);
91 100
 		$info = str_replace('&amp;sect;','',$info);
92 101
 		$info = str_replace('"','',$info);
93
-		if ($type == '') $type = NULL;
102
+		if ($type == '') {
103
+			$type = NULL;
104
+		}
94 105
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
95 106
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
96 107
 		try {
@@ -106,7 +117,9 @@  discard block
 block discarded – undo
106 117
 		$info = str_replace('^','<br />',$info);
107 118
 		$info = str_replace('&amp;sect;','',$info);
108 119
 		$info = str_replace('"','',$info);
109
-		if ($type == '') $type = NULL;
120
+		if ($type == '') {
121
+			$type = NULL;
122
+		}
110 123
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
111 124
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
112 125
 		try {
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
 	* @param Array $filter the filter
16 16
 	* @return Array the SQL part
17 17
 	*/
18
-	public function getFilter($filter = array(),$where = false,$and = false) {
18
+	public function getFilter($filter = array(), $where = false, $and = false) {
19 19
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22
-				foreach($globalStatsFilters[$globalFilterName] as $source) {
22
+				foreach ($globalStatsFilters[$globalFilterName] as $source) {
23 23
 					if (isset($source['source'])) $filter['source'][] = $source['source'];
24 24
 				}
25 25
 			} else {
26 26
 				$filter = $globalStatsFilters[$globalFilterName];
27 27
 			}
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 		$filter_query_join = '';
31 31
 		$filter_query_where = '';
32 32
 		if (isset($filter['source']) && !empty($filter['source'])) {
33
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
33
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
34 34
 		}
35 35
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36 36
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		try {
46 46
 			$sth = $this->db->prepare($query);
47 47
 			$sth->execute($query_values);
48
-		} catch(PDOException $e) {
48
+		} catch (PDOException $e) {
49 49
 			return "error : ".$e->getMessage();
50 50
 		}
51 51
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -53,66 +53,66 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 
55 55
 	public function getById($id) {
56
-		$filter_query = $this->getFilter(array(),true,true);
56
+		$filter_query = $this->getFilter(array(), true, true);
57 57
 		$query = "SELECT * FROM atc".$filter_query." atc_id = :id";
58 58
 		$query_values = array(':id' => $id);
59 59
 		try {
60 60
 			$sth = $this->db->prepare($query);
61 61
 			$sth->execute($query_values);
62
-		} catch(PDOException $e) {
62
+		} catch (PDOException $e) {
63 63
 			return "error : ".$e->getMessage();
64 64
 		}
65 65
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
66 66
 		return $all;
67 67
 	}
68 68
 
69
-	public function getByIdent($ident,$format_source = '') {
70
-		$filter_query = $this->getFilter(array(),true,true);
69
+	public function getByIdent($ident, $format_source = '') {
70
+		$filter_query = $this->getFilter(array(), true, true);
71 71
 		if ($format_source == '') {
72 72
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident";
73 73
 			$query_values = array(':ident' => $ident);
74 74
 		} else {
75 75
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source";
76
-			$query_values = array(':ident' => $ident,':format_source' => $format_source);
76
+			$query_values = array(':ident' => $ident, ':format_source' => $format_source);
77 77
 		}
78 78
 		try {
79 79
 			$sth = $this->db->prepare($query);
80 80
 			$sth->execute($query_values);
81
-		} catch(PDOException $e) {
81
+		} catch (PDOException $e) {
82 82
 			return "error : ".$e->getMessage();
83 83
 		}
84 84
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
85 85
 		return $all;
86 86
 	}
87 87
 
88
-	public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
89
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
90
-		$info = str_replace('^','<br />',$info);
91
-		$info = str_replace('&amp;sect;','',$info);
92
-		$info = str_replace('"','',$info);
88
+	public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
89
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
90
+		$info = str_replace('^', '<br />', $info);
91
+		$info = str_replace('&amp;sect;', '', $info);
92
+		$info = str_replace('"', '', $info);
93 93
 		if ($type == '') $type = NULL;
94 94
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
95
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
95
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
96 96
 		try {
97 97
 			$sth = $this->db->prepare($query);
98 98
 			$sth->execute($query_values);
99
-		} catch(PDOException $e) {
99
+		} catch (PDOException $e) {
100 100
 			return "error : ".$e->getMessage();
101 101
 		}
102 102
 	}
103 103
 
104
-	public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
105
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
106
-		$info = str_replace('^','<br />',$info);
107
-		$info = str_replace('&amp;sect;','',$info);
108
-		$info = str_replace('"','',$info);
104
+	public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
105
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
106
+		$info = str_replace('^', '<br />', $info);
107
+		$info = str_replace('&amp;sect;', '', $info);
108
+		$info = str_replace('"', '', $info);
109 109
 		if ($type == '') $type = NULL;
110 110
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
111
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
111
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
112 112
 		try {
113 113
 			$sth = $this->db->prepare($query);
114 114
 			$sth->execute($query_values);
115
-		} catch(PDOException $e) {
115
+		} catch (PDOException $e) {
116 116
 			return "error : ".$e->getMessage();
117 117
 		}
118 118
 	}
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
 		try {
124 124
 			$sth = $this->db->prepare($query);
125 125
 			$sth->execute($query_values);
126
-		} catch(PDOException $e) {
126
+		} catch (PDOException $e) {
127 127
 			return "error : ".$e->getMessage();
128 128
 		}
129 129
 	}
130 130
 
131
-	public function deleteByIdent($ident,$format_source) {
131
+	public function deleteByIdent($ident, $format_source) {
132 132
 		$query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source";
133
-		$query_values = array(':ident' => $ident,':format_source' => $format_source);
133
+		$query_values = array(':ident' => $ident, ':format_source' => $format_source);
134 134
 		try {
135 135
 			$sth = $this->db->prepare($query);
136 136
 			$sth->execute($query_values);
137
-		} catch(PDOException $e) {
137
+		} catch (PDOException $e) {
138 138
 			return "error : ".$e->getMessage();
139 139
 		}
140 140
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		try {
146 146
 			$sth = $this->db->prepare($query);
147 147
 			$sth->execute($query_values);
148
-		} catch(PDOException $e) {
148
+		} catch (PDOException $e) {
149 149
 			return "error : ".$e->getMessage();
150 150
 		}
151 151
 	}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute();
163
-		} catch(PDOException $e) {
163
+		} catch (PDOException $e) {
164 164
 			return "error";
165 165
 		}
166 166
 		return "success";
Please login to merge, or discard this patch.