@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | if (!isset($globalDemo)) { |
13 | 13 | if (isset($_GET['coord'])) |
14 | 14 | { |
15 | - $coords = explode(',',$_GET['coord']); |
|
15 | + $coords = explode(',', $_GET['coord']); |
|
16 | 16 | // $spotter_array = Source::getAllLocationInfobyCoord($coords); |
17 | 17 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
18 | 18 | || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $output = '{"type": "FeatureCollection","features": ['; |
34 | 34 | if (!empty($spotter_array) && count($spotter_array) > 0) |
35 | 35 | { |
36 | - foreach($spotter_array as $spotter_item) |
|
36 | + foreach ($spotter_array as $spotter_item) |
|
37 | 37 | { |
38 | 38 | date_default_timezone_set('UTC'); |
39 | 39 | //waypoint plotting |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | $output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",'; |
53 | 53 | $output .= '"type": "'.$spotter_item['type'].'",'; |
54 | 54 | if ($spotter_item['type'] == 'wx') { |
55 | - $weather = json_decode($spotter_item['description'],true); |
|
56 | - if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",'; |
|
55 | + $weather = json_decode($spotter_item['description'], true); |
|
56 | + if (isset($weather['temp'])) $output .= '"temp": "'.$weather['temp'].'",'; |
|
57 | 57 | } |
58 | 58 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
59 | 59 | $output .= '},'; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $output .= '}'; |
66 | 66 | $output .= '},'; |
67 | 67 | } |
68 | - $output = substr($output, 0, -1); |
|
68 | + $output = substr($output, 0, -1); |
|
69 | 69 | } |
70 | 70 | $output .= ']}'; |
71 | 71 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | try { |
16 | 16 | $sth = $this->db->prepare($query); |
17 | 17 | $sth->execute($query_values); |
18 | - } catch(PDOException $e) { |
|
18 | + } catch (PDOException $e) { |
|
19 | 19 | return "error : ".$e->getMessage(); |
20 | 20 | } |
21 | 21 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | try { |
29 | 29 | $sth = $this->db->prepare($query); |
30 | 30 | $sth->execute($query_values); |
31 | - } catch(PDOException $e) { |
|
31 | + } catch (PDOException $e) { |
|
32 | 32 | return "error : ".$e->getMessage(); |
33 | 33 | } |
34 | 34 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | 35 | return $all; |
36 | 36 | } |
37 | 37 | |
38 | - public function getLocationInfobyNameType($name,$type) { |
|
38 | + public function getLocationInfobyNameType($name, $type) { |
|
39 | 39 | $query = "SELECT * FROM source_location WHERE name = :name AND type = :type"; |
40 | - $query_values = array(':name' => $name,':type' => $type); |
|
40 | + $query_values = array(':name' => $name, ':type' => $type); |
|
41 | 41 | try { |
42 | 42 | $sth = $this->db->prepare($query); |
43 | 43 | $sth->execute($query_values); |
44 | - } catch(PDOException $e) { |
|
44 | + } catch (PDOException $e) { |
|
45 | 45 | return "error : ".$e->getMessage(); |
46 | 46 | } |
47 | 47 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | try { |
55 | 55 | $sth = $this->db->prepare($query); |
56 | 56 | $sth->execute($query_values); |
57 | - } catch(PDOException $e) { |
|
57 | + } catch (PDOException $e) { |
|
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | try { |
68 | 68 | $sth = $this->db->prepare($query); |
69 | 69 | $sth->execute($query_values); |
70 | - } catch(PDOException $e) { |
|
70 | + } catch (PDOException $e) { |
|
71 | 71 | return "error : ".$e->getMessage(); |
72 | 72 | } |
73 | 73 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | try { |
81 | 81 | $sth = $this->db->prepare($query); |
82 | 82 | $sth->execute($query_values); |
83 | - } catch(PDOException $e) { |
|
83 | + } catch (PDOException $e) { |
|
84 | 84 | return "error : ".$e->getMessage(); |
85 | 85 | } |
86 | 86 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -93,56 +93,56 @@ discard block |
||
93 | 93 | try { |
94 | 94 | $sth = $this->db->prepare($query); |
95 | 95 | $sth->execute($query_values); |
96 | - } catch(PDOException $e) { |
|
96 | + } catch (PDOException $e) { |
|
97 | 97 | return "error : ".$e->getMessage(); |
98 | 98 | } |
99 | 99 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
100 | 100 | return $all; |
101 | 101 | } |
102 | 102 | |
103 | - public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
|
103 | + public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
104 | 104 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
105 | 105 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
106 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
106 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
107 | 107 | try { |
108 | 108 | $sth = $this->db->prepare($query); |
109 | 109 | $sth->execute($query_values); |
110 | - } catch(PDOException $e) { |
|
110 | + } catch (PDOException $e) { |
|
111 | 111 | echo "error : ".$e->getMessage(); |
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
|
115 | + public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
116 | 116 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
117 | 117 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
118 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
118 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
119 | 119 | try { |
120 | 120 | $sth = $this->db->prepare($query); |
121 | 121 | $sth->execute($query_values); |
122 | - } catch(PDOException $e) { |
|
122 | + } catch (PDOException $e) { |
|
123 | 123 | return "error : ".$e->getMessage(); |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | - public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') { |
|
127 | + public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') { |
|
128 | 128 | $query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source"; |
129 | - $query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description); |
|
129 | + $query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description); |
|
130 | 130 | try { |
131 | 131 | $sth = $this->db->prepare($query); |
132 | 132 | $sth->execute($query_values); |
133 | - } catch(PDOException $e) { |
|
133 | + } catch (PDOException $e) { |
|
134 | 134 | return "error : ".$e->getMessage(); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
|
138 | + public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') { |
|
139 | 139 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
140 | 140 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
141 | - $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
141 | + $query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
142 | 142 | try { |
143 | 143 | $sth = $this->db->prepare($query); |
144 | 144 | $sth->execute($query_values); |
145 | - } catch(PDOException $e) { |
|
145 | + } catch (PDOException $e) { |
|
146 | 146 | echo "error : ".$e->getMessage(); |
147 | 147 | } |
148 | 148 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | try { |
154 | 154 | $sth = $this->db->prepare($query); |
155 | 155 | $sth->execute($query_values); |
156 | - } catch(PDOException $e) { |
|
156 | + } catch (PDOException $e) { |
|
157 | 157 | return "error : ".$e->getMessage(); |
158 | 158 | } |
159 | 159 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $this->db->prepare($query); |
166 | 166 | $sth->execute($query_values); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error : ".$e->getMessage(); |
169 | 169 | } |
170 | 170 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | try { |
175 | 175 | $sth = $this->db->prepare($query); |
176 | 176 | $sth->execute(); |
177 | - } catch(PDOException $e) { |
|
177 | + } catch (PDOException $e) { |
|
178 | 178 | return "error : ".$e->getMessage(); |
179 | 179 | } |
180 | 180 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | try { |
198 | 198 | $sth = $this->db->prepare($query); |
199 | 199 | $sth->execute(array(':type' => $type)); |
200 | - } catch(PDOException $e) { |
|
200 | + } catch (PDOException $e) { |
|
201 | 201 | return "error"; |
202 | 202 | } |
203 | 203 | return "success"; |
@@ -166,8 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | |
168 | 168 | private function urshift($n, $s) { |
169 | - return ($n >= 0) ? ($n >> $s) : |
|
170 | - (($n & 0x7fffffff) >> $s) | |
|
169 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
171 | 170 | (0x40000000 >> ($s - 1)); |
172 | 171 | } |
173 | 172 | |
@@ -179,7 +178,7 @@ discard block |
||
179 | 178 | //$split_input = str_split($input); |
180 | 179 | |
181 | 180 | /* Find the end of header checking for NULL bytes while doing it. */ |
182 | - $splitpos = strpos($input,':'); |
|
181 | + $splitpos = strpos($input, ':'); |
|
183 | 182 | |
184 | 183 | /* Check that end was found and body has at least one byte. */ |
185 | 184 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -189,15 +188,15 @@ discard block |
||
189 | 188 | |
190 | 189 | if ($debug) echo 'input : '.$input."\n"; |
191 | 190 | /* Save header and body. */ |
192 | - $body = substr($input,$splitpos+1,$input_len); |
|
191 | + $body = substr($input, $splitpos + 1, $input_len); |
|
193 | 192 | $body_len = strlen($body); |
194 | - $header = substr($input,0,$splitpos); |
|
193 | + $header = substr($input, 0, $splitpos); |
|
195 | 194 | //$header_len = strlen($header); |
196 | 195 | if ($debug) echo 'header : '.$header."\n"; |
197 | 196 | |
198 | 197 | /* Parse source, target and path. */ |
199 | 198 | //FLRDF0A52>APRS,qAS,LSTB |
200 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
199 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
201 | 200 | $ident = $matches[1]; |
202 | 201 | $all_elements = $matches[2]; |
203 | 202 | if ($ident == 'AIRCRAFT') { |
@@ -214,14 +213,14 @@ discard block |
||
214 | 213 | if ($debug) 'No ident'."\n"; |
215 | 214 | return false; |
216 | 215 | } |
217 | - $elements = explode(',',$all_elements); |
|
216 | + $elements = explode(',', $all_elements); |
|
218 | 217 | $source = end($elements); |
219 | 218 | $result['source'] = $source; |
220 | 219 | foreach ($elements as $element) { |
221 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
220 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
222 | 221 | //echo "ok"; |
223 | 222 | //if ($element == 'TCPIP*') return false; |
224 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
223 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
225 | 224 | if ($debug) echo 'element : '.$element."\n"; |
226 | 225 | return false; |
227 | 226 | } |
@@ -234,14 +233,14 @@ discard block |
||
234 | 233 | */ |
235 | 234 | } |
236 | 235 | |
237 | - $type = substr($body,0,1); |
|
236 | + $type = substr($body, 0, 1); |
|
238 | 237 | if ($debug) echo 'type : '.$type."\n"; |
239 | 238 | if ($type == ';') { |
240 | 239 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
241 | - $result['address'] = trim(substr($body,1,9)); |
|
240 | + $result['address'] = trim(substr($body, 1, 9)); |
|
242 | 241 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
243 | - $result['mmsi'] = trim(substr($body,1,9)); |
|
244 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
242 | + $result['mmsi'] = trim(substr($body, 1, 9)); |
|
243 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
245 | 244 | } elseif ($type == ',') { |
246 | 245 | // Invalid data or test data |
247 | 246 | return false; |
@@ -249,24 +248,24 @@ discard block |
||
249 | 248 | |
250 | 249 | // Check for Timestamp |
251 | 250 | $find = false; |
252 | - $body_parse = substr($body,1); |
|
251 | + $body_parse = substr($body, 1); |
|
253 | 252 | //echo 'Body : '.$body."\n"; |
254 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
255 | - $body_parse = substr($body_parse,10); |
|
253 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
254 | + $body_parse = substr($body_parse, 10); |
|
256 | 255 | $find = true; |
257 | 256 | //echo $body_parse."\n"; |
258 | 257 | } |
259 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
260 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
258 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
259 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
261 | 260 | $find = true; |
262 | 261 | //echo $body_parse."\n"; |
263 | 262 | } |
264 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
265 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
263 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
264 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
266 | 265 | $find = true; |
267 | 266 | //echo $body_parse."\n"; |
268 | 267 | } |
269 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
268 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
270 | 269 | $find = true; |
271 | 270 | //print_r($matches); |
272 | 271 | $timestamp = $matches[0]; |
@@ -281,19 +280,19 @@ discard block |
||
281 | 280 | // This work or not ? |
282 | 281 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
283 | 282 | } |
284 | - $body_parse = substr($body_parse,7); |
|
283 | + $body_parse = substr($body_parse, 7); |
|
285 | 284 | $result['timestamp'] = $timestamp; |
286 | 285 | //echo date('Ymd H:i:s',$timestamp); |
287 | 286 | } |
288 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
287 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
289 | 288 | $find = true; |
290 | 289 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
291 | - $body_parse = substr($body_parse,8); |
|
290 | + $body_parse = substr($body_parse, 8); |
|
292 | 291 | $result['timestamp'] = $timestamp; |
293 | 292 | //echo date('Ymd H:i:s',$timestamp); |
294 | 293 | } |
295 | 294 | //if (strlen($body_parse) > 19) { |
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)) { |
|
295 | + 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 | 296 | $find = true; |
298 | 297 | // 4658.70N/00707.78Ez |
299 | 298 | //print_r(str_split($body_parse)); |
@@ -320,11 +319,11 @@ discard block |
||
320 | 319 | */ |
321 | 320 | $latitude = $lat + floatval($lat_min)/60; |
322 | 321 | $longitude = $lon + floatval($lon_min)/60; |
323 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
324 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
322 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
323 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
325 | 324 | $result['latitude'] = $latitude; |
326 | 325 | $result['longitude'] = $longitude; |
327 | - $body_parse = substr($body_parse,18); |
|
326 | + $body_parse = substr($body_parse, 18); |
|
328 | 327 | $body_parse_len = strlen($body_parse); |
329 | 328 | } |
330 | 329 | $body_parse_len = strlen($body_parse); |
@@ -356,7 +355,7 @@ discard block |
||
356 | 355 | //echo $body_parse; |
357 | 356 | //if ($type != ';' && $type != '>') { |
358 | 357 | if ($type != '') { |
359 | - $body_parse = substr($body_parse,1); |
|
358 | + $body_parse = substr($body_parse, 1); |
|
360 | 359 | $body_parse_len = strlen($body_parse); |
361 | 360 | $result['symbol_code'] = $symbol_code; |
362 | 361 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
@@ -367,16 +366,16 @@ discard block |
||
367 | 366 | //$body_parse_len = strlen($body_parse); |
368 | 367 | if ($body_parse_len >= 7) { |
369 | 368 | |
370 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
371 | - $course = substr($body_parse,0,3); |
|
369 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
370 | + $course = substr($body_parse, 0, 3); |
|
372 | 371 | $tmp_s = intval($course); |
373 | 372 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
374 | - $speed = substr($body_parse,4,3); |
|
373 | + $speed = substr($body_parse, 4, 3); |
|
375 | 374 | if ($speed != '...') { |
376 | 375 | //$result['speed'] = round($speed*1.852); |
377 | 376 | $result['speed'] = intval($speed); |
378 | 377 | } |
379 | - $body_parse = substr($body_parse,7); |
|
378 | + $body_parse = substr($body_parse, 7); |
|
380 | 379 | } |
381 | 380 | // Check PHGR, PHG, RNG |
382 | 381 | } |
@@ -386,12 +385,12 @@ discard block |
||
386 | 385 | } |
387 | 386 | */ |
388 | 387 | if (strlen($body_parse) > 0) { |
389 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
388 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
390 | 389 | $altitude = intval($matches[1]); |
391 | 390 | //$result['altitude'] = round($altitude*0.3048); |
392 | 391 | $result['altitude'] = $altitude; |
393 | 392 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
394 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
393 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
395 | 394 | } |
396 | 395 | } |
397 | 396 | |
@@ -403,13 +402,13 @@ discard block |
||
403 | 402 | */ |
404 | 403 | // DAO |
405 | 404 | |
406 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
405 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
407 | 406 | |
408 | 407 | $dao = $matches[1]; |
409 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
408 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
410 | 409 | $dao_split = str_split($dao); |
411 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
412 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
410 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
411 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
413 | 412 | |
414 | 413 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
415 | 414 | else $result['latitude'] += $lat_off; |
@@ -417,50 +416,50 @@ discard block |
||
417 | 416 | else $result['longitude'] += $lon_off; |
418 | 417 | } |
419 | 418 | |
420 | - $body_parse = substr($body_parse,6); |
|
419 | + $body_parse = substr($body_parse, 6); |
|
421 | 420 | } |
422 | 421 | |
423 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
424 | - $result['ident'] = str_replace('_',' ',$matches[1]); |
|
422 | + if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
423 | + $result['ident'] = str_replace('_', ' ', $matches[1]); |
|
425 | 424 | } |
426 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
425 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
427 | 426 | $result['squawk'] = $matches[1]; |
428 | 427 | } |
429 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
428 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
430 | 429 | $result['aircraft_icao'] = $matches[1]; |
431 | 430 | } |
432 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
431 | + if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) { |
|
433 | 432 | $result['verticalrate'] = $matches[1]; |
434 | 433 | } |
435 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
434 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
436 | 435 | $result['typeid'] = $matches[1]; |
437 | 436 | } |
438 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
437 | + if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { |
|
439 | 438 | $result['statusid'] = $matches[1]; |
440 | 439 | } |
441 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
440 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
442 | 441 | $result['imo'] = $matches[1]; |
443 | 442 | } |
444 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
443 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
445 | 444 | $result['arrival_date'] = $matches[1]; |
446 | 445 | } |
447 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
448 | - $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
|
446 | + if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
447 | + $result['arrival_code'] = str_replace('_', ' ', $matches[1]); |
|
449 | 448 | } |
450 | 449 | // OGN comment |
451 | 450 | // echo "Before OGN : ".$body_parse."\n"; |
452 | 451 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
453 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
452 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
454 | 453 | $id = $matches[1]; |
455 | 454 | //$mode = substr($id,0,2); |
456 | - $address = substr($id,2); |
|
455 | + $address = substr($id, 2); |
|
457 | 456 | //print_r($matches); |
458 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
457 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
459 | 458 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
460 | 459 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
461 | 460 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
462 | 461 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
463 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
462 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
464 | 463 | $result['aircrafttype_code'] = $aircraftType; |
465 | 464 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
466 | 465 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -477,7 +476,7 @@ discard block |
||
477 | 476 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
478 | 477 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
479 | 478 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
480 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
479 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
481 | 480 | $result['stealth'] = $stealth; |
482 | 481 | $result['address'] = $address; |
483 | 482 | } |
@@ -489,96 +488,96 @@ discard block |
||
489 | 488 | //$body_parse = substr($body_parse,1); |
490 | 489 | //$body_parse_len = strlen($body_parse); |
491 | 490 | //echo 'weather'."\n"; |
492 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
491 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
493 | 492 | $result['wind_dir'] = intval($matches[1]); |
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)) { |
|
493 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
494 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
495 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
496 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
497 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
499 | 498 | $result['wind_dir'] = intval($matches[1]); |
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)) { |
|
499 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
500 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
501 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
502 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
503 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
505 | 504 | $result['wind_dir'] = intval($matches[1]); |
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)) { |
|
505 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
506 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
507 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
508 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
510 | 509 | $result['wind_dir'] = intval($matches[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); |
|
510 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
511 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
512 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
514 | 513 | } |
515 | 514 | //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
516 | 515 | //g012t088r000p000P000h38b10110 |
517 | 516 | //g011t086r000p000P000h29b10198 |
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); |
|
517 | + 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)) { |
|
518 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
519 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
520 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
521 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
522 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
524 | 523 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
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); |
|
524 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
525 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
526 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,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 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
528 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
529 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
530 | + if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1); |
|
531 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
533 | 532 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
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); |
|
533 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
534 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
535 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
536 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
537 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
538 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
539 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
540 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
542 | 541 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
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); |
|
542 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
543 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
544 | + } 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 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
546 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
547 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
548 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
550 | 549 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
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); |
|
550 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
551 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
552 | + } 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 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
554 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
555 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
556 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
558 | 557 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
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); |
|
558 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
559 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
560 | + } 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 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
562 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
563 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
564 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
566 | 565 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
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); |
|
566 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
567 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
568 | + } 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 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
570 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
572 | 571 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
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); |
|
572 | + if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1); |
|
573 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
574 | + } 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 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
576 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
577 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
579 | 578 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
580 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
581 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
579 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
580 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
582 | 581 | } |
583 | 582 | $result['comment'] = trim($body_parse); |
584 | 583 | } |
@@ -586,42 +585,42 @@ discard block |
||
586 | 585 | |
587 | 586 | } |
588 | 587 | //} |
589 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
590 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
588 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
589 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
591 | 590 | if ($debug) print_r($result); |
592 | 591 | return $result; |
593 | 592 | } |
594 | 593 | |
595 | 594 | public function connect() { |
596 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
595 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
597 | 596 | $aprs_connect = 0; |
598 | 597 | $aprs_keep = 120; |
599 | 598 | $aprs_last_tx = time(); |
600 | 599 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
601 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
600 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
602 | 601 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
603 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
602 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
604 | 603 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
605 | 604 | else $aprs_pass = '-1'; |
606 | 605 | |
607 | - $aprs_filter = ''; |
|
606 | + $aprs_filter = ''; |
|
608 | 607 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
609 | 608 | $Common = new Common(); |
610 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
609 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
611 | 610 | if ($s !== false) { |
612 | 611 | echo 'Connected to APRS server! '."\n"; |
613 | 612 | $authstart = time(); |
614 | 613 | $this->socket = $s; |
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)) { |
|
614 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
615 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1); |
|
616 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
618 | 617 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
619 | 618 | echo 'APRS user verified !'."\n"; |
620 | 619 | $this->connected = true; |
621 | 620 | return true; |
622 | 621 | break; |
623 | 622 | } |
624 | - if (time()-$authstart > 5) { |
|
623 | + if (time() - $authstart > 5) { |
|
625 | 624 | echo 'APRS timeout'."\n"; |
626 | 625 | break; |
627 | 626 | } |
@@ -636,7 +635,7 @@ discard block |
||
636 | 635 | public function send($data) { |
637 | 636 | global $globalDebug; |
638 | 637 | if ($this->connected === false) $this->connect(); |
639 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
638 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
640 | 639 | if ($send === FALSE) { |
641 | 640 | if ($globalDebug) echo 'Reconnect...'; |
642 | 641 | socket_close($this->socket); |
@@ -646,14 +645,14 @@ discard block |
||
646 | 645 | } |
647 | 646 | |
648 | 647 | class APRSSpotter extends APRS { |
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) { |
|
648 | + 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) { |
|
650 | 649 | $Common = new Common(); |
651 | 650 | if ($latitude != '' && $longitude != '') { |
652 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
653 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
654 | - $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']; |
|
655 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
656 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
651 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
652 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
653 | + $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']; |
|
654 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
655 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
657 | 656 | $w = $w1.$w2; |
658 | 657 | //$w = '00'; |
659 | 658 | $custom = ''; |
@@ -674,25 +673,25 @@ discard block |
||
674 | 673 | $custom .= 'AI='.$aircraft_icao; |
675 | 674 | } |
676 | 675 | if ($custom != '') $custom = ' '.$custom; |
677 | - $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"); |
|
676 | + $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"); |
|
678 | 677 | } |
679 | 678 | } |
680 | 679 | } |
681 | 680 | class APRSMarine extends APRS { |
682 | - 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) { |
|
681 | + 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) { |
|
683 | 682 | $Common = new Common(); |
684 | 683 | if ($latitude != '' && $longitude != '') { |
685 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
686 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
687 | - $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']; |
|
688 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
689 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
684 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
685 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
686 | + $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']; |
|
687 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
688 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
690 | 689 | $w = $w1.$w2; |
691 | 690 | //$w = '00'; |
692 | 691 | $custom = ''; |
693 | 692 | if ($ident != '') { |
694 | 693 | if ($custom != '') $custom .= '/'; |
695 | - $custom .= 'CS='.str_replace(' ','_',$ident); |
|
694 | + $custom .= 'CS='.str_replace(' ', '_', $ident); |
|
696 | 695 | } |
697 | 696 | if ($typeid != '') { |
698 | 697 | if ($custom != '') $custom .= '/'; |
@@ -712,11 +711,11 @@ discard block |
||
712 | 711 | } |
713 | 712 | if ($arrival_code != '') { |
714 | 713 | if ($custom != '') $custom .= '/'; |
715 | - $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
|
714 | + $custom .= 'AC='.str_replace(' ', '_', $arrival_code); |
|
716 | 715 | } |
717 | 716 | if ($custom != '') $custom = ' '.$custom; |
718 | 717 | $altitude = 0; |
719 | - $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"); |
|
718 | + $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"); |
|
720 | 719 | } |
721 | 720 | } |
722 | 721 | } |