@@ -6,6 +6,9 @@ discard block |
||
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 37; |
8 | 8 | |
9 | + /** |
|
10 | + * @param string $dbname |
|
11 | + */ |
|
9 | 12 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | 13 | global $globalDBdriver, $globalNoDB; |
11 | 14 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
@@ -140,6 +143,9 @@ discard block |
||
140 | 143 | return true; |
141 | 144 | } |
142 | 145 | |
146 | + /** |
|
147 | + * @param string $table |
|
148 | + */ |
|
143 | 149 | public function tableExists($table) |
144 | 150 | { |
145 | 151 | global $globalDBdriver, $globalDBname; |
@@ -189,6 +195,11 @@ discard block |
||
189 | 195 | /* |
190 | 196 | * Check if index exist |
191 | 197 | */ |
198 | + |
|
199 | + /** |
|
200 | + * @param string $table |
|
201 | + * @param string $index |
|
202 | + */ |
|
192 | 203 | public function indexExists($table,$index) |
193 | 204 | { |
194 | 205 | global $globalDBdriver, $globalDBname; |
@@ -231,6 +242,10 @@ discard block |
||
231 | 242 | return $columns; |
232 | 243 | } |
233 | 244 | |
245 | + /** |
|
246 | + * @param string $table |
|
247 | + * @param string $column |
|
248 | + */ |
|
234 | 249 | public function getColumnType($table,$column) { |
235 | 250 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
236 | 251 | $tomet = $select->getColumnMeta(0); |
@@ -241,6 +256,11 @@ discard block |
||
241 | 256 | * Check if a column name exist in a table |
242 | 257 | * @return Boolean column exist or not |
243 | 258 | */ |
259 | + |
|
260 | + /** |
|
261 | + * @param string $table |
|
262 | + * @param string $name |
|
263 | + */ |
|
244 | 264 | public function checkColumnName($table,$name) |
245 | 265 | { |
246 | 266 | global $globalDBdriver, $globalDBname; |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | public $latest_schema = 37; |
8 | 8 | |
9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | - global $globalDBdriver, $globalNoDB; |
|
11 | - if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
10 | + global $globalDBdriver, $globalNoDB; |
|
11 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
12 | 12 | $this->db = null; |
13 | - } else { |
|
13 | + } else { |
|
14 | 14 | if ($dbc === null) { |
15 | - if ($this->db === null && $dbname === null) { |
|
15 | + if ($this->db === null && $dbname === null) { |
|
16 | 16 | if ($user === null && $pass === null) { |
17 | - $this->createDBConnection(); |
|
17 | + $this->createDBConnection(); |
|
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null,$user,$pass); |
|
20 | 20 | } |
21 | - } else { |
|
21 | + } else { |
|
22 | 22 | $this->createDBConnection($dbname); |
23 | - } |
|
23 | + } |
|
24 | 24 | } elseif ($dbname === null || $dbname === 'default') { |
25 | - $this->db = $dbc; |
|
26 | - if ($this->connectionExists() === false) { |
|
25 | + $this->db = $dbc; |
|
26 | + if ($this->connectionExists() === false) { |
|
27 | 27 | /* |
28 | 28 | echo 'Restart Connection !!!'."\n"; |
29 | 29 | $e = new \Exception; |
30 | 30 | var_dump($e->getTraceAsString()); |
31 | 31 | */ |
32 | 32 | $this->createDBConnection(); |
33 | - } |
|
33 | + } |
|
34 | 34 | } else { |
35 | - //$this->connectionExists(); |
|
36 | - $this->dbs[$dbname] = $dbc; |
|
35 | + //$this->connectionExists(); |
|
36 | + $this->dbs[$dbname] = $dbc; |
|
37 | + } |
|
37 | 38 | } |
38 | - } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function db() { |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * Creates the database connection |
|
59 | - * |
|
60 | - * @return Boolean of the database connection |
|
61 | - * |
|
62 | - */ |
|
58 | + * Creates the database connection |
|
59 | + * |
|
60 | + * @return Boolean of the database connection |
|
61 | + * |
|
62 | + */ |
|
63 | 63 | |
64 | 64 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
65 | 65 | { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | if($results->rowCount()>0) { |
159 | - return true; |
|
159 | + return true; |
|
160 | 160 | } |
161 | 161 | else return false; |
162 | 162 | } |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | $sum = $sum->fetchColumn(0); |
174 | 174 | } else $sum = 0; |
175 | 175 | if (intval($sum) !== 2) { |
176 | - return false; |
|
176 | + return false; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | } catch(PDOException $e) { |
180 | 180 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
181 | - throw $e; |
|
182 | - } |
|
183 | - //echo 'error ! '.$e->getMessage(); |
|
181 | + throw $e; |
|
182 | + } |
|
183 | + //echo 'error ! '.$e->getMessage(); |
|
184 | 184 | return false; |
185 | 185 | } |
186 | 186 | return true; |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | $version = 0; |
285 | 285 | if ($this->tableExists('aircraft')) { |
286 | 286 | if (!$this->tableExists('config')) { |
287 | - $version = '1'; |
|
288 | - return $version; |
|
287 | + $version = '1'; |
|
288 | + return $version; |
|
289 | 289 | } else { |
290 | 290 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
291 | 291 | try { |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | * @return Boolean if latest version or not |
307 | 307 | */ |
308 | 308 | public function latest() { |
309 | - global $globalNoDB; |
|
310 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
311 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
312 | - else return false; |
|
309 | + global $globalNoDB; |
|
310 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
311 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
312 | + else return false; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 37; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalDBdriver, $globalNoDB; |
11 | 11 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
12 | 12 | $this->db = null; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | if ($user === null && $pass === null) { |
17 | 17 | $this->createDBConnection(); |
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null, $user, $pass); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $this->createDBConnection($dbname); |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | while (true) { |
100 | 100 | try { |
101 | 101 | if ($globalDBSdriver == 'mysql') { |
102 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
102 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
103 | 103 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
105 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
106 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
107 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
108 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
109 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
105 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
106 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
107 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
108 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
109 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
110 | 110 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
112 | 112 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
117 | 117 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
118 | 118 | } else { |
119 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
119 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
120 | 120 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
121 | 121 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
122 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
123 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
124 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
125 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
126 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
122 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
123 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
124 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
125 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
126 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
127 | 127 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
128 | 128 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
129 | 129 | } |
130 | 130 | break; |
131 | - } catch(PDOException $e) { |
|
131 | + } catch (PDOException $e) { |
|
132 | 132 | $i++; |
133 | 133 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
134 | 134 | //exit; |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | try { |
153 | 153 | //$Connection = new Connection(); |
154 | 154 | $results = $this->db->query($query); |
155 | - } catch(PDOException $e) { |
|
155 | + } catch (PDOException $e) { |
|
156 | 156 | return false; |
157 | 157 | } |
158 | - if($results->rowCount()>0) { |
|
158 | + if ($results->rowCount() > 0) { |
|
159 | 159 | return true; |
160 | 160 | } |
161 | 161 | else return false; |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
179 | - } catch(PDOException $e) { |
|
180 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
179 | + } catch (PDOException $e) { |
|
180 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
181 | 181 | throw $e; |
182 | 182 | } |
183 | 183 | //echo 'error ! '.$e->getMessage(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | /* |
190 | 190 | * Check if index exist |
191 | 191 | */ |
192 | - public function indexExists($table,$index) |
|
192 | + public function indexExists($table, $index) |
|
193 | 193 | { |
194 | 194 | global $globalDBdriver, $globalDBname; |
195 | 195 | if ($globalDBdriver == 'mysql') { |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | try { |
201 | 201 | //$Connection = new Connection(); |
202 | 202 | $results = $this->db->query($query); |
203 | - } catch(PDOException $e) { |
|
203 | + } catch (PDOException $e) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
207 | - if($nb[0]['nb'] > 0) { |
|
207 | + if ($nb[0]['nb'] > 0) { |
|
208 | 208 | return true; |
209 | 209 | } |
210 | 210 | else return false; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
220 | 220 | try { |
221 | 221 | $results = $this->db->query($query); |
222 | - } catch(PDOException $e) { |
|
222 | + } catch (PDOException $e) { |
|
223 | 223 | return "error : ".$e->getMessage()."\n"; |
224 | 224 | } |
225 | 225 | $columns = array(); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | return $columns; |
232 | 232 | } |
233 | 233 | |
234 | - public function getColumnType($table,$column) { |
|
234 | + public function getColumnType($table, $column) { |
|
235 | 235 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
236 | 236 | $tomet = $select->getColumnMeta(0); |
237 | 237 | return $tomet['native_type']; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * Check if a column name exist in a table |
242 | 242 | * @return Boolean column exist or not |
243 | 243 | */ |
244 | - public function checkColumnName($table,$name) |
|
244 | + public function checkColumnName($table, $name) |
|
245 | 245 | { |
246 | 246 | global $globalDBdriver, $globalDBname; |
247 | 247 | if ($globalDBdriver == 'mysql') { |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | } |
252 | 252 | try { |
253 | 253 | $sth = $this->db()->prepare($query); |
254 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
255 | - } catch(PDOException $e) { |
|
254 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
255 | + } catch (PDOException $e) { |
|
256 | 256 | echo "error : ".$e->getMessage()."\n"; |
257 | 257 | } |
258 | 258 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | try { |
292 | 292 | $sth = $this->db->prepare($query); |
293 | 293 | $sth->execute(); |
294 | - } catch(PDOException $e) { |
|
294 | + } catch (PDOException $e) { |
|
295 | 295 | return "error : ".$e->getMessage()."\n"; |
296 | 296 | } |
297 | 297 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -72,8 +72,11 @@ discard block |
||
72 | 72 | $globalDBSname = $globalDBname; |
73 | 73 | $globalDBSuser = $globalDBuser; |
74 | 74 | $globalDBSpass = $globalDBpass; |
75 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
76 | - else $globalDBSport = $globalDBport; |
|
75 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
76 | + $globalDBSport = 3306; |
|
77 | + } else { |
|
78 | + $globalDBSport = $globalDBport; |
|
79 | + } |
|
77 | 80 | } else { |
78 | 81 | $DBname = 'default'; |
79 | 82 | $globalDBSdriver = $globalDBdriver; |
@@ -81,8 +84,11 @@ discard block |
||
81 | 84 | $globalDBSname = $globalDBname; |
82 | 85 | $globalDBSuser = $user; |
83 | 86 | $globalDBSpass = $pass; |
84 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
85 | - else $globalDBSport = $globalDBport; |
|
87 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
88 | + $globalDBSport = 3306; |
|
89 | + } else { |
|
90 | + $globalDBSport = $globalDBport; |
|
91 | + } |
|
86 | 92 | } |
87 | 93 | } else { |
88 | 94 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -90,11 +96,16 @@ discard block |
||
90 | 96 | $globalDBSname = $globalDB[$DBname]['name']; |
91 | 97 | $globalDBSuser = $globalDB[$DBname]['user']; |
92 | 98 | $globalDBSpass = $globalDB[$DBname]['pass']; |
93 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
94 | - else $globalDBSport = 3306; |
|
99 | + if (isset($globalDB[$DBname]['port'])) { |
|
100 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
101 | + } else { |
|
102 | + $globalDBSport = 3306; |
|
103 | + } |
|
95 | 104 | } |
96 | 105 | // Set number of try to connect to DB |
97 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
106 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
107 | + $globalDBretry = 5; |
|
108 | + } |
|
98 | 109 | $i = 0; |
99 | 110 | while (true) { |
100 | 111 | try { |
@@ -103,10 +114,16 @@ discard block |
||
103 | 114 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
104 | 115 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
105 | 116 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
106 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
107 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
108 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
109 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
117 | + if (!isset($globalDBTimeOut)) { |
|
118 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
119 | + } else { |
|
120 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
121 | + } |
|
122 | + if (!isset($globalDBPersistent)) { |
|
123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
124 | + } else { |
|
125 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
126 | + } |
|
110 | 127 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
111 | 128 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
112 | 129 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -120,23 +137,35 @@ discard block |
||
120 | 137 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
121 | 138 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
122 | 139 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
123 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
124 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
125 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
126 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
140 | + if (!isset($globalDBTimeOut)) { |
|
141 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
142 | + } else { |
|
143 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
144 | + } |
|
145 | + if (!isset($globalDBPersistent)) { |
|
146 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
147 | + } else { |
|
148 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
149 | + } |
|
127 | 150 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
128 | 151 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
129 | 152 | } |
130 | 153 | break; |
131 | 154 | } catch(PDOException $e) { |
132 | 155 | $i++; |
133 | - if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
156 | + if (isset($globalDebug) && $globalDebug) { |
|
157 | + echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
158 | + } |
|
134 | 159 | //exit; |
135 | - if ($i > $globalDBretry) return false; |
|
160 | + if ($i > $globalDBretry) { |
|
161 | + return false; |
|
162 | + } |
|
136 | 163 | //return false; |
137 | 164 | } |
138 | 165 | } |
139 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
166 | + if ($DBname === 'default') { |
|
167 | + $this->db = $this->dbs['default']; |
|
168 | + } |
|
140 | 169 | return true; |
141 | 170 | } |
142 | 171 | |
@@ -148,7 +177,9 @@ discard block |
||
148 | 177 | } else { |
149 | 178 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
150 | 179 | } |
151 | - if ($this->db == NULL) return false; |
|
180 | + if ($this->db == NULL) { |
|
181 | + return false; |
|
182 | + } |
|
152 | 183 | try { |
153 | 184 | //$Connection = new Connection(); |
154 | 185 | $results = $this->db->query($query); |
@@ -157,21 +188,28 @@ discard block |
||
157 | 188 | } |
158 | 189 | if($results->rowCount()>0) { |
159 | 190 | return true; |
191 | + } else { |
|
192 | + return false; |
|
160 | 193 | } |
161 | - else return false; |
|
162 | 194 | } |
163 | 195 | |
164 | 196 | public function connectionExists() |
165 | 197 | { |
166 | 198 | global $globalDBdriver, $globalDBCheckConnection; |
167 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
199 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
200 | + return true; |
|
201 | + } |
|
168 | 202 | $query = "SELECT 1 + 1"; |
169 | - if ($this->db === null) return false; |
|
203 | + if ($this->db === null) { |
|
204 | + return false; |
|
205 | + } |
|
170 | 206 | try { |
171 | 207 | $sum = @$this->db->query($query); |
172 | 208 | if ($sum instanceof \PDOStatement) { |
173 | 209 | $sum = $sum->fetchColumn(0); |
174 | - } else $sum = 0; |
|
210 | + } else { |
|
211 | + $sum = 0; |
|
212 | + } |
|
175 | 213 | if (intval($sum) !== 2) { |
176 | 214 | return false; |
177 | 215 | } |
@@ -206,8 +244,9 @@ discard block |
||
206 | 244 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
207 | 245 | if($nb[0]['nb'] > 0) { |
208 | 246 | return true; |
247 | + } else { |
|
248 | + return false; |
|
209 | 249 | } |
210 | - else return false; |
|
211 | 250 | } |
212 | 251 | |
213 | 252 | /* |
@@ -257,9 +296,12 @@ discard block |
||
257 | 296 | } |
258 | 297 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
259 | 298 | $sth->closeCursor(); |
260 | - if ($result['nb'] > 0) return true; |
|
261 | - else return false; |
|
262 | -/* } else { |
|
299 | + if ($result['nb'] > 0) { |
|
300 | + return true; |
|
301 | + } else { |
|
302 | + return false; |
|
303 | + } |
|
304 | + /* } else { |
|
263 | 305 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
264 | 306 | try { |
265 | 307 | $results = $this->db->query($query); |
@@ -298,7 +340,9 @@ discard block |
||
298 | 340 | $sth->closeCursor(); |
299 | 341 | return $result['value']; |
300 | 342 | } |
301 | - } else return $version; |
|
343 | + } else { |
|
344 | + return $version; |
|
345 | + } |
|
302 | 346 | } |
303 | 347 | |
304 | 348 | /* |
@@ -307,9 +351,14 @@ discard block |
||
307 | 351 | */ |
308 | 352 | public function latest() { |
309 | 353 | global $globalNoDB; |
310 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
311 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
312 | - else return false; |
|
354 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
355 | + return true; |
|
356 | + } |
|
357 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
358 | + return true; |
|
359 | + } else { |
|
360 | + return false; |
|
361 | + } |
|
313 | 362 | } |
314 | 363 | |
315 | 364 | } |
@@ -89,6 +89,10 @@ discard block |
||
89 | 89 | 'y' => 'Yagi At QTH'); |
90 | 90 | |
91 | 91 | |
92 | + /** |
|
93 | + * @param integer $n |
|
94 | + * @param integer $s |
|
95 | + */ |
|
92 | 96 | private function urshift($n, $s) { |
93 | 97 | return ($n >= 0) ? ($n >> $s) : |
94 | 98 | (($n & 0x7fffffff) >> $s) | |
@@ -475,6 +479,9 @@ discard block |
||
475 | 479 | socket_close($this->socket); |
476 | 480 | } |
477 | 481 | |
482 | + /** |
|
483 | + * @param string $data |
|
484 | + */ |
|
478 | 485 | public function send($data) { |
479 | 486 | if ($this->connected === false) $this->connect(); |
480 | 487 | $send = socket_send( $this->socket , $data , strlen($data),0); |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
4 | 4 | class aprs { |
5 | - private $socket; |
|
6 | - private $connected = false; |
|
5 | + private $socket; |
|
6 | + private $connected = false; |
|
7 | 7 | |
8 | - protected $symbols = array('!' => 'Police', |
|
8 | + protected $symbols = array('!' => 'Police', |
|
9 | 9 | '#' => 'DIGI', |
10 | 10 | '$' => 'Phone', |
11 | 11 | '%' => 'DX Cluster', |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | 'y' => 'Yagi At QTH'); |
90 | 90 | |
91 | 91 | |
92 | - private function urshift($n, $s) { |
|
92 | + private function urshift($n, $s) { |
|
93 | 93 | return ($n >= 0) ? ($n >> $s) : |
94 | - (($n & 0x7fffffff) >> $s) | |
|
94 | + (($n & 0x7fffffff) >> $s) | |
|
95 | 95 | (0x40000000 >> ($s - 1)); |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - public function parse($input) { |
|
98 | + public function parse($input) { |
|
99 | 99 | global $globalDebug; |
100 | 100 | $debug = false; |
101 | 101 | $result = array(); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | - return false; |
|
110 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | + return false; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if ($debug) echo 'input : '.$input."\n"; |
@@ -122,31 +122,31 @@ discard block |
||
122 | 122 | /* Parse source, target and path. */ |
123 | 123 | //FLRDF0A52>APRS,qAS,LSTB |
124 | 124 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
125 | - $ident = $matches[1]; |
|
126 | - $all_elements = $matches[2]; |
|
127 | - if ($ident == 'AIRCRAFT') { |
|
125 | + $ident = $matches[1]; |
|
126 | + $all_elements = $matches[2]; |
|
127 | + if ($ident == 'AIRCRAFT') { |
|
128 | 128 | $result['format_source'] = 'famaprs'; |
129 | 129 | $result['source_type'] = 'modes'; |
130 | - } elseif ($ident == 'MARINE') { |
|
130 | + } elseif ($ident == 'MARINE') { |
|
131 | 131 | $result['format_source'] = 'famaprs'; |
132 | 132 | $result['source_type'] = 'ais'; |
133 | - } else { |
|
133 | + } else { |
|
134 | 134 | if ($debug) echo 'ident : '.$ident."\n"; |
135 | 135 | $result['ident'] = $ident; |
136 | - } |
|
136 | + } |
|
137 | 137 | } else return false; |
138 | 138 | $elements = explode(',',$all_elements); |
139 | 139 | $source = end($elements); |
140 | 140 | $result['source'] = $source; |
141 | 141 | foreach ($elements as $element) { |
142 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | - //echo "ok"; |
|
144 | - //if ($element == 'TCPIP*') return false; |
|
145 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
142 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | + //echo "ok"; |
|
144 | + //if ($element == 'TCPIP*') return false; |
|
145 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
146 | 146 | if ($debug) echo 'element : '.$element."\n"; |
147 | 147 | return false; |
148 | - } |
|
149 | - /* |
|
148 | + } |
|
149 | + /* |
|
150 | 150 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
151 | 151 | //echo "ok"; |
152 | 152 | } else { |
@@ -171,49 +171,49 @@ discard block |
||
171 | 171 | $body_parse = substr($body,1); |
172 | 172 | //echo 'Body : '.$body."\n"; |
173 | 173 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
174 | - $body_parse = substr($body_parse,10); |
|
175 | - $find = true; |
|
176 | - //echo $body_parse."\n"; |
|
174 | + $body_parse = substr($body_parse,10); |
|
175 | + $find = true; |
|
176 | + //echo $body_parse."\n"; |
|
177 | 177 | } |
178 | 178 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
179 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
180 | - $find = true; |
|
181 | - //echo $body_parse."\n"; |
|
179 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
180 | + $find = true; |
|
181 | + //echo $body_parse."\n"; |
|
182 | 182 | } |
183 | 183 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
184 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
185 | - $find = true; |
|
186 | - //echo $body_parse."\n"; |
|
184 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
185 | + $find = true; |
|
186 | + //echo $body_parse."\n"; |
|
187 | 187 | } |
188 | 188 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
189 | - $find = true; |
|
190 | - //print_r($matches); |
|
191 | - $timestamp = $matches[0]; |
|
192 | - if ($matches[4] == 'h') { |
|
189 | + $find = true; |
|
190 | + //print_r($matches); |
|
191 | + $timestamp = $matches[0]; |
|
192 | + if ($matches[4] == 'h') { |
|
193 | 193 | $timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]); |
194 | 194 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
195 | 195 | /* |
196 | 196 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
197 | 197 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
198 | 198 | */ |
199 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
199 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
200 | 200 | // This work or not ? |
201 | 201 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
202 | - } |
|
203 | - $body_parse = substr($body_parse,7); |
|
204 | - $result['timestamp'] = $timestamp; |
|
205 | - //echo date('Ymd H:i:s',$timestamp); |
|
202 | + } |
|
203 | + $body_parse = substr($body_parse,7); |
|
204 | + $result['timestamp'] = $timestamp; |
|
205 | + //echo date('Ymd H:i:s',$timestamp); |
|
206 | 206 | } |
207 | 207 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
208 | - $find = true; |
|
209 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
210 | - $body_parse = substr($body_parse,8); |
|
211 | - $result['timestamp'] = $timestamp; |
|
212 | - //echo date('Ymd H:i:s',$timestamp); |
|
208 | + $find = true; |
|
209 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
210 | + $body_parse = substr($body_parse,8); |
|
211 | + $result['timestamp'] = $timestamp; |
|
212 | + //echo date('Ymd H:i:s',$timestamp); |
|
213 | 213 | } |
214 | 214 | //if (strlen($body_parse) > 19) { |
215 | - 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)) { |
|
216 | - $find = true; |
|
215 | + 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)) { |
|
216 | + $find = true; |
|
217 | 217 | // 4658.70N/00707.78Ez |
218 | 218 | //print_r(str_split($body_parse)); |
219 | 219 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $lon = intval($lon_deg); |
231 | 231 | if ($lat > 89 || $lon > 179) return false; |
232 | 232 | |
233 | - /* |
|
233 | + /* |
|
234 | 234 | $tmp_5b = str_replace('.','',$lat_min); |
235 | 235 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
236 | 236 | print_r($matches); |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | $result['longitude'] = $longitude; |
245 | 245 | $body_parse = substr($body_parse,18); |
246 | 246 | $body_parse_len = strlen($body_parse); |
247 | - } |
|
248 | - $body_parse_len = strlen($body_parse); |
|
249 | - if ($body_parse_len > 0) { |
|
247 | + } |
|
248 | + $body_parse_len = strlen($body_parse); |
|
249 | + if ($body_parse_len > 0) { |
|
250 | 250 | /* |
251 | 251 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
252 | 252 | $body_split = str_split($body); |
@@ -276,89 +276,89 @@ discard block |
||
276 | 276 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
277 | 277 | if ($symbol_code != '_') { |
278 | 278 | } |
279 | - //$body_parse = substr($body_parse,1); |
|
280 | - //$body_parse = trim($body_parse); |
|
281 | - //$body_parse_len = strlen($body_parse); |
|
282 | - if ($body_parse_len >= 7) { |
|
279 | + //$body_parse = substr($body_parse,1); |
|
280 | + //$body_parse = trim($body_parse); |
|
281 | + //$body_parse_len = strlen($body_parse); |
|
282 | + if ($body_parse_len >= 7) { |
|
283 | 283 | |
284 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
285 | - $course = substr($body_parse,0,3); |
|
286 | - $tmp_s = intval($course); |
|
287 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
288 | - $speed = substr($body_parse,4,3); |
|
289 | - if ($speed != '...') { |
|
290 | - //$result['speed'] = round($speed*1.852); |
|
291 | - $result['speed'] = intval($speed); |
|
292 | - } |
|
293 | - $body_parse = substr($body_parse,7); |
|
294 | - } |
|
295 | - // Check PHGR, PHG, RNG |
|
296 | - } |
|
297 | - /* |
|
284 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
285 | + $course = substr($body_parse,0,3); |
|
286 | + $tmp_s = intval($course); |
|
287 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
288 | + $speed = substr($body_parse,4,3); |
|
289 | + if ($speed != '...') { |
|
290 | + //$result['speed'] = round($speed*1.852); |
|
291 | + $result['speed'] = intval($speed); |
|
292 | + } |
|
293 | + $body_parse = substr($body_parse,7); |
|
294 | + } |
|
295 | + // Check PHGR, PHG, RNG |
|
296 | + } |
|
297 | + /* |
|
298 | 298 | else if ($body_parse_len > 0) { |
299 | 299 | $rest = $body_parse; |
300 | 300 | } |
301 | 301 | */ |
302 | - if (strlen($body_parse) > 0) { |
|
303 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
304 | - $altitude = intval($matches[1]); |
|
305 | - //$result['altitude'] = round($altitude*0.3048); |
|
306 | - $result['altitude'] = $altitude; |
|
307 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
308 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
309 | - } |
|
310 | - } |
|
302 | + if (strlen($body_parse) > 0) { |
|
303 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
304 | + $altitude = intval($matches[1]); |
|
305 | + //$result['altitude'] = round($altitude*0.3048); |
|
306 | + $result['altitude'] = $altitude; |
|
307 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
308 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
309 | + } |
|
310 | + } |
|
311 | 311 | |
312 | - // Telemetry |
|
313 | - /* |
|
312 | + // Telemetry |
|
313 | + /* |
|
314 | 314 | 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)) { |
315 | 315 | // Nothing yet... |
316 | 316 | } |
317 | 317 | */ |
318 | - // DAO |
|
318 | + // DAO |
|
319 | 319 | |
320 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
320 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
321 | 321 | |
322 | - $dao = $matches[1]; |
|
323 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
322 | + $dao = $matches[1]; |
|
323 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
324 | 324 | $dao_split = str_split($dao); |
325 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
326 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
325 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
326 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
327 | 327 | |
328 | 328 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
329 | 329 | else $result['latitude'] += $lat_off; |
330 | 330 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
331 | 331 | else $result['longitude'] += $lon_off; |
332 | - } |
|
332 | + } |
|
333 | 333 | |
334 | - $body_parse = substr($body_parse,6); |
|
335 | - } |
|
334 | + $body_parse = substr($body_parse,6); |
|
335 | + } |
|
336 | 336 | |
337 | - if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
337 | + if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
338 | 338 | $result['ident'] = $matches[1]; |
339 | - } |
|
340 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
339 | + } |
|
340 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
341 | 341 | $result['squawk'] = $matches[1]; |
342 | - } |
|
343 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
342 | + } |
|
343 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
344 | 344 | $result['aircraft_icao'] = $matches[1]; |
345 | - } |
|
346 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
345 | + } |
|
346 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
347 | 347 | $result['typeid'] = $matches[1]; |
348 | - } |
|
349 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
348 | + } |
|
349 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
350 | 350 | $result['imo'] = $matches[1]; |
351 | - } |
|
352 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
351 | + } |
|
352 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
353 | 353 | $result['arrival_date'] = $matches[1]; |
354 | - } |
|
355 | - if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
354 | + } |
|
355 | + if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
356 | 356 | $result['arrival_code'] = $matches[1]; |
357 | - } |
|
358 | - // OGN comment |
|
357 | + } |
|
358 | + // OGN comment |
|
359 | 359 | // echo "Before OGN : ".$body_parse."\n"; |
360 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
361 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
360 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
361 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
362 | 362 | $id = $matches[1]; |
363 | 363 | //$mode = substr($id,0,2); |
364 | 364 | $address = substr($id,2); |
@@ -388,53 +388,53 @@ discard block |
||
388 | 388 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
389 | 389 | $result['stealth'] = $stealth; |
390 | 390 | $result['address'] = $address; |
391 | - } |
|
391 | + } |
|
392 | 392 | |
393 | - //Comment |
|
394 | - $result['comment'] = trim($body_parse); |
|
393 | + //Comment |
|
394 | + $result['comment'] = trim($body_parse); |
|
395 | 395 | } else { |
396 | - // parse weather |
|
397 | - //$body_parse = substr($body_parse,1); |
|
398 | - //$body_parse_len = strlen($body_parse); |
|
396 | + // parse weather |
|
397 | + //$body_parse = substr($body_parse,1); |
|
398 | + //$body_parse_len = strlen($body_parse); |
|
399 | 399 | |
400 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
401 | - $result['wind_dir'] = intval($matches[1]); |
|
402 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
403 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
404 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
405 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
406 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
400 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
401 | + $result['wind_dir'] = intval($matches[1]); |
|
402 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
403 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
404 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
405 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
406 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
407 | 407 | $result['wind_dir'] = intval($matches[1]); |
408 | 408 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
409 | 409 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
410 | 410 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
411 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
412 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
411 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
412 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
413 | 413 | $result['wind_dir'] = intval($matches[1]); |
414 | 414 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
415 | 415 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
416 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
417 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
416 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
417 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
418 | 418 | $result['wind_dir'] = intval($matches[1]); |
419 | 419 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
420 | 420 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
421 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
422 | - } |
|
423 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
421 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
422 | + } |
|
423 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
424 | 424 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
425 | - } |
|
425 | + } |
|
426 | 426 | } |
427 | 427 | } else $result['comment'] = trim($body_parse); |
428 | 428 | |
429 | - } |
|
429 | + } |
|
430 | 430 | //} |
431 | 431 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
432 | 432 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
433 | 433 | if ($debug) print_r($result); |
434 | 434 | return $result; |
435 | - } |
|
435 | + } |
|
436 | 436 | |
437 | - public function connect() { |
|
437 | + public function connect() { |
|
438 | 438 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
439 | 439 | $aprs_connect = 0; |
440 | 440 | $aprs_keep = 120; |
@@ -457,32 +457,32 @@ discard block |
||
457 | 457 | $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
458 | 458 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
459 | 459 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
460 | - echo 'APRS user verified !'."\n"; |
|
461 | - $this->connected = true; |
|
462 | - return true; |
|
463 | - break; |
|
460 | + echo 'APRS user verified !'."\n"; |
|
461 | + $this->connected = true; |
|
462 | + return true; |
|
463 | + break; |
|
464 | 464 | } |
465 | 465 | if (time()-$authstart > 5) { |
466 | - echo 'APRS timeout'."\n"; |
|
467 | - break; |
|
466 | + echo 'APRS timeout'."\n"; |
|
467 | + break; |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE); |
471 | 471 | } |
472 | - } |
|
472 | + } |
|
473 | 473 | |
474 | - public function disconnect() { |
|
474 | + public function disconnect() { |
|
475 | 475 | socket_close($this->socket); |
476 | - } |
|
476 | + } |
|
477 | 477 | |
478 | - public function send($data) { |
|
478 | + public function send($data) { |
|
479 | 479 | if ($this->connected === false) $this->connect(); |
480 | 480 | $send = socket_send( $this->socket , $data , strlen($data),0); |
481 | 481 | if ($send === FALSE) { |
482 | 482 | socket_close($this->socket); |
483 | 483 | $this->connect(); |
484 | 484 | } |
485 | - } |
|
485 | + } |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | class APRSSpotter extends APRS { |
@@ -90,8 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | |
92 | 92 | private function urshift($n, $s) { |
93 | - return ($n >= 0) ? ($n >> $s) : |
|
94 | - (($n & 0x7fffffff) >> $s) | |
|
93 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
95 | 94 | (0x40000000 >> ($s - 1)); |
96 | 95 | } |
97 | 96 | |
@@ -103,7 +102,7 @@ discard block |
||
103 | 102 | //$split_input = str_split($input); |
104 | 103 | |
105 | 104 | /* Find the end of header checking for NULL bytes while doing it. */ |
106 | - $splitpos = strpos($input,':'); |
|
105 | + $splitpos = strpos($input, ':'); |
|
107 | 106 | |
108 | 107 | /* Check that end was found and body has at least one byte. */ |
109 | 108 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -113,15 +112,15 @@ discard block |
||
113 | 112 | |
114 | 113 | if ($debug) echo 'input : '.$input."\n"; |
115 | 114 | /* Save header and body. */ |
116 | - $body = substr($input,$splitpos+1,$input_len); |
|
115 | + $body = substr($input, $splitpos + 1, $input_len); |
|
117 | 116 | $body_len = strlen($body); |
118 | - $header = substr($input,0,$splitpos); |
|
117 | + $header = substr($input, 0, $splitpos); |
|
119 | 118 | //$header_len = strlen($header); |
120 | 119 | if ($debug) echo 'header : '.$header."\n"; |
121 | 120 | |
122 | 121 | /* Parse source, target and path. */ |
123 | 122 | //FLRDF0A52>APRS,qAS,LSTB |
124 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
123 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
125 | 124 | $ident = $matches[1]; |
126 | 125 | $all_elements = $matches[2]; |
127 | 126 | if ($ident == 'AIRCRAFT') { |
@@ -135,14 +134,14 @@ discard block |
||
135 | 134 | $result['ident'] = $ident; |
136 | 135 | } |
137 | 136 | } else return false; |
138 | - $elements = explode(',',$all_elements); |
|
137 | + $elements = explode(',', $all_elements); |
|
139 | 138 | $source = end($elements); |
140 | 139 | $result['source'] = $source; |
141 | 140 | foreach ($elements as $element) { |
142 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
141 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
143 | 142 | //echo "ok"; |
144 | 143 | //if ($element == 'TCPIP*') return false; |
145 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
144 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
146 | 145 | if ($debug) echo 'element : '.$element."\n"; |
147 | 146 | return false; |
148 | 147 | } |
@@ -155,12 +154,12 @@ discard block |
||
155 | 154 | */ |
156 | 155 | } |
157 | 156 | |
158 | - $type = substr($body,0,1); |
|
157 | + $type = substr($body, 0, 1); |
|
159 | 158 | if ($debug) echo 'type : '.$type."\n"; |
160 | 159 | if ($type == ';') { |
161 | 160 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
162 | - $result['address'] = trim(substr($body,1,9)); |
|
163 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
161 | + $result['address'] = trim(substr($body, 1, 9)); |
|
162 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
164 | 163 | } elseif ($type == ',') { |
165 | 164 | // Invalid data or test data |
166 | 165 | return false; |
@@ -168,24 +167,24 @@ discard block |
||
168 | 167 | |
169 | 168 | // Check for Timestamp |
170 | 169 | $find = false; |
171 | - $body_parse = substr($body,1); |
|
170 | + $body_parse = substr($body, 1); |
|
172 | 171 | //echo 'Body : '.$body."\n"; |
173 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
174 | - $body_parse = substr($body_parse,10); |
|
172 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
173 | + $body_parse = substr($body_parse, 10); |
|
175 | 174 | $find = true; |
176 | 175 | //echo $body_parse."\n"; |
177 | 176 | } |
178 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
179 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
177 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
178 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
180 | 179 | $find = true; |
181 | 180 | //echo $body_parse."\n"; |
182 | 181 | } |
183 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
184 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
182 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
183 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
185 | 184 | $find = true; |
186 | 185 | //echo $body_parse."\n"; |
187 | 186 | } |
188 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
187 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
189 | 188 | $find = true; |
190 | 189 | //print_r($matches); |
191 | 190 | $timestamp = $matches[0]; |
@@ -200,19 +199,19 @@ discard block |
||
200 | 199 | // This work or not ? |
201 | 200 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
202 | 201 | } |
203 | - $body_parse = substr($body_parse,7); |
|
202 | + $body_parse = substr($body_parse, 7); |
|
204 | 203 | $result['timestamp'] = $timestamp; |
205 | 204 | //echo date('Ymd H:i:s',$timestamp); |
206 | 205 | } |
207 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
206 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
208 | 207 | $find = true; |
209 | 208 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
210 | - $body_parse = substr($body_parse,8); |
|
209 | + $body_parse = substr($body_parse, 8); |
|
211 | 210 | $result['timestamp'] = $timestamp; |
212 | 211 | //echo date('Ymd H:i:s',$timestamp); |
213 | 212 | } |
214 | 213 | //if (strlen($body_parse) > 19) { |
215 | - 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)) { |
|
214 | + 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)) { |
|
216 | 215 | $find = true; |
217 | 216 | // 4658.70N/00707.78Ez |
218 | 217 | //print_r(str_split($body_parse)); |
@@ -238,11 +237,11 @@ discard block |
||
238 | 237 | */ |
239 | 238 | $latitude = $lat + floatval($lat_min)/60; |
240 | 239 | $longitude = $lon + floatval($lon_min)/60; |
241 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
242 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
240 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
241 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
243 | 242 | $result['latitude'] = $latitude; |
244 | 243 | $result['longitude'] = $longitude; |
245 | - $body_parse = substr($body_parse,18); |
|
244 | + $body_parse = substr($body_parse, 18); |
|
246 | 245 | $body_parse_len = strlen($body_parse); |
247 | 246 | } |
248 | 247 | $body_parse_len = strlen($body_parse); |
@@ -270,7 +269,7 @@ discard block |
||
270 | 269 | //echo $body_parse; |
271 | 270 | //if ($type != ';' && $type != '>') { |
272 | 271 | if ($type != '') { |
273 | - $body_parse = substr($body_parse,1); |
|
272 | + $body_parse = substr($body_parse, 1); |
|
274 | 273 | $body_parse_len = strlen($body_parse); |
275 | 274 | $result['symbol_code'] = $symbol_code; |
276 | 275 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
@@ -281,16 +280,16 @@ discard block |
||
281 | 280 | //$body_parse_len = strlen($body_parse); |
282 | 281 | if ($body_parse_len >= 7) { |
283 | 282 | |
284 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
285 | - $course = substr($body_parse,0,3); |
|
283 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
284 | + $course = substr($body_parse, 0, 3); |
|
286 | 285 | $tmp_s = intval($course); |
287 | 286 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
288 | - $speed = substr($body_parse,4,3); |
|
287 | + $speed = substr($body_parse, 4, 3); |
|
289 | 288 | if ($speed != '...') { |
290 | 289 | //$result['speed'] = round($speed*1.852); |
291 | 290 | $result['speed'] = intval($speed); |
292 | 291 | } |
293 | - $body_parse = substr($body_parse,7); |
|
292 | + $body_parse = substr($body_parse, 7); |
|
294 | 293 | } |
295 | 294 | // Check PHGR, PHG, RNG |
296 | 295 | } |
@@ -300,12 +299,12 @@ discard block |
||
300 | 299 | } |
301 | 300 | */ |
302 | 301 | if (strlen($body_parse) > 0) { |
303 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
302 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
304 | 303 | $altitude = intval($matches[1]); |
305 | 304 | //$result['altitude'] = round($altitude*0.3048); |
306 | 305 | $result['altitude'] = $altitude; |
307 | 306 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
308 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
307 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
309 | 308 | } |
310 | 309 | } |
311 | 310 | |
@@ -317,13 +316,13 @@ discard block |
||
317 | 316 | */ |
318 | 317 | // DAO |
319 | 318 | |
320 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
319 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
321 | 320 | |
322 | 321 | $dao = $matches[1]; |
323 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
322 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
324 | 323 | $dao_split = str_split($dao); |
325 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
326 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
324 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
325 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
327 | 326 | |
328 | 327 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
329 | 328 | else $result['latitude'] += $lat_off; |
@@ -331,44 +330,44 @@ discard block |
||
331 | 330 | else $result['longitude'] += $lon_off; |
332 | 331 | } |
333 | 332 | |
334 | - $body_parse = substr($body_parse,6); |
|
333 | + $body_parse = substr($body_parse, 6); |
|
335 | 334 | } |
336 | 335 | |
337 | - if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
336 | + if (preg_match('/CS=([0-9A-Z]*)/', $body_parse, $matches)) { |
|
338 | 337 | $result['ident'] = $matches[1]; |
339 | 338 | } |
340 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
339 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
341 | 340 | $result['squawk'] = $matches[1]; |
342 | 341 | } |
343 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
342 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
344 | 343 | $result['aircraft_icao'] = $matches[1]; |
345 | 344 | } |
346 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
345 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
347 | 346 | $result['typeid'] = $matches[1]; |
348 | 347 | } |
349 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
348 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
350 | 349 | $result['imo'] = $matches[1]; |
351 | 350 | } |
352 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
351 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
353 | 352 | $result['arrival_date'] = $matches[1]; |
354 | 353 | } |
355 | - if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
354 | + if (preg_match('/AC=([0-9A-Z]*)/', $body_parse, $matches)) { |
|
356 | 355 | $result['arrival_code'] = $matches[1]; |
357 | 356 | } |
358 | 357 | // OGN comment |
359 | 358 | // echo "Before OGN : ".$body_parse."\n"; |
360 | 359 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
361 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
360 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
362 | 361 | $id = $matches[1]; |
363 | 362 | //$mode = substr($id,0,2); |
364 | - $address = substr($id,2); |
|
363 | + $address = substr($id, 2); |
|
365 | 364 | //print_r($matches); |
366 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
365 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
367 | 366 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
368 | 367 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
369 | 368 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
370 | 369 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
371 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
370 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
372 | 371 | $result['aircrafttype_code'] = $aircraftType; |
373 | 372 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
374 | 373 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -385,7 +384,7 @@ discard block |
||
385 | 384 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
386 | 385 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
387 | 386 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
388 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
387 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
389 | 388 | $result['stealth'] = $stealth; |
390 | 389 | $result['address'] = $address; |
391 | 390 | } |
@@ -397,77 +396,77 @@ discard block |
||
397 | 396 | //$body_parse = substr($body_parse,1); |
398 | 397 | //$body_parse_len = strlen($body_parse); |
399 | 398 | |
400 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
399 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
401 | 400 | $result['wind_dir'] = intval($matches[1]); |
402 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
403 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
404 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
405 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
406 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
401 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
402 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
403 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
404 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
405 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
407 | 406 | $result['wind_dir'] = intval($matches[1]); |
408 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
409 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
410 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
411 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
412 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
407 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
408 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
409 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
410 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
411 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
413 | 412 | $result['wind_dir'] = intval($matches[1]); |
414 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
415 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
416 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
417 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
413 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
414 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
415 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
416 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
418 | 417 | $result['wind_dir'] = intval($matches[1]); |
419 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
420 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
421 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
418 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
419 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
420 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
422 | 421 | } |
423 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
424 | - $result['temp'] = round(5/9*(($matches[1])-32),1); |
|
422 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) { |
|
423 | + $result['temp'] = round(5/9*(($matches[1]) - 32), 1); |
|
425 | 424 | } |
426 | 425 | } |
427 | 426 | } else $result['comment'] = trim($body_parse); |
428 | 427 | |
429 | 428 | } |
430 | 429 | //} |
431 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
432 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
430 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
431 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
433 | 432 | if ($debug) print_r($result); |
434 | 433 | return $result; |
435 | 434 | } |
436 | 435 | |
437 | 436 | public function connect() { |
438 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
437 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
439 | 438 | $aprs_connect = 0; |
440 | 439 | $aprs_keep = 120; |
441 | 440 | $aprs_last_tx = time(); |
442 | 441 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
443 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
442 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
444 | 443 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
445 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
444 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
446 | 445 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
447 | 446 | else $aprs_pass = '-1'; |
448 | 447 | |
449 | - $aprs_filter = ''; |
|
448 | + $aprs_filter = ''; |
|
450 | 449 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
451 | 450 | $Common = new Common(); |
452 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
451 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
453 | 452 | if ($s !== false) { |
454 | 453 | echo 'Connected to APRS server! '."\n"; |
455 | 454 | $authstart = time(); |
456 | 455 | $this->socket = $s; |
457 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
458 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
456 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
457 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
459 | 458 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
460 | 459 | echo 'APRS user verified !'."\n"; |
461 | 460 | $this->connected = true; |
462 | 461 | return true; |
463 | 462 | break; |
464 | 463 | } |
465 | - if (time()-$authstart > 5) { |
|
464 | + if (time() - $authstart > 5) { |
|
466 | 465 | echo 'APRS timeout'."\n"; |
467 | 466 | break; |
468 | 467 | } |
469 | 468 | } |
470 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE); |
|
469 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE); |
|
471 | 470 | } |
472 | 471 | } |
473 | 472 | |
@@ -477,7 +476,7 @@ discard block |
||
477 | 476 | |
478 | 477 | public function send($data) { |
479 | 478 | if ($this->connected === false) $this->connect(); |
480 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
479 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
481 | 480 | if ($send === FALSE) { |
482 | 481 | socket_close($this->socket); |
483 | 482 | $this->connect(); |
@@ -486,14 +485,14 @@ discard block |
||
486 | 485 | } |
487 | 486 | |
488 | 487 | class APRSSpotter extends APRS { |
489 | - 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) { |
|
488 | + 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) { |
|
490 | 489 | $Common = new Common(); |
491 | 490 | if ($latitude != '' && $longitude != '') { |
492 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
493 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
494 | - $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']; |
|
495 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
496 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
491 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
492 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
493 | + $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']; |
|
494 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
495 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
497 | 496 | $w = $w1.$w2; |
498 | 497 | //$w = '00'; |
499 | 498 | $custom = ''; |
@@ -510,19 +509,19 @@ discard block |
||
510 | 509 | $custom .= 'AI='.$aircraft_icao; |
511 | 510 | } |
512 | 511 | if ($custom != '') $custom = ' '.$custom; |
513 | - $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"); |
|
512 | + $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"); |
|
514 | 513 | } |
515 | 514 | } |
516 | 515 | } |
517 | 516 | class APRSMarine extends APRS { |
518 | - public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source,$source_name,$over_country) { |
|
517 | + public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country) { |
|
519 | 518 | $Common = new Common(); |
520 | 519 | if ($latitude != '' && $longitude != '') { |
521 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
522 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
523 | - $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']; |
|
524 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
525 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
520 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
521 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
522 | + $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']; |
|
523 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
524 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
526 | 525 | $w = $w1.$w2; |
527 | 526 | //$w = '00'; |
528 | 527 | $custom = ''; |
@@ -548,7 +547,7 @@ discard block |
||
548 | 547 | } |
549 | 548 | if ($custom != '') $custom = ' '.$custom; |
550 | 549 | $altitude = 0; |
551 | - $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"); |
|
550 | + $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"); |
|
552 | 551 | } |
553 | 552 | } |
554 | 553 | } |
@@ -107,17 +107,23 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
110 | + if ($globalDebug) { |
|
111 | + echo '!!! APRS invalid : '.$input."\n"; |
|
112 | + } |
|
111 | 113 | return false; |
112 | 114 | } |
113 | 115 | |
114 | - if ($debug) echo 'input : '.$input."\n"; |
|
116 | + if ($debug) { |
|
117 | + echo 'input : '.$input."\n"; |
|
118 | + } |
|
115 | 119 | /* Save header and body. */ |
116 | 120 | $body = substr($input,$splitpos+1,$input_len); |
117 | 121 | $body_len = strlen($body); |
118 | 122 | $header = substr($input,0,$splitpos); |
119 | 123 | //$header_len = strlen($header); |
120 | - if ($debug) echo 'header : '.$header."\n"; |
|
124 | + if ($debug) { |
|
125 | + echo 'header : '.$header."\n"; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | /* Parse source, target and path. */ |
123 | 129 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -131,10 +137,14 @@ discard block |
||
131 | 137 | $result['format_source'] = 'famaprs'; |
132 | 138 | $result['source_type'] = 'ais'; |
133 | 139 | } else { |
134 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
140 | + if ($debug) { |
|
141 | + echo 'ident : '.$ident."\n"; |
|
142 | + } |
|
135 | 143 | $result['ident'] = $ident; |
136 | 144 | } |
137 | - } else return false; |
|
145 | + } else { |
|
146 | + return false; |
|
147 | + } |
|
138 | 148 | $elements = explode(',',$all_elements); |
139 | 149 | $source = end($elements); |
140 | 150 | $result['source'] = $source; |
@@ -143,7 +153,9 @@ discard block |
||
143 | 153 | //echo "ok"; |
144 | 154 | //if ($element == 'TCPIP*') return false; |
145 | 155 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
146 | - if ($debug) echo 'element : '.$element."\n"; |
|
156 | + if ($debug) { |
|
157 | + echo 'element : '.$element."\n"; |
|
158 | + } |
|
147 | 159 | return false; |
148 | 160 | } |
149 | 161 | /* |
@@ -156,11 +168,15 @@ discard block |
||
156 | 168 | } |
157 | 169 | |
158 | 170 | $type = substr($body,0,1); |
159 | - if ($debug) echo 'type : '.$type."\n"; |
|
171 | + if ($debug) { |
|
172 | + echo 'type : '.$type."\n"; |
|
173 | + } |
|
160 | 174 | if ($type == ';') { |
161 | 175 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
162 | 176 | $result['address'] = trim(substr($body,1,9)); |
163 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
177 | + } else { |
|
178 | + $result['ident'] = trim(substr($body,1,9)); |
|
179 | + } |
|
164 | 180 | } elseif ($type == ',') { |
165 | 181 | // Invalid data or test data |
166 | 182 | return false; |
@@ -228,7 +244,9 @@ discard block |
||
228 | 244 | //$symbol_table = $matches[4]; |
229 | 245 | $lat = intval($lat_deg); |
230 | 246 | $lon = intval($lon_deg); |
231 | - if ($lat > 89 || $lon > 179) return false; |
|
247 | + if ($lat > 89 || $lon > 179) { |
|
248 | + return false; |
|
249 | + } |
|
232 | 250 | |
233 | 251 | /* |
234 | 252 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -238,8 +256,12 @@ discard block |
||
238 | 256 | */ |
239 | 257 | $latitude = $lat + floatval($lat_min)/60; |
240 | 258 | $longitude = $lon + floatval($lon_min)/60; |
241 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
242 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
259 | + if ($sind == 'S') { |
|
260 | + $latitude = 0-$latitude; |
|
261 | + } |
|
262 | + if ($wind == 'W') { |
|
263 | + $longitude = 0-$longitude; |
|
264 | + } |
|
243 | 265 | $result['latitude'] = $latitude; |
244 | 266 | $result['longitude'] = $longitude; |
245 | 267 | $body_parse = substr($body_parse,18); |
@@ -273,7 +295,9 @@ discard block |
||
273 | 295 | $body_parse = substr($body_parse,1); |
274 | 296 | $body_parse_len = strlen($body_parse); |
275 | 297 | $result['symbol_code'] = $symbol_code; |
276 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
298 | + if (isset($this->symbols[$symbol_code])) { |
|
299 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
300 | + } |
|
277 | 301 | if ($symbol_code != '_') { |
278 | 302 | } |
279 | 303 | //$body_parse = substr($body_parse,1); |
@@ -284,7 +308,9 @@ discard block |
||
284 | 308 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
285 | 309 | $course = substr($body_parse,0,3); |
286 | 310 | $tmp_s = intval($course); |
287 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
311 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
312 | + $result['heading'] = intval($course); |
|
313 | + } |
|
288 | 314 | $speed = substr($body_parse,4,3); |
289 | 315 | if ($speed != '...') { |
290 | 316 | //$result['speed'] = round($speed*1.852); |
@@ -325,10 +351,16 @@ discard block |
||
325 | 351 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
326 | 352 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
327 | 353 | |
328 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
329 | - else $result['latitude'] += $lat_off; |
|
330 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
331 | - else $result['longitude'] += $lon_off; |
|
354 | + if ($result['latitude'] < 0) { |
|
355 | + $result['latitude'] -= $lat_off; |
|
356 | + } else { |
|
357 | + $result['latitude'] += $lat_off; |
|
358 | + } |
|
359 | + if ($result['longitude'] < 0) { |
|
360 | + $result['longitude'] -= $lon_off; |
|
361 | + } else { |
|
362 | + $result['longitude'] += $lon_off; |
|
363 | + } |
|
332 | 364 | } |
333 | 365 | |
334 | 366 | $body_parse = substr($body_parse,6); |
@@ -364,27 +396,48 @@ discard block |
||
364 | 396 | $address = substr($id,2); |
365 | 397 | //print_r($matches); |
366 | 398 | $addressType = (intval(substr($id,0,2),16))&3; |
367 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
368 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
369 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
370 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
399 | + if ($addressType == 0) { |
|
400 | + $result['addresstype'] = "RANDOM"; |
|
401 | + } elseif ($addressType == 1) { |
|
402 | + $result['addresstype'] = "ICAO"; |
|
403 | + } elseif ($addressType == 2) { |
|
404 | + $result['addresstype'] = "FLARM"; |
|
405 | + } elseif ($addressType == 3) { |
|
406 | + $result['addresstype'] = "OGN"; |
|
407 | + } |
|
371 | 408 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
372 | 409 | $result['aircrafttype_code'] = $aircraftType; |
373 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
374 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
375 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
376 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
377 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
378 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
379 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
380 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
381 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
382 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
383 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
384 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
385 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
386 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
387 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
410 | + if ($aircraftType == 0) { |
|
411 | + $result['aircrafttype'] = "UNKNOWN"; |
|
412 | + } elseif ($aircraftType == 1) { |
|
413 | + $result['aircrafttype'] = "GLIDER"; |
|
414 | + } elseif ($aircraftType == 2) { |
|
415 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
416 | + } elseif ($aircraftType == 3) { |
|
417 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
418 | + } elseif ($aircraftType == 4) { |
|
419 | + $result['aircrafttype'] = "PARACHUTE"; |
|
420 | + } elseif ($aircraftType == 5) { |
|
421 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
422 | + } elseif ($aircraftType == 6) { |
|
423 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
424 | + } elseif ($aircraftType == 7) { |
|
425 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
426 | + } elseif ($aircraftType == 8) { |
|
427 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
428 | + } elseif ($aircraftType == 9) { |
|
429 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
430 | + } elseif ($aircraftType == 10) { |
|
431 | + $result['aircrafttype'] = "UFO"; |
|
432 | + } elseif ($aircraftType == 11) { |
|
433 | + $result['aircrafttype'] = "BALLOON"; |
|
434 | + } elseif ($aircraftType == 12) { |
|
435 | + $result['aircrafttype'] = "AIRSHIP"; |
|
436 | + } elseif ($aircraftType == 13) { |
|
437 | + $result['aircrafttype'] = "UAV"; |
|
438 | + } elseif ($aircraftType == 15) { |
|
439 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
440 | + } |
|
388 | 441 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
389 | 442 | $result['stealth'] = $stealth; |
390 | 443 | $result['address'] = $address; |
@@ -424,13 +477,21 @@ discard block |
||
424 | 477 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
425 | 478 | } |
426 | 479 | } |
427 | - } else $result['comment'] = trim($body_parse); |
|
480 | + } else { |
|
481 | + $result['comment'] = trim($body_parse); |
|
482 | + } |
|
428 | 483 | |
429 | 484 | } |
430 | 485 | //} |
431 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
432 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
433 | - if ($debug) print_r($result); |
|
486 | + if (isset($result['latitude'])) { |
|
487 | + $result['latitude'] = round($result['latitude'],4); |
|
488 | + } |
|
489 | + if (isset($result['longitude'])) { |
|
490 | + $result['longitude'] = round($result['longitude'],4); |
|
491 | + } |
|
492 | + if ($debug) { |
|
493 | + print_r($result); |
|
494 | + } |
|
434 | 495 | return $result; |
435 | 496 | } |
436 | 497 | |
@@ -439,12 +500,21 @@ discard block |
||
439 | 500 | $aprs_connect = 0; |
440 | 501 | $aprs_keep = 120; |
441 | 502 | $aprs_last_tx = time(); |
442 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
443 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
444 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
445 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
446 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
447 | - else $aprs_pass = '-1'; |
|
503 | + if (isset($globalAPRSversion)) { |
|
504 | + $aprs_version = $globalAPRSversion; |
|
505 | + } else { |
|
506 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
507 | + } |
|
508 | + if (isset($globalServerAPRSssid)) { |
|
509 | + $aprs_ssid = $globalServerAPRSssid; |
|
510 | + } else { |
|
511 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
512 | + } |
|
513 | + if (isset($globalServerAPRSpass)) { |
|
514 | + $aprs_pass = $globalServerAPRSpass; |
|
515 | + } else { |
|
516 | + $aprs_pass = '-1'; |
|
517 | + } |
|
448 | 518 | |
449 | 519 | $aprs_filter = ''; |
450 | 520 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
@@ -476,7 +546,9 @@ discard block |
||
476 | 546 | } |
477 | 547 | |
478 | 548 | public function send($data) { |
479 | - if ($this->connected === false) $this->connect(); |
|
549 | + if ($this->connected === false) { |
|
550 | + $this->connect(); |
|
551 | + } |
|
480 | 552 | $send = socket_send( $this->socket , $data , strlen($data),0); |
481 | 553 | if ($send === FALSE) { |
482 | 554 | socket_close($this->socket); |
@@ -498,18 +570,26 @@ discard block |
||
498 | 570 | //$w = '00'; |
499 | 571 | $custom = ''; |
500 | 572 | if ($ident != '') { |
501 | - if ($custom != '') $custom .= '/'; |
|
573 | + if ($custom != '') { |
|
574 | + $custom .= '/'; |
|
575 | + } |
|
502 | 576 | $custom .= 'CS='.$ident; |
503 | 577 | } |
504 | 578 | if ($squawk != '') { |
505 | - if ($custom != '') $custom .= '/'; |
|
579 | + if ($custom != '') { |
|
580 | + $custom .= '/'; |
|
581 | + } |
|
506 | 582 | $custom .= 'SQ='.$squawk; |
507 | 583 | } |
508 | 584 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
509 | - if ($custom != '') $custom .= '/'; |
|
585 | + if ($custom != '') { |
|
586 | + $custom .= '/'; |
|
587 | + } |
|
510 | 588 | $custom .= 'AI='.$aircraft_icao; |
511 | 589 | } |
512 | - if ($custom != '') $custom = ' '.$custom; |
|
590 | + if ($custom != '') { |
|
591 | + $custom = ' '.$custom; |
|
592 | + } |
|
513 | 593 | $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"); |
514 | 594 | } |
515 | 595 | } |
@@ -527,26 +607,38 @@ discard block |
||
527 | 607 | //$w = '00'; |
528 | 608 | $custom = ''; |
529 | 609 | if ($ident != '') { |
530 | - if ($custom != '') $custom .= '/'; |
|
610 | + if ($custom != '') { |
|
611 | + $custom .= '/'; |
|
612 | + } |
|
531 | 613 | $custom .= 'CS='.$ident; |
532 | 614 | } |
533 | 615 | if ($typeid != '') { |
534 | - if ($custom != '') $custom .= '/'; |
|
616 | + if ($custom != '') { |
|
617 | + $custom .= '/'; |
|
618 | + } |
|
535 | 619 | $custom .= 'TI='.$typeid; |
536 | 620 | } |
537 | 621 | if ($imo != '') { |
538 | - if ($custom != '') $custom .= '/'; |
|
622 | + if ($custom != '') { |
|
623 | + $custom .= '/'; |
|
624 | + } |
|
539 | 625 | $custom .= 'IMO='.$imo; |
540 | 626 | } |
541 | 627 | if ($arrival_date != '') { |
542 | - if ($custom != '') $custom .= '/'; |
|
628 | + if ($custom != '') { |
|
629 | + $custom .= '/'; |
|
630 | + } |
|
543 | 631 | $custom .= 'AD='.strtotime($arrival_date); |
544 | 632 | } |
545 | 633 | if ($arrival_code != '') { |
546 | - if ($custom != '') $custom .= '/'; |
|
634 | + if ($custom != '') { |
|
635 | + $custom .= '/'; |
|
636 | + } |
|
547 | 637 | $custom .= 'AC='.$arrival_code; |
548 | 638 | } |
549 | - if ($custom != '') $custom = ' '.$custom; |
|
639 | + if ($custom != '') { |
|
640 | + $custom = ' '.$custom; |
|
641 | + } |
|
550 | 642 | $altitude = 0; |
551 | 643 | $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"); |
552 | 644 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
3 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
4 | 4 | if ($date == '') $date = date('Y-m-d'); |
5 | 5 | header('Location: '.$globalURL.'/incident/'.$date); |
6 | 6 | ?> |
7 | 7 | \ No newline at end of file |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
4 | -if ($date == '') $date = date('Y-m-d'); |
|
4 | +if ($date == '') { |
|
5 | + $date = date('Y-m-d'); |
|
6 | +} |
|
5 | 7 | header('Location: '.$globalURL.'/incident/'.$date); |
6 | 8 | ?> |
7 | 9 | \ No newline at end of file |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['country'])) { |
6 | - header('Location: '.$globalURL.'/country'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/country'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
|
11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
10 | +$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING))); |
|
11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
12 | 12 | |
13 | 13 | if (isset($_GET['sort'])) { |
14 | 14 | $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort); |
@@ -18,16 +18,16 @@ discard block |
||
18 | 18 | |
19 | 19 | if (!empty($spotter_array)) |
20 | 20 | { |
21 | - $title = sprintf(_("Most Common Airlines by Country of %s"),$country); |
|
21 | + $title = sprintf(_("Most Common Airlines by Country of %s"), $country); |
|
22 | 22 | require_once('header.php'); |
23 | 23 | print '<div class="select-item">'; |
24 | 24 | print '<form action="'.$globalURL.'/country" method="post">'; |
25 | 25 | print '<select name="country" class="selectpicker" data-live-search="true">'; |
26 | 26 | print '<option></option>'; |
27 | 27 | $all_countries = $Spotter->getAllCountries(); |
28 | - foreach($all_countries as $all_country) |
|
28 | + foreach ($all_countries as $all_country) |
|
29 | 29 | { |
30 | - if($country == $all_country['country']) |
|
30 | + if ($country == $all_country['country']) |
|
31 | 31 | { |
32 | 32 | print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>'; |
33 | 33 | } else { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | if ($_GET['country'] != "NA") |
43 | 43 | { |
44 | 44 | print '<div class="info column">'; |
45 | - print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>'; |
|
45 | + print '<h1>'.sprintf(_("Airports & Airlines from %s"), $country).'</h1>'; |
|
46 | 46 | print '</div>'; |
47 | 47 | } else { |
48 | 48 | print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>'; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | include('country-sub-menu.php'); |
52 | 52 | print '<div class="column">'; |
53 | 53 | print '<h2>'._("Most Common Airlines by Country").'</h2>'; |
54 | - print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights from airports & airlines of <strong>%s</strong>."),$country).'</p>'; |
|
54 | + print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights from airports & airlines of <strong>%s</strong>."), $country).'</p>'; |
|
55 | 55 | $airline_array = $Spotter->countAllAirlineCountriesByCountry($country); |
56 | 56 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
57 | 57 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
60 | 60 | print 'var series = ['; |
61 | 61 | $country_data = ''; |
62 | - foreach($airline_array as $airline_item) |
|
62 | + foreach ($airline_array as $airline_item) |
|
63 | 63 | { |
64 | 64 | $country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],'; |
65 | 65 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | print '</thead>'; |
108 | 108 | print '<tbody>'; |
109 | 109 | $i = 1; |
110 | - foreach($airline_array as $airline_item) |
|
110 | + foreach ($airline_array as $airline_item) |
|
111 | 111 | { |
112 | 112 | print '<tr>'; |
113 | 113 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['country'])) { |
6 | - header('Location: '.$globalURL.'/country'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/country'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | include('country-sub-menu.php'); |
52 | 52 | print '<div class="column">'; |
53 | 53 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
54 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."),$country).'</p>'; |
|
54 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."),$country).'</p>'; |
|
55 | 55 | |
56 | 56 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country); |
57 | 57 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
|
11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
10 | +$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING))); |
|
11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
12 | 12 | |
13 | 13 | if (isset($_GET['sort'])) { |
14 | 14 | $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort); |
@@ -18,16 +18,16 @@ discard block |
||
18 | 18 | |
19 | 19 | if (!empty($spotter_array)) |
20 | 20 | { |
21 | - $title = sprintf(_("Most Common Arrival Airports by Country from %s"),$country); |
|
21 | + $title = sprintf(_("Most Common Arrival Airports by Country from %s"), $country); |
|
22 | 22 | require_once('header.php'); |
23 | 23 | print '<div class="select-item">'; |
24 | 24 | print '<form action="'.$globalURL.'/country" method="post">'; |
25 | 25 | print '<select name="country" class="selectpicker" data-live-search="true">'; |
26 | 26 | print '<option></option>'; |
27 | 27 | $all_countries = $Spotter->getAllCountries(); |
28 | - foreach($all_countries as $all_country) |
|
28 | + foreach ($all_countries as $all_country) |
|
29 | 29 | { |
30 | - if($country == $all_country['country']) |
|
30 | + if ($country == $all_country['country']) |
|
31 | 31 | { |
32 | 32 | print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>'; |
33 | 33 | } else { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | if ($_GET['country'] != "NA") |
43 | 43 | { |
44 | 44 | print '<div class="info column">'; |
45 | - print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>'; |
|
45 | + print '<h1>'.sprintf(_("Airports & Airlines from %s"), $country).'</h1>'; |
|
46 | 46 | print '</div>'; |
47 | 47 | } else { |
48 | 48 | print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>'; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | include('country-sub-menu.php'); |
52 | 52 | print '<div class="column">'; |
53 | 53 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
54 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."),$country).'</p>'; |
|
54 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."), $country).'</p>'; |
|
55 | 55 | |
56 | 56 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country); |
57 | 57 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
62 | 62 | print 'var series = ['; |
63 | 63 | $country_data = ''; |
64 | - foreach($airport_country_array as $airport_item) |
|
64 | + foreach ($airport_country_array as $airport_item) |
|
65 | 65 | { |
66 | 66 | $country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
67 | 67 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | print '</thead>'; |
110 | 110 | print '<tbody>'; |
111 | 111 | $i = 1; |
112 | - foreach($airport_country_array as $airport_item) |
|
112 | + foreach ($airport_country_array as $airport_item) |
|
113 | 113 | { |
114 | 114 | print '<tr>'; |
115 | 115 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
12 | - $title = sprintf(_("Most Common Departure Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
12 | + $title = sprintf(_("Most Common Departure Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
13 | 13 | |
14 | 14 | require_once('header.php'); |
15 | 15 | print '<div class="select-item">'; |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
28 | 28 | print '<br />'; |
29 | 29 | print '<div class="info column">'; |
30 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
30 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
31 | 31 | print '</div>'; |
32 | 32 | |
33 | 33 | include('date-sub-menu.php'); |
34 | 34 | print '<div class="column">'; |
35 | 35 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
36 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
36 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
37 | 37 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByDate($date); |
38 | 38 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
39 | 39 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
42 | 42 | print 'var series = ['; |
43 | 43 | $country_data = ''; |
44 | - foreach($airport_country_array as $airport_item) |
|
44 | + foreach ($airport_country_array as $airport_item) |
|
45 | 45 | { |
46 | 46 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
47 | 47 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | print '</thead>'; |
90 | 90 | print '<tbody>'; |
91 | 91 | $i = 1; |
92 | - foreach($airport_country_array as $airport_item) |
|
92 | + foreach ($airport_country_array as $airport_item) |
|
93 | 93 | { |
94 | 94 | print '<tr>'; |
95 | 95 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
12 | - $title = sprintf(_("Most Common Arrival Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
12 | + $title = sprintf(_("Most Common Arrival Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
13 | 13 | require_once('header.php'); |
14 | 14 | print '<div class="select-item">'; |
15 | 15 | print '<form action="'.$globalURL.'/date" method="post" class="form-inline">'; |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
27 | 27 | print '<br />'; |
28 | 28 | print '<div class="info column">'; |
29 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
29 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
30 | 30 | print '</div>'; |
31 | 31 | |
32 | 32 | include('date-sub-menu.php'); |
33 | 33 | print '<div class="column">'; |
34 | 34 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
35 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
35 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
36 | 36 | |
37 | 37 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByDate($date); |
38 | 38 | //print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>'; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | print 'var series = ['; |
75 | 75 | $country_data = ''; |
76 | - foreach($airport_country_array as $airport_item) |
|
76 | + foreach ($airport_country_array as $airport_item) |
|
77 | 77 | { |
78 | 78 | $country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
79 | 79 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | print '</thead>'; |
122 | 122 | print '<tbody>'; |
123 | 123 | $i = 1; |
124 | - foreach($airport_country_array as $airport_item) |
|
124 | + foreach ($airport_country_array as $airport_item) |
|
125 | 125 | { |
126 | 126 | print '<tr>'; |
127 | 127 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
17 | 17 | if (isset($globalMarine) && $globalMarine) { |
18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,40 +24,40 @@ discard block |
||
24 | 24 | // Check if schema is at latest version |
25 | 25 | $Connection = new Connection(); |
26 | 26 | if ($Connection->latest() === false) { |
27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | - exit(); |
|
27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | + exit(); |
|
29 | 29 | } |
30 | 30 | if (PHP_SAPI != 'cli') { |
31 | - echo "This script MUST be called from console, not a web browser."; |
|
31 | + echo "This script MUST be called from console, not a web browser."; |
|
32 | 32 | // exit(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This is to be compatible with old version of settings.php |
36 | 36 | if (!isset($globalSources)) { |
37 | - if (isset($globalSBS1Hosts)) { |
|
38 | - //$hosts = $globalSBS1Hosts; |
|
39 | - foreach ($globalSBS1Hosts as $host) { |
|
40 | - $globalSources[] = array('host' => $host); |
|
41 | - } |
|
42 | - } else { |
|
43 | - if (!isset($globalSBS1Host)) { |
|
44 | - echo '$globalSources MUST be defined !'; |
|
45 | - die; |
|
37 | + if (isset($globalSBS1Hosts)) { |
|
38 | + //$hosts = $globalSBS1Hosts; |
|
39 | + foreach ($globalSBS1Hosts as $host) { |
|
40 | + $globalSources[] = array('host' => $host); |
|
41 | + } |
|
42 | + } else { |
|
43 | + if (!isset($globalSBS1Host)) { |
|
44 | + echo '$globalSources MUST be defined !'; |
|
45 | + die; |
|
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
56 | - $globalSources = array(); |
|
57 | - $globalSources[] = array('host' => $options['s']); |
|
56 | + $globalSources = array(); |
|
57 | + $globalSources[] = array('host' => $options['s']); |
|
58 | 58 | } elseif (isset($options['source'])) { |
59 | - $globalSources = array(); |
|
60 | - $globalSources[] = array('host' => $options['source']); |
|
59 | + $globalSources = array(); |
|
60 | + $globalSources[] = array('host' => $options['source']); |
|
61 | 61 | } |
62 | 62 | if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
63 | 63 | if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
67 | 67 | else $id_source = 1; |
68 | 68 | if (isset($globalServer) && $globalServer) { |
69 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
70 | - $SI=new SpotterServer(); |
|
69 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
70 | + $SI=new SpotterServer(); |
|
71 | 71 | /* |
72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 73 | $SI = new adsb2aprs(); |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | } else $SI=new SpotterImport($Connection->db); |
77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
78 | 78 | if (isset($globalMarine) && $globalMarine) { |
79 | - $AIS = new AIS(); |
|
80 | - $MI = new MarineImport($Connection->db); |
|
79 | + $AIS = new AIS(); |
|
80 | + $MI = new MarineImport($Connection->db); |
|
81 | 81 | } |
82 | 82 | //$APRS=new APRS($Connection->db); |
83 | 83 | $SBS=new SBS(); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | //$servertz = system('date +%Z'); |
88 | 88 | // signal handler - playing nice with sockets and dump1090 |
89 | 89 | if (function_exists('pcntl_fork')) { |
90 | - pcntl_signal(SIGINT, function() { |
|
91 | - global $sockets; |
|
92 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
93 | - die("Bye!\n"); |
|
94 | - }); |
|
95 | - pcntl_signal_dispatch(); |
|
90 | + pcntl_signal(SIGINT, function() { |
|
91 | + global $sockets; |
|
92 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
93 | + die("Bye!\n"); |
|
94 | + }); |
|
95 | + pcntl_signal_dispatch(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // let's try and connect |
@@ -102,153 +102,153 @@ discard block |
||
102 | 102 | $reset = 0; |
103 | 103 | |
104 | 104 | function connect_all($hosts) { |
105 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
107 | - $reset++; |
|
108 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
109 | - foreach ($hosts as $id => $value) { |
|
105 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
106 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
107 | + $reset++; |
|
108 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
109 | + foreach ($hosts as $id => $value) { |
|
110 | 110 | $host = $value['host']; |
111 | 111 | $globalSources[$id]['last_exec'] = 0; |
112 | 112 | // Here we check type of source(s) |
113 | 113 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
115 | - //$formats[$id] = 'deltadbtxt'; |
|
116 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
117 | - //$last_exec['deltadbtxt'] = 0; |
|
118 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
120 | - //$formats[$id] = 'vatsimtxt'; |
|
121 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
122 | - //$last_exec['vatsimtxt'] = 0; |
|
123 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
125 | - //$formats[$id] = 'aircraftlistjson'; |
|
126 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
127 | - //$last_exec['aircraftlistjson'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/opensky/i',$host)) { |
|
130 | - //$formats[$id] = 'aircraftlistjson'; |
|
131 | - $globalSources[$id]['format'] = 'opensky'; |
|
132 | - //$last_exec['aircraftlistjson'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
135 | - //$formats[$id] = 'radarvirtueljson'; |
|
136 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
137 | - //$last_exec['radarvirtueljson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
139 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
140 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
141 | - exit(0); |
|
142 | - } |
|
143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
144 | - //$formats[$id] = 'planeupdatefaa'; |
|
145 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
146 | - //$last_exec['planeupdatefaa'] = 0; |
|
147 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
148 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
149 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
150 | - exit(0); |
|
151 | - } |
|
152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
153 | - //$formats[$id] = 'phpvmacars'; |
|
154 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
155 | - //$last_exec['phpvmacars'] = 0; |
|
156 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
158 | - //$formats[$id] = 'phpvmacars'; |
|
159 | - $globalSources[$id]['format'] = 'vam'; |
|
160 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
162 | - //$formats[$id] = 'whazzup'; |
|
163 | - $globalSources[$id]['format'] = 'whazzup'; |
|
164 | - //$last_exec['whazzup'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
167 | - //$formats[$id] = 'pirepsjson'; |
|
168 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
169 | - //$last_exec['pirepsjson'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
172 | - //$formats[$id] = 'fr24json'; |
|
173 | - $globalSources[$id]['format'] = 'fr24json'; |
|
174 | - //$last_exec['fr24json'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
176 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
177 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
178 | - exit(0); |
|
179 | - } |
|
180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
181 | - //$formats[$id] = 'fr24json'; |
|
182 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
183 | - //$last_exec['fr24json'] = 0; |
|
184 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
185 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
186 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
187 | - exit(0); |
|
188 | - } |
|
189 | - //} else if (preg_match('/10001/',$host)) { |
|
190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | - //$formats[$id] = 'tsv'; |
|
192 | - $globalSources[$id]['format'] = 'tsv'; |
|
193 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
194 | - } |
|
195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
196 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
198 | - if ($idf !== false) { |
|
199 | - $httpfeeds[$id] = $idf; |
|
200 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
201 | - } |
|
202 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | - $hostport = explode(':',$host); |
|
206 | - if (isset($hostport[1])) { |
|
114 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
115 | + //$formats[$id] = 'deltadbtxt'; |
|
116 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
117 | + //$last_exec['deltadbtxt'] = 0; |
|
118 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
119 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
120 | + //$formats[$id] = 'vatsimtxt'; |
|
121 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
122 | + //$last_exec['vatsimtxt'] = 0; |
|
123 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
124 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
125 | + //$formats[$id] = 'aircraftlistjson'; |
|
126 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
127 | + //$last_exec['aircraftlistjson'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/opensky/i',$host)) { |
|
130 | + //$formats[$id] = 'aircraftlistjson'; |
|
131 | + $globalSources[$id]['format'] = 'opensky'; |
|
132 | + //$last_exec['aircraftlistjson'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
135 | + //$formats[$id] = 'radarvirtueljson'; |
|
136 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
137 | + //$last_exec['radarvirtueljson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
139 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
140 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
141 | + exit(0); |
|
142 | + } |
|
143 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
144 | + //$formats[$id] = 'planeupdatefaa'; |
|
145 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
146 | + //$last_exec['planeupdatefaa'] = 0; |
|
147 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
148 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
149 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
150 | + exit(0); |
|
151 | + } |
|
152 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
153 | + //$formats[$id] = 'phpvmacars'; |
|
154 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
155 | + //$last_exec['phpvmacars'] = 0; |
|
156 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
157 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
158 | + //$formats[$id] = 'phpvmacars'; |
|
159 | + $globalSources[$id]['format'] = 'vam'; |
|
160 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
161 | + } else if (preg_match('/whazzup/i',$host)) { |
|
162 | + //$formats[$id] = 'whazzup'; |
|
163 | + $globalSources[$id]['format'] = 'whazzup'; |
|
164 | + //$last_exec['whazzup'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
167 | + //$formats[$id] = 'pirepsjson'; |
|
168 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
169 | + //$last_exec['pirepsjson'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
172 | + //$formats[$id] = 'fr24json'; |
|
173 | + $globalSources[$id]['format'] = 'fr24json'; |
|
174 | + //$last_exec['fr24json'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
176 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
177 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
178 | + exit(0); |
|
179 | + } |
|
180 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
181 | + //$formats[$id] = 'fr24json'; |
|
182 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
183 | + //$last_exec['fr24json'] = 0; |
|
184 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
185 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
186 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
187 | + exit(0); |
|
188 | + } |
|
189 | + //} else if (preg_match('/10001/',$host)) { |
|
190 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | + //$formats[$id] = 'tsv'; |
|
192 | + $globalSources[$id]['format'] = 'tsv'; |
|
193 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
194 | + } |
|
195 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
196 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
197 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
198 | + if ($idf !== false) { |
|
199 | + $httpfeeds[$id] = $idf; |
|
200 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
201 | + } |
|
202 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
204 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | + $hostport = explode(':',$host); |
|
206 | + if (isset($hostport[1])) { |
|
207 | 207 | $port = $hostport[1]; |
208 | 208 | $hostn = $hostport[0]; |
209 | - } else { |
|
209 | + } else { |
|
210 | 210 | $port = $globalSources[$id]['port']; |
211 | 211 | $hostn = $globalSources[$id]['host']; |
212 | - } |
|
213 | - $Common = new Common(); |
|
214 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
216 | - } else { |
|
217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
218 | - } |
|
219 | - if ($s) { |
|
220 | - $sockets[$id] = $s; |
|
221 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
212 | + } |
|
213 | + $Common = new Common(); |
|
214 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
215 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
216 | + } else { |
|
217 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
218 | + } |
|
219 | + if ($s) { |
|
220 | + $sockets[$id] = $s; |
|
221 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
222 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
223 | 223 | //$formats[$id] = 'aprs'; |
224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
225 | 225 | //$aprs_connect = 0; |
226 | 226 | //$use_aprs = true; |
227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
227 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
229 | - } elseif ($port == '10001') { |
|
230 | - //$formats[$id] = 'tsv'; |
|
231 | - $globalSources[$id]['format'] = 'tsv'; |
|
232 | - } elseif ($port == '30002') { |
|
233 | - //$formats[$id] = 'raw'; |
|
234 | - $globalSources[$id]['format'] = 'raw'; |
|
235 | - } elseif ($port == '5001') { |
|
236 | - //$formats[$id] = 'raw'; |
|
237 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
238 | - } elseif ($port == '30005') { |
|
229 | + } elseif ($port == '10001') { |
|
230 | + //$formats[$id] = 'tsv'; |
|
231 | + $globalSources[$id]['format'] = 'tsv'; |
|
232 | + } elseif ($port == '30002') { |
|
233 | + //$formats[$id] = 'raw'; |
|
234 | + $globalSources[$id]['format'] = 'raw'; |
|
235 | + } elseif ($port == '5001') { |
|
236 | + //$formats[$id] = 'raw'; |
|
237 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
238 | + } elseif ($port == '30005') { |
|
239 | 239 | // Not yet supported |
240 | - //$formats[$id] = 'beast'; |
|
241 | - $globalSources[$id]['format'] = 'beast'; |
|
242 | - //} else $formats[$id] = 'sbs'; |
|
243 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
244 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
240 | + //$formats[$id] = 'beast'; |
|
241 | + $globalSources[$id]['format'] = 'beast'; |
|
242 | + //} else $formats[$id] = 'sbs'; |
|
243 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
244 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
245 | 245 | } |
246 | 246 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
247 | - } else { |
|
247 | + } else { |
|
248 | 248 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
249 | - } |
|
250 | - } |
|
251 | - } |
|
249 | + } |
|
250 | + } |
|
251 | + } |
|
252 | 252 | } |
253 | 253 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
254 | 254 | |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | //connect_all($globalSources); |
272 | 272 | |
273 | 273 | if (isset($globalProxy) && $globalProxy) { |
274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
275 | 275 | } else { |
276 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
276 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | // APRS Configuration |
@@ -282,18 +282,18 @@ discard block |
||
282 | 282 | die; |
283 | 283 | } |
284 | 284 | foreach ($globalSources as $key => $source) { |
285 | - if (!isset($source['format'])) { |
|
286 | - $globalSources[$key]['format'] = 'auto'; |
|
287 | - } |
|
285 | + if (!isset($source['format'])) { |
|
286 | + $globalSources[$key]['format'] = 'auto'; |
|
287 | + } |
|
288 | 288 | } |
289 | 289 | connect_all($globalSources); |
290 | 290 | foreach ($globalSources as $key => $source) { |
291 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
291 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
292 | 292 | $aprs_connect = 0; |
293 | 293 | $use_aprs = true; |
294 | 294 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
295 | 295 | break; |
296 | - } |
|
296 | + } |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | if ($use_aprs) { |
@@ -334,152 +334,152 @@ discard block |
||
334 | 334 | |
335 | 335 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
336 | 336 | while ($i > 0) { |
337 | - if (!$globalDaemon) $i = $endtime-time(); |
|
338 | - // Delete old ATC |
|
339 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
337 | + if (!$globalDaemon) $i = $endtime-time(); |
|
338 | + // Delete old ATC |
|
339 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
340 | 340 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
341 | - $ATC->deleteOldATC(); |
|
342 | - } |
|
341 | + $ATC->deleteOldATC(); |
|
342 | + } |
|
343 | 343 | |
344 | - //if (count($last_exec) > 0) { |
|
345 | - if (count($last_exec) == count($globalSources)) { |
|
344 | + //if (count($last_exec) > 0) { |
|
345 | + if (count($last_exec) == count($globalSources)) { |
|
346 | 346 | $max = $globalMinFetch; |
347 | 347 | foreach ($last_exec as $last) { |
348 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
348 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
349 | 349 | } |
350 | 350 | if ($max != $globalMinFetch) { |
351 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
352 | - sleep($globalMinFetch-$max+2); |
|
351 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
352 | + sleep($globalMinFetch-$max+2); |
|
353 | + } |
|
353 | 354 | } |
354 | - } |
|
355 | 355 | |
356 | 356 | |
357 | - //foreach ($formats as $id => $value) { |
|
358 | - foreach ($globalSources as $id => $value) { |
|
357 | + //foreach ($formats as $id => $value) { |
|
358 | + foreach ($globalSources as $id => $value) { |
|
359 | 359 | date_default_timezone_set('UTC'); |
360 | 360 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
361 | 361 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
362 | - //$buffer = $Common->getData($hosts[$id]); |
|
363 | - $buffer = $Common->getData($value['host']); |
|
364 | - if ($buffer != '') $reset = 0; |
|
365 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
366 | - $buffer = explode('\n',$buffer); |
|
367 | - foreach ($buffer as $line) { |
|
368 | - if ($line != '' && count($line) > 7) { |
|
369 | - $line = explode(',', $line); |
|
370 | - $data = array(); |
|
371 | - $data['hex'] = $line[1]; // hex |
|
372 | - $data['ident'] = $line[2]; // ident |
|
373 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
374 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
375 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
376 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
377 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
378 | - $data['verticalrate'] = ''; // vertical rate |
|
379 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
380 | - $data['emergency'] = ''; // emergency |
|
381 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
382 | - $data['format_source'] = 'deltadbtxt'; |
|
383 | - $data['id_source'] = $id_source; |
|
384 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
385 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
386 | - $SI->add($data); |
|
387 | - unset($data); |
|
388 | - } |
|
389 | - } |
|
390 | - $last_exec[$id]['last'] = time(); |
|
362 | + //$buffer = $Common->getData($hosts[$id]); |
|
363 | + $buffer = $Common->getData($value['host']); |
|
364 | + if ($buffer != '') $reset = 0; |
|
365 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
366 | + $buffer = explode('\n',$buffer); |
|
367 | + foreach ($buffer as $line) { |
|
368 | + if ($line != '' && count($line) > 7) { |
|
369 | + $line = explode(',', $line); |
|
370 | + $data = array(); |
|
371 | + $data['hex'] = $line[1]; // hex |
|
372 | + $data['ident'] = $line[2]; // ident |
|
373 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
374 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
375 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
376 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
377 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
378 | + $data['verticalrate'] = ''; // vertical rate |
|
379 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
380 | + $data['emergency'] = ''; // emergency |
|
381 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
382 | + $data['format_source'] = 'deltadbtxt'; |
|
383 | + $data['id_source'] = $id_source; |
|
384 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
385 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
386 | + $SI->add($data); |
|
387 | + unset($data); |
|
388 | + } |
|
389 | + } |
|
390 | + $last_exec[$id]['last'] = time(); |
|
391 | 391 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
392 | - date_default_timezone_set('CET'); |
|
393 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
394 | - date_default_timezone_set('UTC'); |
|
395 | - if ($buffer != '') $reset = 0; |
|
396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | - $buffer = explode('\n',$buffer); |
|
398 | - foreach ($buffer as $line) { |
|
392 | + date_default_timezone_set('CET'); |
|
393 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
394 | + date_default_timezone_set('UTC'); |
|
395 | + if ($buffer != '') $reset = 0; |
|
396 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | + $buffer = explode('\n',$buffer); |
|
398 | + foreach ($buffer as $line) { |
|
399 | 399 | if ($line != '') { |
400 | - echo "'".$line."'\n"; |
|
401 | - $add = false; |
|
402 | - $ais_data = $AIS->parse_line(trim($line)); |
|
403 | - $data = array(); |
|
404 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
405 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
406 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
407 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
408 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
409 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
410 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
411 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
412 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
413 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
414 | - if (isset($ais_data['timestamp'])) { |
|
400 | + echo "'".$line."'\n"; |
|
401 | + $add = false; |
|
402 | + $ais_data = $AIS->parse_line(trim($line)); |
|
403 | + $data = array(); |
|
404 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
405 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
406 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
407 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
408 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
409 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
410 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
411 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
412 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
413 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
414 | + if (isset($ais_data['timestamp'])) { |
|
415 | 415 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
416 | 416 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
417 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
418 | - $add = true; |
|
417 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
418 | + $add = true; |
|
419 | 419 | } |
420 | - } else { |
|
420 | + } else { |
|
421 | 421 | $data['datetime'] = date('Y-m-d H:i:s'); |
422 | 422 | $add = true; |
423 | - } |
|
424 | - $data['format_source'] = 'aisnmeatxt'; |
|
425 | - $data['id_source'] = $id_source; |
|
426 | - print_r($data); |
|
427 | - echo 'Add...'."\n"; |
|
428 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
429 | - unset($data); |
|
423 | + } |
|
424 | + $data['format_source'] = 'aisnmeatxt'; |
|
425 | + $data['id_source'] = $id_source; |
|
426 | + print_r($data); |
|
427 | + echo 'Add...'."\n"; |
|
428 | + if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
429 | + unset($data); |
|
430 | 430 | } |
431 | - } |
|
432 | - $last_exec[$id]['last'] = time(); |
|
431 | + } |
|
432 | + $last_exec[$id]['last'] = time(); |
|
433 | 433 | } elseif ($value['format'] == 'aisnmeahttp') { |
434 | - $arr = $httpfeeds; |
|
435 | - $w = $e = null; |
|
434 | + $arr = $httpfeeds; |
|
435 | + $w = $e = null; |
|
436 | 436 | |
437 | - if (isset($arr[$id])) { |
|
438 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
439 | - if ($nn > 0) { |
|
437 | + if (isset($arr[$id])) { |
|
438 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
439 | + if ($nn > 0) { |
|
440 | 440 | foreach ($httpfeeds as $feed) { |
441 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
442 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
443 | - $buffer = explode('\n',$buffer); |
|
444 | - foreach ($buffer as $line) { |
|
441 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
442 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
443 | + $buffer = explode('\n',$buffer); |
|
444 | + foreach ($buffer as $line) { |
|
445 | 445 | if ($line != '') { |
446 | - $ais_data = $AIS->parse_line(trim($line)); |
|
447 | - $data = array(); |
|
448 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
449 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
450 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
451 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
452 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
453 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
454 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
455 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
456 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
457 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
458 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
459 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
460 | - if (isset($ais_data['timestamp'])) { |
|
446 | + $ais_data = $AIS->parse_line(trim($line)); |
|
447 | + $data = array(); |
|
448 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
449 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
450 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
451 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
452 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
453 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
454 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
455 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
456 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
457 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
458 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
459 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
460 | + if (isset($ais_data['timestamp'])) { |
|
461 | 461 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
462 | - } else { |
|
462 | + } else { |
|
463 | 463 | $data['datetime'] = date('Y-m-d H:i:s'); |
464 | - } |
|
465 | - $data['format_source'] = 'aisnmeahttp'; |
|
466 | - $data['id_source'] = $id_source; |
|
467 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
468 | - unset($data); |
|
464 | + } |
|
465 | + $data['format_source'] = 'aisnmeahttp'; |
|
466 | + $data['id_source'] = $id_source; |
|
467 | + if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
468 | + unset($data); |
|
469 | 469 | } |
470 | - } |
|
470 | + } |
|
471 | + } |
|
471 | 472 | } |
472 | 473 | } |
473 | - } |
|
474 | 474 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
475 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
476 | - if ($buffer != '') { |
|
475 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
476 | + if ($buffer != '') { |
|
477 | 477 | //echo $buffer; |
478 | 478 | $all_data = json_decode($buffer,true); |
479 | 479 | //print_r($all_data); |
480 | 480 | if (isset($all_data[0]['DATA'])) { |
481 | 481 | foreach ($all_data[0]['DATA'] as $line) { |
482 | - if ($line != '') { |
|
482 | + if ($line != '') { |
|
483 | 483 | $data = array(); |
484 | 484 | $data['ident'] = $line['NAME']; |
485 | 485 | $data['mmsi'] = $line['MMSI']; |
@@ -495,87 +495,87 @@ discard block |
||
495 | 495 | $data['id_source'] = $id_source; |
496 | 496 | $MI->add($data); |
497 | 497 | unset($data); |
498 | - } |
|
498 | + } |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - } |
|
503 | - $last_exec[$id]['last'] = time(); |
|
502 | + } |
|
503 | + $last_exec[$id]['last'] = time(); |
|
504 | 504 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
505 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
506 | - if ($buffer != '') { |
|
505 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
506 | + if ($buffer != '') { |
|
507 | 507 | $all_data = json_decode($buffer,true); |
508 | 508 | if (isset($all_data[0]['mmsi'])) { |
509 | - foreach ($all_data as $line) { |
|
509 | + foreach ($all_data as $line) { |
|
510 | 510 | if ($line != '') { |
511 | - $data = array(); |
|
512 | - $data['ident'] = $line['shipname']; |
|
513 | - $data['callsign'] = $line['callsign']; |
|
514 | - $data['mmsi'] = $line['mmsi']; |
|
515 | - $data['speed'] = $line['sog']; |
|
516 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
517 | - $data['latitude'] = $line['latitude']; |
|
518 | - $data['longitude'] = $line['longitude']; |
|
519 | - $data['type_id'] = $line['shiptype']; |
|
520 | - $data['arrival_code'] = $line['destination']; |
|
521 | - $data['datetime'] = $line['time']; |
|
522 | - $data['format_source'] = 'boatbeaconapp'; |
|
523 | - $data['id_source'] = $id_source; |
|
524 | - $MI->add($data); |
|
525 | - unset($data); |
|
511 | + $data = array(); |
|
512 | + $data['ident'] = $line['shipname']; |
|
513 | + $data['callsign'] = $line['callsign']; |
|
514 | + $data['mmsi'] = $line['mmsi']; |
|
515 | + $data['speed'] = $line['sog']; |
|
516 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
517 | + $data['latitude'] = $line['latitude']; |
|
518 | + $data['longitude'] = $line['longitude']; |
|
519 | + $data['type_id'] = $line['shiptype']; |
|
520 | + $data['arrival_code'] = $line['destination']; |
|
521 | + $data['datetime'] = $line['time']; |
|
522 | + $data['format_source'] = 'boatbeaconapp'; |
|
523 | + $data['id_source'] = $id_source; |
|
524 | + $MI->add($data); |
|
525 | + unset($data); |
|
526 | + } |
|
526 | 527 | } |
527 | - } |
|
528 | 528 | } |
529 | 529 | |
530 | - } |
|
531 | - $last_exec[$id]['last'] = time(); |
|
530 | + } |
|
531 | + $last_exec[$id]['last'] = time(); |
|
532 | 532 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
533 | - echo 'download...'; |
|
534 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
535 | - echo 'done !'."\n"; |
|
536 | - if ($buffer != '') $reset = 0; |
|
537 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
538 | - $buffer = explode('\n',$buffer); |
|
539 | - foreach ($buffer as $line) { |
|
533 | + echo 'download...'; |
|
534 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
535 | + echo 'done !'."\n"; |
|
536 | + if ($buffer != '') $reset = 0; |
|
537 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
538 | + $buffer = explode('\n',$buffer); |
|
539 | + foreach ($buffer as $line) { |
|
540 | 540 | if ($line != '') { |
541 | - $data = array(); |
|
542 | - $data['mmsi'] = (int)substr($line,0,9); |
|
543 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
544 | - //$data['status'] = substr($line,21,2); |
|
545 | - //$data['type'] = substr($line,24,3); |
|
546 | - $data['latitude'] = substr($line,29,9); |
|
547 | - $data['longitude'] = substr($line,41,9); |
|
548 | - $data['speed'] = round(substr($line,51,5)); |
|
549 | - //$data['course'] = substr($line,57,5); |
|
550 | - $data['heading'] = round(substr($line,63,3)); |
|
551 | - //$data['draft'] = substr($line,67,4); |
|
552 | - //$data['length'] = substr($line,72,3); |
|
553 | - //$data['beam'] = substr($line,76,2); |
|
554 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
555 | - //$data['callsign'] = trim(substr($line,100,7); |
|
556 | - //$data['dest'] = substr($line,108,20); |
|
557 | - //$data['etaDate'] = substr($line,129,5); |
|
558 | - //$data['etaTime'] = substr($line,135,5); |
|
559 | - $data['format_source'] = 'shipplotter'; |
|
560 | - $data['id_source'] = $id_source; |
|
561 | - print_r($data); |
|
562 | - echo 'Add...'."\n"; |
|
563 | - $MI->add($data); |
|
564 | - unset($data); |
|
541 | + $data = array(); |
|
542 | + $data['mmsi'] = (int)substr($line,0,9); |
|
543 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
544 | + //$data['status'] = substr($line,21,2); |
|
545 | + //$data['type'] = substr($line,24,3); |
|
546 | + $data['latitude'] = substr($line,29,9); |
|
547 | + $data['longitude'] = substr($line,41,9); |
|
548 | + $data['speed'] = round(substr($line,51,5)); |
|
549 | + //$data['course'] = substr($line,57,5); |
|
550 | + $data['heading'] = round(substr($line,63,3)); |
|
551 | + //$data['draft'] = substr($line,67,4); |
|
552 | + //$data['length'] = substr($line,72,3); |
|
553 | + //$data['beam'] = substr($line,76,2); |
|
554 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
555 | + //$data['callsign'] = trim(substr($line,100,7); |
|
556 | + //$data['dest'] = substr($line,108,20); |
|
557 | + //$data['etaDate'] = substr($line,129,5); |
|
558 | + //$data['etaTime'] = substr($line,135,5); |
|
559 | + $data['format_source'] = 'shipplotter'; |
|
560 | + $data['id_source'] = $id_source; |
|
561 | + print_r($data); |
|
562 | + echo 'Add...'."\n"; |
|
563 | + $MI->add($data); |
|
564 | + unset($data); |
|
565 | 565 | } |
566 | - } |
|
567 | - $last_exec[$id]['last'] = time(); |
|
566 | + } |
|
567 | + $last_exec[$id]['last'] = time(); |
|
568 | 568 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
569 | 569 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
570 | - //$buffer = $Common->getData($hosts[$id]); |
|
571 | - $buffer = $Common->getData($value['host']); |
|
572 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
573 | - $buffer = explode('\n',$buffer); |
|
574 | - $reset = 0; |
|
575 | - foreach ($buffer as $line) { |
|
576 | - if ($line != '') { |
|
577 | - $line = explode(':', $line); |
|
578 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
570 | + //$buffer = $Common->getData($hosts[$id]); |
|
571 | + $buffer = $Common->getData($value['host']); |
|
572 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
573 | + $buffer = explode('\n',$buffer); |
|
574 | + $reset = 0; |
|
575 | + foreach ($buffer as $line) { |
|
576 | + if ($line != '') { |
|
577 | + $line = explode(':', $line); |
|
578 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
579 | 579 | $data = array(); |
580 | 580 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
581 | 581 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -588,36 +588,36 @@ discard block |
||
588 | 588 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
589 | 589 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
590 | 590 | $data['latitude'] = $line[5]; // lat |
591 | - $data['longitude'] = $line[6]; // long |
|
592 | - $data['verticalrate'] = ''; // vertical rate |
|
593 | - $data['squawk'] = ''; // squawk |
|
594 | - $data['emergency'] = ''; // emergency |
|
595 | - $data['waypoints'] = $line[30]; |
|
591 | + $data['longitude'] = $line[6]; // long |
|
592 | + $data['verticalrate'] = ''; // vertical rate |
|
593 | + $data['squawk'] = ''; // squawk |
|
594 | + $data['emergency'] = ''; // emergency |
|
595 | + $data['waypoints'] = $line[30]; |
|
596 | 596 | $data['datetime'] = date('Y-m-d H:i:s'); |
597 | 597 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
598 | 598 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
599 | - $data['departure_airport_icao'] = $line[11]; |
|
600 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
601 | - $data['arrival_airport_icao'] = $line[13]; |
|
599 | + $data['departure_airport_icao'] = $line[11]; |
|
600 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
601 | + $data['arrival_airport_icao'] = $line[13]; |
|
602 | 602 | $data['frequency'] = $line[4]; |
603 | 603 | $data['type'] = $line[18]; |
604 | 604 | $data['range'] = $line[19]; |
605 | 605 | if (isset($line[35])) $data['info'] = $line[35]; |
606 | - $data['id_source'] = $id_source; |
|
607 | - //$data['arrival_airport_time'] = ; |
|
608 | - if ($line[9] != '') { |
|
609 | - $aircraft_data = explode('/',$line[9]); |
|
610 | - if (isset($aircraft_data[1])) { |
|
611 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
612 | - } |
|
613 | - } |
|
614 | - /* |
|
606 | + $data['id_source'] = $id_source; |
|
607 | + //$data['arrival_airport_time'] = ; |
|
608 | + if ($line[9] != '') { |
|
609 | + $aircraft_data = explode('/',$line[9]); |
|
610 | + if (isset($aircraft_data[1])) { |
|
611 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
612 | + } |
|
613 | + } |
|
614 | + /* |
|
615 | 615 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
616 | 616 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
617 | 617 | */ |
618 | - $data['format_source'] = $value['format']; |
|
618 | + $data['format_source'] = $value['format']; |
|
619 | 619 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
620 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
620 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
621 | 621 | elseif ($line[3] == 'ATC') { |
622 | 622 | //print_r($data); |
623 | 623 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -635,247 +635,247 @@ discard block |
||
635 | 635 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
636 | 636 | if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
637 | 637 | } |
638 | - unset($data); |
|
639 | - } |
|
640 | - } |
|
641 | - } |
|
642 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
643 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
644 | - $last_exec[$id]['last'] = time(); |
|
645 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
646 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
647 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
648 | - if ($buffer != '') { |
|
649 | - $all_data = json_decode($buffer,true); |
|
650 | - if (isset($all_data['acList'])) { |
|
638 | + unset($data); |
|
639 | + } |
|
640 | + } |
|
641 | + } |
|
642 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
643 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
644 | + $last_exec[$id]['last'] = time(); |
|
645 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
646 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
647 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
648 | + if ($buffer != '') { |
|
649 | + $all_data = json_decode($buffer,true); |
|
650 | + if (isset($all_data['acList'])) { |
|
651 | 651 | $reset = 0; |
652 | 652 | foreach ($all_data['acList'] as $line) { |
653 | - $data = array(); |
|
654 | - $data['hex'] = $line['Icao']; // hex |
|
655 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
656 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
657 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
658 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
659 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
660 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
661 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
662 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
663 | - $data['emergency'] = ''; // emergency |
|
664 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
665 | - /* |
|
653 | + $data = array(); |
|
654 | + $data['hex'] = $line['Icao']; // hex |
|
655 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
656 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
657 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
658 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
659 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
660 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
661 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
662 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
663 | + $data['emergency'] = ''; // emergency |
|
664 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
665 | + /* |
|
666 | 666 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
667 | 667 | else $data['datetime'] = date('Y-m-d H:i:s'); |
668 | 668 | */ |
669 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
670 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
671 | - $data['format_source'] = 'aircraftlistjson'; |
|
672 | - $data['id_source'] = $id_source; |
|
673 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
674 | - if (isset($data['latitude'])) $SI->add($data); |
|
675 | - unset($data); |
|
669 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
670 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
671 | + $data['format_source'] = 'aircraftlistjson'; |
|
672 | + $data['id_source'] = $id_source; |
|
673 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
674 | + if (isset($data['latitude'])) $SI->add($data); |
|
675 | + unset($data); |
|
676 | 676 | } |
677 | - } elseif (is_array($all_data)) { |
|
677 | + } elseif (is_array($all_data)) { |
|
678 | 678 | $reset = 0; |
679 | 679 | foreach ($all_data as $line) { |
680 | - $data = array(); |
|
681 | - $data['hex'] = $line['hex']; // hex |
|
682 | - $data['ident'] = $line['flight']; // ident |
|
683 | - $data['altitude'] = $line['altitude']; // altitude |
|
684 | - $data['speed'] = $line['speed']; // speed |
|
685 | - $data['heading'] = $line['track']; // heading |
|
686 | - $data['latitude'] = $line['lat']; // lat |
|
687 | - $data['longitude'] = $line['lon']; // long |
|
688 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
689 | - $data['squawk'] = $line['squawk']; // squawk |
|
690 | - $data['emergency'] = ''; // emergency |
|
691 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
692 | - $data['format_source'] = 'aircraftlistjson'; |
|
693 | - $data['id_source'] = $id_source; |
|
694 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
695 | - $SI->add($data); |
|
696 | - unset($data); |
|
680 | + $data = array(); |
|
681 | + $data['hex'] = $line['hex']; // hex |
|
682 | + $data['ident'] = $line['flight']; // ident |
|
683 | + $data['altitude'] = $line['altitude']; // altitude |
|
684 | + $data['speed'] = $line['speed']; // speed |
|
685 | + $data['heading'] = $line['track']; // heading |
|
686 | + $data['latitude'] = $line['lat']; // lat |
|
687 | + $data['longitude'] = $line['lon']; // long |
|
688 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
689 | + $data['squawk'] = $line['squawk']; // squawk |
|
690 | + $data['emergency'] = ''; // emergency |
|
691 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
692 | + $data['format_source'] = 'aircraftlistjson'; |
|
693 | + $data['id_source'] = $id_source; |
|
694 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
695 | + $SI->add($data); |
|
696 | + unset($data); |
|
697 | + } |
|
698 | + } |
|
697 | 699 | } |
698 | - } |
|
699 | - } |
|
700 | - //$last_exec['aircraftlistjson'] = time(); |
|
701 | - $last_exec[$id]['last'] = time(); |
|
702 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
703 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
704 | - $buffer = $Common->getData($value['host']); |
|
705 | - $all_data = json_decode($buffer,true); |
|
706 | - if (isset($all_data['planes'])) { |
|
700 | + //$last_exec['aircraftlistjson'] = time(); |
|
701 | + $last_exec[$id]['last'] = time(); |
|
702 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
703 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
704 | + $buffer = $Common->getData($value['host']); |
|
705 | + $all_data = json_decode($buffer,true); |
|
706 | + if (isset($all_data['planes'])) { |
|
707 | 707 | $reset = 0; |
708 | 708 | foreach ($all_data['planes'] as $key => $line) { |
709 | - $data = array(); |
|
710 | - $data['hex'] = $key; // hex |
|
711 | - $data['ident'] = $line[3]; // ident |
|
712 | - $data['altitude'] = $line[6]; // altitude |
|
713 | - $data['speed'] = $line[8]; // speed |
|
714 | - $data['heading'] = $line[7]; // heading |
|
715 | - $data['latitude'] = $line[4]; // lat |
|
716 | - $data['longitude'] = $line[5]; // long |
|
717 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
718 | - $data['squawk'] = $line[10]; // squawk |
|
719 | - $data['emergency'] = ''; // emergency |
|
720 | - $data['registration'] = $line[2]; |
|
721 | - $data['aircraft_icao'] = $line[0]; |
|
722 | - $deparr = explode('-',$line[1]); |
|
723 | - if (count($deparr) == 2) { |
|
709 | + $data = array(); |
|
710 | + $data['hex'] = $key; // hex |
|
711 | + $data['ident'] = $line[3]; // ident |
|
712 | + $data['altitude'] = $line[6]; // altitude |
|
713 | + $data['speed'] = $line[8]; // speed |
|
714 | + $data['heading'] = $line[7]; // heading |
|
715 | + $data['latitude'] = $line[4]; // lat |
|
716 | + $data['longitude'] = $line[5]; // long |
|
717 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
718 | + $data['squawk'] = $line[10]; // squawk |
|
719 | + $data['emergency'] = ''; // emergency |
|
720 | + $data['registration'] = $line[2]; |
|
721 | + $data['aircraft_icao'] = $line[0]; |
|
722 | + $deparr = explode('-',$line[1]); |
|
723 | + if (count($deparr) == 2) { |
|
724 | 724 | $data['departure_airport_icao'] = $deparr[0]; |
725 | 725 | $data['arrival_airport_icao'] = $deparr[1]; |
726 | - } |
|
727 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
728 | - $data['format_source'] = 'planeupdatefaa'; |
|
729 | - $data['id_source'] = $id_source; |
|
730 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
731 | - $SI->add($data); |
|
732 | - unset($data); |
|
726 | + } |
|
727 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
728 | + $data['format_source'] = 'planeupdatefaa'; |
|
729 | + $data['id_source'] = $id_source; |
|
730 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
731 | + $SI->add($data); |
|
732 | + unset($data); |
|
733 | + } |
|
733 | 734 | } |
734 | - } |
|
735 | - //$last_exec['planeupdatefaa'] = time(); |
|
736 | - $last_exec[$id]['last'] = time(); |
|
737 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
738 | - $buffer = $Common->getData($value['host']); |
|
739 | - $all_data = json_decode($buffer,true); |
|
740 | - if (isset($all_data['states'])) { |
|
735 | + //$last_exec['planeupdatefaa'] = time(); |
|
736 | + $last_exec[$id]['last'] = time(); |
|
737 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
738 | + $buffer = $Common->getData($value['host']); |
|
739 | + $all_data = json_decode($buffer,true); |
|
740 | + if (isset($all_data['states'])) { |
|
741 | 741 | $reset = 0; |
742 | 742 | foreach ($all_data['states'] as $key => $line) { |
743 | - $data = array(); |
|
744 | - $data['hex'] = $line[0]; // hex |
|
745 | - $data['ident'] = trim($line[1]); // ident |
|
746 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
747 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
748 | - $data['heading'] = round($line[10]); // heading |
|
749 | - $data['latitude'] = $line[5]; // lat |
|
750 | - $data['longitude'] = $line[6]; // long |
|
751 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
752 | - //$data['squawk'] = $line[10]; // squawk |
|
753 | - //$data['emergency'] = ''; // emergency |
|
754 | - //$data['registration'] = $line[2]; |
|
755 | - //$data['aircraft_icao'] = $line[0]; |
|
756 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
757 | - $data['format_source'] = 'opensky'; |
|
758 | - $data['id_source'] = $id_source; |
|
759 | - $SI->add($data); |
|
760 | - unset($data); |
|
743 | + $data = array(); |
|
744 | + $data['hex'] = $line[0]; // hex |
|
745 | + $data['ident'] = trim($line[1]); // ident |
|
746 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
747 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
748 | + $data['heading'] = round($line[10]); // heading |
|
749 | + $data['latitude'] = $line[5]; // lat |
|
750 | + $data['longitude'] = $line[6]; // long |
|
751 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
752 | + //$data['squawk'] = $line[10]; // squawk |
|
753 | + //$data['emergency'] = ''; // emergency |
|
754 | + //$data['registration'] = $line[2]; |
|
755 | + //$data['aircraft_icao'] = $line[0]; |
|
756 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
757 | + $data['format_source'] = 'opensky'; |
|
758 | + $data['id_source'] = $id_source; |
|
759 | + $SI->add($data); |
|
760 | + unset($data); |
|
761 | 761 | } |
762 | - } |
|
763 | - //$last_exec['planeupdatefaa'] = time(); |
|
764 | - $last_exec[$id]['last'] = time(); |
|
765 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
766 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
767 | - //$buffer = $Common->getData($hosts[$id]); |
|
768 | - $buffer = $Common->getData($value['host']); |
|
769 | - $all_data = json_decode($buffer,true); |
|
770 | - if (!empty($all_data)) $reset = 0; |
|
771 | - foreach ($all_data as $key => $line) { |
|
762 | + } |
|
763 | + //$last_exec['planeupdatefaa'] = time(); |
|
764 | + $last_exec[$id]['last'] = time(); |
|
765 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
766 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
767 | + //$buffer = $Common->getData($hosts[$id]); |
|
768 | + $buffer = $Common->getData($value['host']); |
|
769 | + $all_data = json_decode($buffer,true); |
|
770 | + if (!empty($all_data)) $reset = 0; |
|
771 | + foreach ($all_data as $key => $line) { |
|
772 | 772 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
773 | - $data = array(); |
|
774 | - $data['hex'] = $line[0]; |
|
775 | - $data['ident'] = $line[16]; //$line[13] |
|
776 | - $data['altitude'] = $line[4]; // altitude |
|
777 | - $data['speed'] = $line[5]; // speed |
|
778 | - $data['heading'] = $line[3]; // heading |
|
779 | - $data['latitude'] = $line[1]; // lat |
|
780 | - $data['longitude'] = $line[2]; // long |
|
781 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
782 | - $data['squawk'] = $line[6]; // squawk |
|
783 | - $data['aircraft_icao'] = $line[8]; |
|
784 | - $data['registration'] = $line[9]; |
|
785 | - $data['departure_airport_iata'] = $line[11]; |
|
786 | - $data['arrival_airport_iata'] = $line[12]; |
|
787 | - $data['emergency'] = ''; // emergency |
|
788 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
789 | - $data['format_source'] = 'fr24json'; |
|
790 | - $data['id_source'] = $id_source; |
|
791 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
792 | - $SI->add($data); |
|
793 | - unset($data); |
|
773 | + $data = array(); |
|
774 | + $data['hex'] = $line[0]; |
|
775 | + $data['ident'] = $line[16]; //$line[13] |
|
776 | + $data['altitude'] = $line[4]; // altitude |
|
777 | + $data['speed'] = $line[5]; // speed |
|
778 | + $data['heading'] = $line[3]; // heading |
|
779 | + $data['latitude'] = $line[1]; // lat |
|
780 | + $data['longitude'] = $line[2]; // long |
|
781 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
782 | + $data['squawk'] = $line[6]; // squawk |
|
783 | + $data['aircraft_icao'] = $line[8]; |
|
784 | + $data['registration'] = $line[9]; |
|
785 | + $data['departure_airport_iata'] = $line[11]; |
|
786 | + $data['arrival_airport_iata'] = $line[12]; |
|
787 | + $data['emergency'] = ''; // emergency |
|
788 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
789 | + $data['format_source'] = 'fr24json'; |
|
790 | + $data['id_source'] = $id_source; |
|
791 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
792 | + $SI->add($data); |
|
793 | + unset($data); |
|
794 | + } |
|
794 | 795 | } |
795 | - } |
|
796 | - //$last_exec['fr24json'] = time(); |
|
797 | - $last_exec[$id]['last'] = time(); |
|
798 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
799 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
800 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
801 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
802 | - //echo $buffer; |
|
803 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
804 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
805 | - $all_data = json_decode($buffer,true); |
|
806 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
796 | + //$last_exec['fr24json'] = time(); |
|
797 | + $last_exec[$id]['last'] = time(); |
|
798 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
799 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
800 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
801 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
802 | + //echo $buffer; |
|
803 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
804 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
805 | + $all_data = json_decode($buffer,true); |
|
806 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
807 | 807 | die(json_last_error_msg()); |
808 | - } |
|
809 | - if (isset($all_data['mrkrs'])) { |
|
808 | + } |
|
809 | + if (isset($all_data['mrkrs'])) { |
|
810 | 810 | $reset = 0; |
811 | 811 | foreach ($all_data['mrkrs'] as $key => $line) { |
812 | - if (isset($line['inf'])) { |
|
812 | + if (isset($line['inf'])) { |
|
813 | 813 | $data = array(); |
814 | 814 | $data['hex'] = $line['inf']['ia']; |
815 | 815 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
816 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
817 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
818 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
819 | - $data['latitude'] = $line['pt'][0]; // lat |
|
820 | - $data['longitude'] = $line['pt'][1]; // long |
|
821 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
822 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
823 | - //$data['aircraft_icao'] = $line[8]; |
|
824 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
816 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
817 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
818 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
819 | + $data['latitude'] = $line['pt'][0]; // lat |
|
820 | + $data['longitude'] = $line['pt'][1]; // long |
|
821 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
822 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
823 | + //$data['aircraft_icao'] = $line[8]; |
|
824 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
825 | 825 | //$data['departure_airport_iata'] = $line[11]; |
826 | 826 | //$data['arrival_airport_iata'] = $line[12]; |
827 | - //$data['emergency'] = ''; // emergency |
|
827 | + //$data['emergency'] = ''; // emergency |
|
828 | 828 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
829 | - $data['format_source'] = 'radarvirtueljson'; |
|
830 | - $data['id_source'] = $id_source; |
|
829 | + $data['format_source'] = 'radarvirtueljson'; |
|
830 | + $data['id_source'] = $id_source; |
|
831 | 831 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
832 | 832 | $SI->add($data); |
833 | 833 | unset($data); |
834 | - } |
|
834 | + } |
|
835 | + } |
|
835 | 836 | } |
836 | - } |
|
837 | - //$last_exec['radarvirtueljson'] = time(); |
|
838 | - $last_exec[$id]['last'] = time(); |
|
839 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
840 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
841 | - //$buffer = $Common->getData($hosts[$id]); |
|
842 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
843 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
837 | + //$last_exec['radarvirtueljson'] = time(); |
|
838 | + $last_exec[$id]['last'] = time(); |
|
839 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
840 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
841 | + //$buffer = $Common->getData($hosts[$id]); |
|
842 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
843 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
844 | 844 | |
845 | - if (isset($all_data['pireps'])) { |
|
845 | + if (isset($all_data['pireps'])) { |
|
846 | 846 | $reset = 0; |
847 | - foreach ($all_data['pireps'] as $line) { |
|
848 | - $data = array(); |
|
849 | - $data['id'] = $line['id']; |
|
850 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
851 | - $data['ident'] = $line['callsign']; // ident |
|
852 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
853 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
854 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
855 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
856 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
857 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
858 | - $data['latitude'] = $line['lat']; // lat |
|
859 | - $data['longitude'] = $line['lon']; // long |
|
860 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
861 | - //$data['squawk'] = $line['squawk']; // squawk |
|
862 | - //$data['emergency'] = ''; // emergency |
|
863 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
864 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
865 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
866 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
867 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
868 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
869 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
870 | - else $data['info'] = ''; |
|
871 | - $data['format_source'] = 'pireps'; |
|
872 | - $data['id_source'] = $id_source; |
|
873 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
874 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
875 | - if ($line['icon'] == 'plane') { |
|
847 | + foreach ($all_data['pireps'] as $line) { |
|
848 | + $data = array(); |
|
849 | + $data['id'] = $line['id']; |
|
850 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
851 | + $data['ident'] = $line['callsign']; // ident |
|
852 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
853 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
854 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
855 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
856 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
857 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
858 | + $data['latitude'] = $line['lat']; // lat |
|
859 | + $data['longitude'] = $line['lon']; // long |
|
860 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
861 | + //$data['squawk'] = $line['squawk']; // squawk |
|
862 | + //$data['emergency'] = ''; // emergency |
|
863 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
864 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
865 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
866 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
867 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
868 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
869 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
870 | + else $data['info'] = ''; |
|
871 | + $data['format_source'] = 'pireps'; |
|
872 | + $data['id_source'] = $id_source; |
|
873 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
874 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
875 | + if ($line['icon'] == 'plane') { |
|
876 | 876 | $SI->add($data); |
877 | - // print_r($data); |
|
878 | - } elseif ($line['icon'] == 'ct') { |
|
877 | + // print_r($data); |
|
878 | + } elseif ($line['icon'] == 'ct') { |
|
879 | 879 | $data['info'] = str_replace('^§','<br />',$data['info']); |
880 | 880 | $data['info'] = str_replace('&sect;','',$data['info']); |
881 | 881 | $typec = substr($data['ident'],-3); |
@@ -890,192 +890,192 @@ discard block |
||
890 | 890 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
891 | 891 | else $data['type'] = 'Observer'; |
892 | 892 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
893 | - } |
|
894 | - unset($data); |
|
893 | + } |
|
894 | + unset($data); |
|
895 | + } |
|
895 | 896 | } |
896 | - } |
|
897 | - //$last_exec['pirepsjson'] = time(); |
|
898 | - $last_exec[$id]['last'] = time(); |
|
899 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
900 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
901 | - //$buffer = $Common->getData($hosts[$id]); |
|
902 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
903 | - $buffer = $Common->getData($value['host']); |
|
904 | - $all_data = json_decode($buffer,true); |
|
905 | - if ($buffer != '' && is_array($all_data)) { |
|
897 | + //$last_exec['pirepsjson'] = time(); |
|
898 | + $last_exec[$id]['last'] = time(); |
|
899 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
900 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
901 | + //$buffer = $Common->getData($hosts[$id]); |
|
902 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
903 | + $buffer = $Common->getData($value['host']); |
|
904 | + $all_data = json_decode($buffer,true); |
|
905 | + if ($buffer != '' && is_array($all_data)) { |
|
906 | 906 | $reset = 0; |
907 | 907 | foreach ($all_data as $line) { |
908 | - $data = array(); |
|
909 | - //$data['id'] = $line['id']; // id not usable |
|
910 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
911 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
912 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
913 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
914 | - $data['ident'] = $line['flightnum']; // ident |
|
915 | - $data['altitude'] = $line['alt']; // altitude |
|
916 | - $data['speed'] = $line['gs']; // speed |
|
917 | - $data['heading'] = $line['heading']; // heading |
|
918 | - $data['latitude'] = $line['lat']; // lat |
|
919 | - $data['longitude'] = $line['lng']; // long |
|
920 | - $data['verticalrate'] = ''; // verticale rate |
|
921 | - $data['squawk'] = ''; // squawk |
|
922 | - $data['emergency'] = ''; // emergency |
|
923 | - //$data['datetime'] = $line['lastupdate']; |
|
924 | - $data['last_update'] = $line['lastupdate']; |
|
925 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
926 | - $data['departure_airport_icao'] = $line['depicao']; |
|
927 | - $data['departure_airport_time'] = $line['deptime']; |
|
928 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
929 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
930 | - $data['registration'] = $line['aircraft']; |
|
931 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
932 | - if (isset($line['aircraftname'])) { |
|
908 | + $data = array(); |
|
909 | + //$data['id'] = $line['id']; // id not usable |
|
910 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
911 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
912 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
913 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
914 | + $data['ident'] = $line['flightnum']; // ident |
|
915 | + $data['altitude'] = $line['alt']; // altitude |
|
916 | + $data['speed'] = $line['gs']; // speed |
|
917 | + $data['heading'] = $line['heading']; // heading |
|
918 | + $data['latitude'] = $line['lat']; // lat |
|
919 | + $data['longitude'] = $line['lng']; // long |
|
920 | + $data['verticalrate'] = ''; // verticale rate |
|
921 | + $data['squawk'] = ''; // squawk |
|
922 | + $data['emergency'] = ''; // emergency |
|
923 | + //$data['datetime'] = $line['lastupdate']; |
|
924 | + $data['last_update'] = $line['lastupdate']; |
|
925 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
926 | + $data['departure_airport_icao'] = $line['depicao']; |
|
927 | + $data['departure_airport_time'] = $line['deptime']; |
|
928 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
929 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
930 | + $data['registration'] = $line['aircraft']; |
|
931 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
932 | + if (isset($line['aircraftname'])) { |
|
933 | 933 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
934 | 934 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
935 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
936 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
937 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
938 | - else { |
|
939 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
940 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
941 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
942 | - } |
|
943 | - } |
|
944 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
945 | - $data['id_source'] = $id_source; |
|
946 | - $data['format_source'] = 'phpvmacars'; |
|
947 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
948 | - $SI->add($data); |
|
949 | - unset($data); |
|
935 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
936 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
937 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
938 | + else { |
|
939 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
940 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
941 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
942 | + } |
|
943 | + } |
|
944 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
945 | + $data['id_source'] = $id_source; |
|
946 | + $data['format_source'] = 'phpvmacars'; |
|
947 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
948 | + $SI->add($data); |
|
949 | + unset($data); |
|
950 | 950 | } |
951 | 951 | if ($globalDebug) echo 'No more data...'."\n"; |
952 | 952 | unset($buffer); |
953 | 953 | unset($all_data); |
954 | - } |
|
955 | - //$last_exec['phpvmacars'] = time(); |
|
956 | - $last_exec[$id]['last'] = time(); |
|
957 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
958 | - //$buffer = $Common->getData($hosts[$id]); |
|
959 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
960 | - $buffer = $Common->getData($value['host']); |
|
961 | - $all_data = json_decode($buffer,true); |
|
962 | - if ($buffer != '' && is_array($all_data)) { |
|
954 | + } |
|
955 | + //$last_exec['phpvmacars'] = time(); |
|
956 | + $last_exec[$id]['last'] = time(); |
|
957 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
958 | + //$buffer = $Common->getData($hosts[$id]); |
|
959 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
960 | + $buffer = $Common->getData($value['host']); |
|
961 | + $all_data = json_decode($buffer,true); |
|
962 | + if ($buffer != '' && is_array($all_data)) { |
|
963 | 963 | $reset = 0; |
964 | 964 | foreach ($all_data as $line) { |
965 | - $data = array(); |
|
966 | - //$data['id'] = $line['id']; // id not usable |
|
967 | - $data['id'] = trim($line['flight_id']); |
|
968 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
969 | - $data['pilot_name'] = $line['pilot_name']; |
|
970 | - $data['pilot_id'] = $line['pilot_id']; |
|
971 | - $data['ident'] = trim($line['callsign']); // ident |
|
972 | - $data['altitude'] = $line['altitude']; // altitude |
|
973 | - $data['speed'] = $line['gs']; // speed |
|
974 | - $data['heading'] = $line['heading']; // heading |
|
975 | - $data['latitude'] = $line['latitude']; // lat |
|
976 | - $data['longitude'] = $line['longitude']; // long |
|
977 | - $data['verticalrate'] = ''; // verticale rate |
|
978 | - $data['squawk'] = ''; // squawk |
|
979 | - $data['emergency'] = ''; // emergency |
|
980 | - //$data['datetime'] = $line['lastupdate']; |
|
981 | - $data['last_update'] = $line['last_update']; |
|
982 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
983 | - $data['departure_airport_icao'] = $line['departure']; |
|
984 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
985 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
986 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
987 | - //$data['registration'] = $line['aircraft']; |
|
988 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
989 | - $data['aircraft_icao'] = $line['plane_type']; |
|
990 | - $data['id_source'] = $id_source; |
|
991 | - $data['format_source'] = 'vam'; |
|
992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
993 | - $SI->add($data); |
|
994 | - unset($data); |
|
965 | + $data = array(); |
|
966 | + //$data['id'] = $line['id']; // id not usable |
|
967 | + $data['id'] = trim($line['flight_id']); |
|
968 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
969 | + $data['pilot_name'] = $line['pilot_name']; |
|
970 | + $data['pilot_id'] = $line['pilot_id']; |
|
971 | + $data['ident'] = trim($line['callsign']); // ident |
|
972 | + $data['altitude'] = $line['altitude']; // altitude |
|
973 | + $data['speed'] = $line['gs']; // speed |
|
974 | + $data['heading'] = $line['heading']; // heading |
|
975 | + $data['latitude'] = $line['latitude']; // lat |
|
976 | + $data['longitude'] = $line['longitude']; // long |
|
977 | + $data['verticalrate'] = ''; // verticale rate |
|
978 | + $data['squawk'] = ''; // squawk |
|
979 | + $data['emergency'] = ''; // emergency |
|
980 | + //$data['datetime'] = $line['lastupdate']; |
|
981 | + $data['last_update'] = $line['last_update']; |
|
982 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
983 | + $data['departure_airport_icao'] = $line['departure']; |
|
984 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
985 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
986 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
987 | + //$data['registration'] = $line['aircraft']; |
|
988 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
989 | + $data['aircraft_icao'] = $line['plane_type']; |
|
990 | + $data['id_source'] = $id_source; |
|
991 | + $data['format_source'] = 'vam'; |
|
992 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
993 | + $SI->add($data); |
|
994 | + unset($data); |
|
995 | 995 | } |
996 | 996 | if ($globalDebug) echo 'No more data...'."\n"; |
997 | 997 | unset($buffer); |
998 | 998 | unset($all_data); |
999 | - } |
|
1000 | - //$last_exec['phpvmacars'] = time(); |
|
1001 | - $last_exec[$id]['last'] = time(); |
|
999 | + } |
|
1000 | + //$last_exec['phpvmacars'] = time(); |
|
1001 | + $last_exec[$id]['last'] = time(); |
|
1002 | 1002 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1003 | 1003 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1004 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1005 | - //$last_exec[$id]['last'] = time(); |
|
1004 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1005 | + //$last_exec[$id]['last'] = time(); |
|
1006 | 1006 | |
1007 | - //$read = array( $sockets[$id] ); |
|
1008 | - $read = $sockets; |
|
1009 | - $write = NULL; |
|
1010 | - $e = NULL; |
|
1011 | - $n = socket_select($read, $write, $e, $timeout); |
|
1012 | - if ($e != NULL) var_dump($e); |
|
1013 | - if ($n > 0) { |
|
1007 | + //$read = array( $sockets[$id] ); |
|
1008 | + $read = $sockets; |
|
1009 | + $write = NULL; |
|
1010 | + $e = NULL; |
|
1011 | + $n = socket_select($read, $write, $e, $timeout); |
|
1012 | + if ($e != NULL) var_dump($e); |
|
1013 | + if ($n > 0) { |
|
1014 | 1014 | $reset = 0; |
1015 | 1015 | foreach ($read as $nb => $r) { |
1016 | - //$value = $formats[$nb]; |
|
1017 | - $format = $globalSources[$nb]['format']; |
|
1018 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1016 | + //$value = $formats[$nb]; |
|
1017 | + $format = $globalSources[$nb]['format']; |
|
1018 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1019 | 1019 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1020 | - } elseif ($format == 'vrstcp') { |
|
1020 | + } elseif ($format == 'vrstcp') { |
|
1021 | 1021 | $buffer = @socket_read($r, 6000); |
1022 | - } else { |
|
1022 | + } else { |
|
1023 | 1023 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1024 | - } |
|
1025 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1026 | - //echo $buffer."\n"; |
|
1027 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1028 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1029 | - $error = false; |
|
1030 | - //$SI::del(); |
|
1031 | - if ($format == 'vrstcp') { |
|
1024 | + } |
|
1025 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1026 | + //echo $buffer."\n"; |
|
1027 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1028 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1029 | + $error = false; |
|
1030 | + //$SI::del(); |
|
1031 | + if ($format == 'vrstcp') { |
|
1032 | 1032 | $buffer = explode('},{',$buffer); |
1033 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1034 | - // SBS format is CSV format |
|
1035 | - if ($buffer !== FALSE && $buffer != '') { |
|
1033 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1034 | + // SBS format is CSV format |
|
1035 | + if ($buffer !== FALSE && $buffer != '') { |
|
1036 | 1036 | $tt[$format] = 0; |
1037 | 1037 | if ($format == 'acarssbs3') { |
1038 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1039 | - $ACARS->add(trim($buffer)); |
|
1040 | - $ACARS->deleteLiveAcarsData(); |
|
1038 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1039 | + $ACARS->add(trim($buffer)); |
|
1040 | + $ACARS->deleteLiveAcarsData(); |
|
1041 | 1041 | } elseif ($format == 'raw') { |
1042 | - // AVR format |
|
1043 | - $data = $SBS->parse($buffer); |
|
1044 | - if (is_array($data)) { |
|
1042 | + // AVR format |
|
1043 | + $data = $SBS->parse($buffer); |
|
1044 | + if (is_array($data)) { |
|
1045 | 1045 | $data['datetime'] = date('Y-m-d H:i:s'); |
1046 | 1046 | $data['format_source'] = 'raw'; |
1047 | 1047 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1048 | 1048 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1049 | 1049 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1050 | - } |
|
1050 | + } |
|
1051 | 1051 | } elseif ($format == 'ais') { |
1052 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1053 | - $data = array(); |
|
1054 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1055 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1056 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1057 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1058 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1059 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1060 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1061 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1062 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1063 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1064 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1065 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1052 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1053 | + $data = array(); |
|
1054 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1055 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1056 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1057 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1058 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1059 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1060 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1061 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1062 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1063 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1064 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1065 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1066 | 1066 | |
1067 | - if (isset($ais_data['timestamp'])) { |
|
1067 | + if (isset($ais_data['timestamp'])) { |
|
1068 | 1068 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1069 | - } else { |
|
1069 | + } else { |
|
1070 | 1070 | $data['datetime'] = date('Y-m-d H:i:s'); |
1071 | - } |
|
1072 | - $data['format_source'] = 'aisnmea'; |
|
1073 | - $data['id_source'] = $id_source; |
|
1074 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1075 | - unset($data); |
|
1076 | - } elseif ($format == 'flightgearsp') { |
|
1077 | - //echo $buffer."\n"; |
|
1078 | - if (strlen($buffer) > 5) { |
|
1071 | + } |
|
1072 | + $data['format_source'] = 'aisnmea'; |
|
1073 | + $data['id_source'] = $id_source; |
|
1074 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1075 | + unset($data); |
|
1076 | + } elseif ($format == 'flightgearsp') { |
|
1077 | + //echo $buffer."\n"; |
|
1078 | + if (strlen($buffer) > 5) { |
|
1079 | 1079 | $line = explode(',',$buffer); |
1080 | 1080 | $data = array(); |
1081 | 1081 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1091,37 +1091,37 @@ discard block |
||
1091 | 1091 | $data['format_source'] = 'flightgearsp'; |
1092 | 1092 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1093 | 1093 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1094 | - } |
|
1095 | - } elseif ($format == 'acars') { |
|
1096 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1097 | - $ACARS->add(trim($buffer)); |
|
1098 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1099 | - $ACARS->deleteLiveAcarsData(); |
|
1094 | + } |
|
1095 | + } elseif ($format == 'acars') { |
|
1096 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1097 | + $ACARS->add(trim($buffer)); |
|
1098 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1099 | + $ACARS->deleteLiveAcarsData(); |
|
1100 | 1100 | } elseif ($format == 'flightgearmp') { |
1101 | - if (substr($buffer,0,1) != '#') { |
|
1101 | + if (substr($buffer,0,1) != '#') { |
|
1102 | 1102 | $data = array(); |
1103 | 1103 | //echo $buffer."\n"; |
1104 | 1104 | $line = explode(' ',$buffer); |
1105 | 1105 | if (count($line) == 11) { |
1106 | - $userserver = explode('@',$line[0]); |
|
1107 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1108 | - $data['ident'] = $userserver[0]; |
|
1109 | - $data['registration'] = $userserver[0]; |
|
1110 | - $data['latitude'] = $line[4]; |
|
1111 | - $data['longitude'] = $line[5]; |
|
1112 | - $data['altitude'] = $line[6]; |
|
1113 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1114 | - $aircraft_type = $line[10]; |
|
1115 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1116 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1117 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1106 | + $userserver = explode('@',$line[0]); |
|
1107 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1108 | + $data['ident'] = $userserver[0]; |
|
1109 | + $data['registration'] = $userserver[0]; |
|
1110 | + $data['latitude'] = $line[4]; |
|
1111 | + $data['longitude'] = $line[5]; |
|
1112 | + $data['altitude'] = $line[6]; |
|
1113 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1114 | + $aircraft_type = $line[10]; |
|
1115 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1116 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1117 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1118 | + } |
|
1118 | 1119 | } |
1119 | - } |
|
1120 | 1120 | } elseif ($format == 'beast') { |
1121 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1122 | - die; |
|
1121 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1122 | + die; |
|
1123 | 1123 | } elseif ($format == 'vrstcp') { |
1124 | - foreach($buffer as $all_data) { |
|
1124 | + foreach($buffer as $all_data) { |
|
1125 | 1125 | $line = json_decode('{'.$all_data.'}',true); |
1126 | 1126 | $data = array(); |
1127 | 1127 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1141,100 +1141,100 @@ discard block |
||
1141 | 1141 | */ |
1142 | 1142 | $data['datetime'] = date('Y-m-d H:i:s'); |
1143 | 1143 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1144 | - $data['format_source'] = 'vrstcp'; |
|
1144 | + $data['format_source'] = 'vrstcp'; |
|
1145 | 1145 | $data['id_source'] = $id_source; |
1146 | 1146 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1147 | 1147 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1148 | 1148 | unset($data); |
1149 | - } |
|
1149 | + } |
|
1150 | 1150 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1151 | - $line = explode("\t", $buffer); |
|
1152 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1151 | + $line = explode("\t", $buffer); |
|
1152 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1153 | 1153 | $key = $line[$k]; |
1154 | - $lined[$key] = $line[$k+1]; |
|
1155 | - } |
|
1156 | - if (count($lined) > 3) { |
|
1157 | - $data['hex'] = $lined['hexid']; |
|
1158 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1159 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1160 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1161 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1162 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1163 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1164 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1165 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1166 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1167 | - $data['id_source'] = $id_source; |
|
1168 | - $data['format_source'] = 'tsv'; |
|
1169 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1170 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1171 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1172 | - unset($lined); |
|
1173 | - unset($data); |
|
1174 | - } else $error = true; |
|
1154 | + $lined[$key] = $line[$k+1]; |
|
1155 | + } |
|
1156 | + if (count($lined) > 3) { |
|
1157 | + $data['hex'] = $lined['hexid']; |
|
1158 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1159 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1160 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1161 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1162 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1163 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1164 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1165 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1166 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1167 | + $data['id_source'] = $id_source; |
|
1168 | + $data['format_source'] = 'tsv'; |
|
1169 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1170 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1171 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1172 | + unset($lined); |
|
1173 | + unset($data); |
|
1174 | + } else $error = true; |
|
1175 | 1175 | } elseif ($format == 'aprs' && $use_aprs) { |
1176 | - if ($aprs_connect == 0) { |
|
1176 | + if ($aprs_connect == 0) { |
|
1177 | 1177 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1178 | 1178 | $aprs_connect = 1; |
1179 | - } |
|
1179 | + } |
|
1180 | 1180 | |
1181 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1181 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1182 | 1182 | $aprs_last_tx = time(); |
1183 | 1183 | $data_aprs = "# Keep alive"; |
1184 | 1184 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1185 | - } |
|
1185 | + } |
|
1186 | 1186 | |
1187 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1188 | - //echo 'APRS data : '.$buffer."\n"; |
|
1189 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1190 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1191 | - //echo $buffer."\n"; |
|
1192 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1187 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1188 | + //echo 'APRS data : '.$buffer."\n"; |
|
1189 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1190 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1191 | + //echo $buffer."\n"; |
|
1192 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1193 | 1193 | $line = $APRS->parse($buffer); |
1194 | 1194 | //print_r($line); |
1195 | 1195 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1196 | 1196 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']))) { |
1197 | - $aprs_last_tx = time(); |
|
1198 | - $data = array(); |
|
1199 | - //print_r($line); |
|
1200 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1201 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1202 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1203 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1204 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1205 | - $data['latitude'] = $line['latitude']; |
|
1206 | - $data['longitude'] = $line['longitude']; |
|
1207 | - //$data['verticalrate'] = $line[16]; |
|
1208 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1209 | - else $data['speed'] = 0; |
|
1210 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1211 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1212 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1213 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1214 | - //else $data['heading'] = 0; |
|
1215 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1216 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1217 | - $data['id_source'] = $id_source; |
|
1218 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1219 | - else $data['format_source'] = 'aprs'; |
|
1220 | - $data['source_name'] = $line['source']; |
|
1221 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1222 | - else $data['source_type'] = 'flarm'; |
|
1223 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1224 | - $currentdate = date('Y-m-d H:i:s'); |
|
1225 | - $aprsdate = strtotime($data['datetime']); |
|
1226 | - // Accept data if time <= system time + 20s |
|
1227 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1197 | + $aprs_last_tx = time(); |
|
1198 | + $data = array(); |
|
1199 | + //print_r($line); |
|
1200 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1201 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1202 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1203 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1204 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1205 | + $data['latitude'] = $line['latitude']; |
|
1206 | + $data['longitude'] = $line['longitude']; |
|
1207 | + //$data['verticalrate'] = $line[16]; |
|
1208 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1209 | + else $data['speed'] = 0; |
|
1210 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1211 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1212 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1213 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1214 | + //else $data['heading'] = 0; |
|
1215 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1216 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1217 | + $data['id_source'] = $id_source; |
|
1218 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1219 | + else $data['format_source'] = 'aprs'; |
|
1220 | + $data['source_name'] = $line['source']; |
|
1221 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1222 | + else $data['source_type'] = 'flarm'; |
|
1223 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1224 | + $currentdate = date('Y-m-d H:i:s'); |
|
1225 | + $aprsdate = strtotime($data['datetime']); |
|
1226 | + // Accept data if time <= system time + 20s |
|
1227 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1228 | 1228 | $send = $SI->add($data); |
1229 | - } elseif (isset($line['stealth'])) { |
|
1229 | + } elseif (isset($line['stealth'])) { |
|
1230 | 1230 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1231 | 1231 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1232 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1233 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1232 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1233 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1234 | 1234 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1235 | 1235 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1236 | - } |
|
1237 | - unset($data); |
|
1236 | + } |
|
1237 | + unset($data); |
|
1238 | 1238 | } |
1239 | 1239 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1240 | 1240 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1244,12 +1244,12 @@ discard block |
||
1244 | 1244 | } |
1245 | 1245 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1246 | 1246 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1247 | - } |
|
1247 | + } |
|
1248 | 1248 | } else { |
1249 | - $line = explode(',', $buffer); |
|
1250 | - if (count($line) > 20) { |
|
1251 | - $data['hex'] = $line[4]; |
|
1252 | - /* |
|
1249 | + $line = explode(',', $buffer); |
|
1250 | + if (count($line) > 20) { |
|
1251 | + $data['hex'] = $line[4]; |
|
1252 | + /* |
|
1253 | 1253 | $data['datetime'] = $line[6].' '.$line[7]; |
1254 | 1254 | date_default_timezone_set($globalTimezone); |
1255 | 1255 | $datetime = new DateTime($data['datetime']); |
@@ -1257,29 +1257,29 @@ discard block |
||
1257 | 1257 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1258 | 1258 | date_default_timezone_set('UTC'); |
1259 | 1259 | */ |
1260 | - // Force datetime to current UTC datetime |
|
1261 | - date_default_timezone_set('UTC'); |
|
1262 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1263 | - $data['ident'] = trim($line[10]); |
|
1264 | - $data['latitude'] = $line[14]; |
|
1265 | - $data['longitude'] = $line[15]; |
|
1266 | - $data['verticalrate'] = $line[16]; |
|
1267 | - $data['emergency'] = $line[20]; |
|
1268 | - $data['speed'] = $line[12]; |
|
1269 | - $data['squawk'] = $line[17]; |
|
1270 | - $data['altitude'] = $line[11]; |
|
1271 | - $data['heading'] = $line[13]; |
|
1272 | - $data['ground'] = $line[21]; |
|
1273 | - $data['emergency'] = $line[19]; |
|
1274 | - $data['format_source'] = 'sbs'; |
|
1260 | + // Force datetime to current UTC datetime |
|
1261 | + date_default_timezone_set('UTC'); |
|
1262 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1263 | + $data['ident'] = trim($line[10]); |
|
1264 | + $data['latitude'] = $line[14]; |
|
1265 | + $data['longitude'] = $line[15]; |
|
1266 | + $data['verticalrate'] = $line[16]; |
|
1267 | + $data['emergency'] = $line[20]; |
|
1268 | + $data['speed'] = $line[12]; |
|
1269 | + $data['squawk'] = $line[17]; |
|
1270 | + $data['altitude'] = $line[11]; |
|
1271 | + $data['heading'] = $line[13]; |
|
1272 | + $data['ground'] = $line[21]; |
|
1273 | + $data['emergency'] = $line[19]; |
|
1274 | + $data['format_source'] = 'sbs'; |
|
1275 | 1275 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1276 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1277 | - $data['id_source'] = $id_source; |
|
1278 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1279 | - else $error = true; |
|
1280 | - unset($data); |
|
1281 | - } else $error = true; |
|
1282 | - if ($error) { |
|
1276 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1277 | + $data['id_source'] = $id_source; |
|
1278 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1279 | + else $error = true; |
|
1280 | + unset($data); |
|
1281 | + } else $error = true; |
|
1282 | + if ($error) { |
|
1283 | 1283 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1284 | 1284 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1285 | 1285 | } else { |
@@ -1295,13 +1295,13 @@ discard block |
||
1295 | 1295 | connect_all($sourceer); |
1296 | 1296 | $sourceer = array(); |
1297 | 1297 | } |
1298 | - } |
|
1298 | + } |
|
1299 | 1299 | } |
1300 | 1300 | // Sleep for xxx microseconds |
1301 | 1301 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1302 | - } else { |
|
1302 | + } else { |
|
1303 | 1303 | if ($format == 'flightgearmp') { |
1304 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1304 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1305 | 1305 | //@socket_close($r); |
1306 | 1306 | sleep($globalMinFetch); |
1307 | 1307 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1310,9 +1310,9 @@ discard block |
||
1310 | 1310 | break; |
1311 | 1311 | |
1312 | 1312 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1313 | - if (isset($tt[$format])) $tt[$format]++; |
|
1314 | - else $tt[$format] = 0; |
|
1315 | - if ($tt[$format] > 30) { |
|
1313 | + if (isset($tt[$format])) $tt[$format]++; |
|
1314 | + else $tt[$format] = 0; |
|
1315 | + if ($tt[$format] > 30) { |
|
1316 | 1316 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1317 | 1317 | //@socket_close($r); |
1318 | 1318 | sleep(2); |
@@ -1323,23 +1323,23 @@ discard block |
||
1323 | 1323 | //connect_all($globalSources); |
1324 | 1324 | $tt[$format]=0; |
1325 | 1325 | break; |
1326 | - } |
|
1326 | + } |
|
1327 | + } |
|
1327 | 1328 | } |
1328 | - } |
|
1329 | 1329 | } |
1330 | - } else { |
|
1330 | + } else { |
|
1331 | 1331 | $error = socket_strerror(socket_last_error()); |
1332 | 1332 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1333 | 1333 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1334 | 1334 | if (isset($globalDebug)) echo "Restarting...\n"; |
1335 | 1335 | // Restart the script if possible |
1336 | 1336 | if (is_array($sockets)) { |
1337 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1337 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1338 | 1338 | |
1339 | - foreach ($sockets as $sock) { |
|
1339 | + foreach ($sockets as $sock) { |
|
1340 | 1340 | @socket_shutdown($sock,2); |
1341 | 1341 | @socket_close($sock); |
1342 | - } |
|
1342 | + } |
|
1343 | 1343 | |
1344 | 1344 | } |
1345 | 1345 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1350,13 +1350,13 @@ discard block |
||
1350 | 1350 | if ($reset > 40) exit('Too many attempts...'); |
1351 | 1351 | connect_all($globalSources); |
1352 | 1352 | } |
1353 | - } |
|
1353 | + } |
|
1354 | 1354 | } |
1355 | 1355 | if ($globalDaemon === false) { |
1356 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1357 | - $SI->checkAll(); |
|
1356 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1357 | + $SI->checkAll(); |
|
1358 | + } |
|
1358 | 1359 | } |
1359 | - } |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | ?> |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | die; |
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
48 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
|
52 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::')); |
|
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
@@ -67,27 +67,27 @@ discard block |
||
67 | 67 | else $id_source = 1; |
68 | 68 | if (isset($globalServer) && $globalServer) { |
69 | 69 | if ($globalDebug) echo "Using Server Mode\n"; |
70 | - $SI=new SpotterServer(); |
|
70 | + $SI = new SpotterServer(); |
|
71 | 71 | /* |
72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 73 | $SI = new adsb2aprs(); |
74 | 74 | $SI->connect(); |
75 | 75 | */ |
76 | -} else $SI=new SpotterImport($Connection->db); |
|
76 | +} else $SI = new SpotterImport($Connection->db); |
|
77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
78 | 78 | if (isset($globalMarine) && $globalMarine) { |
79 | 79 | $AIS = new AIS(); |
80 | 80 | $MI = new MarineImport($Connection->db); |
81 | 81 | } |
82 | 82 | //$APRS=new APRS($Connection->db); |
83 | -$SBS=new SBS(); |
|
84 | -$ACARS=new ACARS($Connection->db); |
|
85 | -$Common=new Common(); |
|
83 | +$SBS = new SBS(); |
|
84 | +$ACARS = new ACARS($Connection->db); |
|
85 | +$Common = new Common(); |
|
86 | 86 | date_default_timezone_set('UTC'); |
87 | 87 | //$servertz = system('date +%Z'); |
88 | 88 | // signal handler - playing nice with sockets and dump1090 |
89 | 89 | if (function_exists('pcntl_fork')) { |
90 | - pcntl_signal(SIGINT, function() { |
|
90 | + pcntl_signal(SIGINT, function() { |
|
91 | 91 | global $sockets; |
92 | 92 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
93 | 93 | die("Bye!\n"); |
@@ -103,35 +103,35 @@ discard block |
||
103 | 103 | |
104 | 104 | function connect_all($hosts) { |
105 | 105 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
106 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
107 | 107 | $reset++; |
108 | 108 | if ($globalDebug) echo 'Connect to all...'."\n"; |
109 | 109 | foreach ($hosts as $id => $value) { |
110 | 110 | $host = $value['host']; |
111 | 111 | $globalSources[$id]['last_exec'] = 0; |
112 | 112 | // Here we check type of source(s) |
113 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
113 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
114 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
115 | 115 | //$formats[$id] = 'deltadbtxt'; |
116 | 116 | $globalSources[$id]['format'] = 'deltadbtxt'; |
117 | 117 | //$last_exec['deltadbtxt'] = 0; |
118 | 118 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
119 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
120 | 120 | //$formats[$id] = 'vatsimtxt'; |
121 | 121 | $globalSources[$id]['format'] = 'vatsimtxt'; |
122 | 122 | //$last_exec['vatsimtxt'] = 0; |
123 | 123 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
124 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'aircraftlistjson'; |
126 | 126 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
127 | 127 | //$last_exec['aircraftlistjson'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
129 | - } else if (preg_match('/opensky/i',$host)) { |
|
129 | + } else if (preg_match('/opensky/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'aircraftlistjson'; |
131 | 131 | $globalSources[$id]['format'] = 'opensky'; |
132 | 132 | //$last_exec['aircraftlistjson'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'radarvirtueljson'; |
136 | 136 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
137 | 137 | //$last_exec['radarvirtueljson'] = 0; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
141 | 141 | exit(0); |
142 | 142 | } |
143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
143 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
144 | 144 | //$formats[$id] = 'planeupdatefaa'; |
145 | 145 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
146 | 146 | //$last_exec['planeupdatefaa'] = 0; |
@@ -149,26 +149,26 @@ discard block |
||
149 | 149 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
150 | 150 | exit(0); |
151 | 151 | } |
152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
152 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
153 | 153 | //$formats[$id] = 'phpvmacars'; |
154 | 154 | $globalSources[$id]['format'] = 'phpvmacars'; |
155 | 155 | //$last_exec['phpvmacars'] = 0; |
156 | 156 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
157 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
158 | 158 | //$formats[$id] = 'phpvmacars'; |
159 | 159 | $globalSources[$id]['format'] = 'vam'; |
160 | 160 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
161 | + } else if (preg_match('/whazzup/i', $host)) { |
|
162 | 162 | //$formats[$id] = 'whazzup'; |
163 | 163 | $globalSources[$id]['format'] = 'whazzup'; |
164 | 164 | //$last_exec['whazzup'] = 0; |
165 | 165 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
166 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
167 | 167 | //$formats[$id] = 'pirepsjson'; |
168 | 168 | $globalSources[$id]['format'] = 'pirepsjson'; |
169 | 169 | //$last_exec['pirepsjson'] = 0; |
170 | 170 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
172 | 172 | //$formats[$id] = 'fr24json'; |
173 | 173 | $globalSources[$id]['format'] = 'fr24json'; |
174 | 174 | //$last_exec['fr24json'] = 0; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
178 | 178 | exit(0); |
179 | 179 | } |
180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
180 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
181 | 181 | //$formats[$id] = 'fr24json'; |
182 | 182 | $globalSources[$id]['format'] = 'myshiptracking'; |
183 | 183 | //$last_exec['fr24json'] = 0; |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | exit(0); |
188 | 188 | } |
189 | 189 | //} else if (preg_match('/10001/',$host)) { |
190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
190 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | 191 | //$formats[$id] = 'tsv'; |
192 | 192 | $globalSources[$id]['format'] = 'tsv'; |
193 | 193 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
194 | 194 | } |
195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
195 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
196 | 196 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
197 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
198 | 198 | if ($idf !== false) { |
199 | 199 | $httpfeeds[$id] = $idf; |
200 | 200 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
201 | 201 | } |
202 | 202 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
203 | 203 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | - $hostport = explode(':',$host); |
|
204 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
205 | + $hostport = explode(':', $host); |
|
206 | 206 | if (isset($hostport[1])) { |
207 | 207 | $port = $hostport[1]; |
208 | 208 | $hostn = $hostport[0]; |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | } |
213 | 213 | $Common = new Common(); |
214 | 214 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
215 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
216 | 216 | } else { |
217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
217 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
218 | 218 | } |
219 | 219 | if ($s) { |
220 | 220 | $sockets[$id] = $s; |
221 | 221 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
222 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
223 | 223 | //$formats[$id] = 'aprs'; |
224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
225 | 225 | //$aprs_connect = 0; |
226 | 226 | //$use_aprs = true; |
227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
227 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
229 | 229 | } elseif ($port == '10001') { |
230 | 230 | //$formats[$id] = 'tsv'; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
264 | 264 | else $timeout = 20; |
265 | 265 | $errno = ''; |
266 | -$errstr=''; |
|
266 | +$errstr = ''; |
|
267 | 267 | |
268 | 268 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
269 | 269 | /* Initiate connections to all the hosts simultaneously */ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | //connect_all($globalSources); |
272 | 272 | |
273 | 273 | if (isset($globalProxy) && $globalProxy) { |
274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
275 | 275 | } else { |
276 | 276 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
277 | 277 | } |
@@ -298,16 +298,16 @@ discard block |
||
298 | 298 | |
299 | 299 | if ($use_aprs) { |
300 | 300 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
301 | - $APRS=new APRS(); |
|
301 | + $APRS = new APRS(); |
|
302 | 302 | $aprs_connect = 0; |
303 | 303 | $aprs_keep = 120; |
304 | 304 | $aprs_last_tx = time(); |
305 | 305 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
306 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
306 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
307 | 307 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
308 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
308 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
309 | 309 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
310 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
310 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
311 | 311 | if ($aprs_full) $aprs_filter = ''; |
312 | 312 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
313 | 313 | else $aprs_pass = '-1'; |
@@ -321,12 +321,12 @@ discard block |
||
321 | 321 | sleep(1); |
322 | 322 | if ($globalDebug) echo "SCAN MODE \n\n"; |
323 | 323 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
324 | -$endtime = time()+$globalCronEnd; |
|
324 | +$endtime = time() + $globalCronEnd; |
|
325 | 325 | $i = 1; |
326 | 326 | $tt = array(); |
327 | 327 | // Delete all ATC |
328 | 328 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
329 | - $ATC=new ATC($Connection->db); |
|
329 | + $ATC = new ATC($Connection->db); |
|
330 | 330 | } |
331 | 331 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
332 | 332 | $ATC->deleteAll(); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
336 | 336 | while ($i > 0) { |
337 | - if (!$globalDaemon) $i = $endtime-time(); |
|
337 | + if (!$globalDaemon) $i = $endtime - time(); |
|
338 | 338 | // Delete old ATC |
339 | 339 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
340 | 340 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | } |
350 | 350 | if ($max != $globalMinFetch) { |
351 | 351 | if ($globalDebug) echo 'Sleeping...'."\n"; |
352 | - sleep($globalMinFetch-$max+2); |
|
352 | + sleep($globalMinFetch - $max + 2); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | //$buffer = $Common->getData($hosts[$id]); |
363 | 363 | $buffer = $Common->getData($value['host']); |
364 | 364 | if ($buffer != '') $reset = 0; |
365 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
366 | - $buffer = explode('\n',$buffer); |
|
365 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
366 | + $buffer = explode('\n', $buffer); |
|
367 | 367 | foreach ($buffer as $line) { |
368 | 368 | if ($line != '' && count($line) > 7) { |
369 | 369 | $line = explode(',', $line); |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | $last_exec[$id]['last'] = time(); |
391 | 391 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
392 | 392 | date_default_timezone_set('CET'); |
393 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
393 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
394 | 394 | date_default_timezone_set('UTC'); |
395 | 395 | if ($buffer != '') $reset = 0; |
396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | - $buffer = explode('\n',$buffer); |
|
396 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
397 | + $buffer = explode('\n', $buffer); |
|
398 | 398 | foreach ($buffer as $line) { |
399 | 399 | if ($line != '') { |
400 | 400 | echo "'".$line."'\n"; |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
413 | 413 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
414 | 414 | if (isset($ais_data['timestamp'])) { |
415 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
415 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
416 | 416 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
417 | 417 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
418 | 418 | $add = true; |
@@ -435,12 +435,12 @@ discard block |
||
435 | 435 | $w = $e = null; |
436 | 436 | |
437 | 437 | if (isset($arr[$id])) { |
438 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
438 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
439 | 439 | if ($nn > 0) { |
440 | 440 | foreach ($httpfeeds as $feed) { |
441 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
442 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
443 | - $buffer = explode('\n',$buffer); |
|
441 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
442 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
443 | + $buffer = explode('\n', $buffer); |
|
444 | 444 | foreach ($buffer as $line) { |
445 | 445 | if ($line != '') { |
446 | 446 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -456,9 +456,9 @@ discard block |
||
456 | 456 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
457 | 457 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
458 | 458 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
459 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
459 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
460 | 460 | if (isset($ais_data['timestamp'])) { |
461 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
461 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
462 | 462 | } else { |
463 | 463 | $data['datetime'] = date('Y-m-d H:i:s'); |
464 | 464 | } |
@@ -472,10 +472,10 @@ discard block |
||
472 | 472 | } |
473 | 473 | } |
474 | 474 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
475 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
475 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
476 | 476 | if ($buffer != '') { |
477 | 477 | //echo $buffer; |
478 | - $all_data = json_decode($buffer,true); |
|
478 | + $all_data = json_decode($buffer, true); |
|
479 | 479 | //print_r($all_data); |
480 | 480 | if (isset($all_data[0]['DATA'])) { |
481 | 481 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
491 | 491 | $data['imo'] = $line['IMO']; |
492 | 492 | //$data['arrival_code'] = $ais_data['destination']; |
493 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
493 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
494 | 494 | $data['format_source'] = 'myshiptracking'; |
495 | 495 | $data['id_source'] = $id_source; |
496 | 496 | $MI->add($data); |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | } |
503 | 503 | $last_exec[$id]['last'] = time(); |
504 | 504 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
505 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
505 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
506 | 506 | if ($buffer != '') { |
507 | - $all_data = json_decode($buffer,true); |
|
507 | + $all_data = json_decode($buffer, true); |
|
508 | 508 | if (isset($all_data[0]['mmsi'])) { |
509 | 509 | foreach ($all_data as $line) { |
510 | 510 | if ($line != '') { |
@@ -531,27 +531,27 @@ discard block |
||
531 | 531 | $last_exec[$id]['last'] = time(); |
532 | 532 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
533 | 533 | echo 'download...'; |
534 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
534 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
535 | 535 | echo 'done !'."\n"; |
536 | 536 | if ($buffer != '') $reset = 0; |
537 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
538 | - $buffer = explode('\n',$buffer); |
|
537 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
538 | + $buffer = explode('\n', $buffer); |
|
539 | 539 | foreach ($buffer as $line) { |
540 | 540 | if ($line != '') { |
541 | 541 | $data = array(); |
542 | - $data['mmsi'] = (int)substr($line,0,9); |
|
543 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
542 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
543 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
544 | 544 | //$data['status'] = substr($line,21,2); |
545 | 545 | //$data['type'] = substr($line,24,3); |
546 | - $data['latitude'] = substr($line,29,9); |
|
547 | - $data['longitude'] = substr($line,41,9); |
|
548 | - $data['speed'] = round(substr($line,51,5)); |
|
546 | + $data['latitude'] = substr($line, 29, 9); |
|
547 | + $data['longitude'] = substr($line, 41, 9); |
|
548 | + $data['speed'] = round(substr($line, 51, 5)); |
|
549 | 549 | //$data['course'] = substr($line,57,5); |
550 | - $data['heading'] = round(substr($line,63,3)); |
|
550 | + $data['heading'] = round(substr($line, 63, 3)); |
|
551 | 551 | //$data['draft'] = substr($line,67,4); |
552 | 552 | //$data['length'] = substr($line,72,3); |
553 | 553 | //$data['beam'] = substr($line,76,2); |
554 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
554 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
555 | 555 | //$data['callsign'] = trim(substr($line,100,7); |
556 | 556 | //$data['dest'] = substr($line,108,20); |
557 | 557 | //$data['etaDate'] = substr($line,129,5); |
@@ -569,8 +569,8 @@ discard block |
||
569 | 569 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
570 | 570 | //$buffer = $Common->getData($hosts[$id]); |
571 | 571 | $buffer = $Common->getData($value['host']); |
572 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
573 | - $buffer = explode('\n',$buffer); |
|
572 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
573 | + $buffer = explode('\n', $buffer); |
|
574 | 574 | $reset = 0; |
575 | 575 | foreach ($buffer as $line) { |
576 | 576 | if ($line != '') { |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
582 | 582 | $data['pilot_id'] = $line[1]; |
583 | 583 | $data['pilot_name'] = $line[2]; |
584 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
584 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
585 | 585 | $data['ident'] = $line[0]; // ident |
586 | 586 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
587 | 587 | $data['speed'] = $line[8]; // speed |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
598 | 598 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
599 | 599 | $data['departure_airport_icao'] = $line[11]; |
600 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
600 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
601 | 601 | $data['arrival_airport_icao'] = $line[13]; |
602 | 602 | $data['frequency'] = $line[4]; |
603 | 603 | $data['type'] = $line[18]; |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | $data['id_source'] = $id_source; |
607 | 607 | //$data['arrival_airport_time'] = ; |
608 | 608 | if ($line[9] != '') { |
609 | - $aircraft_data = explode('/',$line[9]); |
|
609 | + $aircraft_data = explode('/', $line[9]); |
|
610 | 610 | if (isset($aircraft_data[1])) { |
611 | 611 | $data['aircraft_icao'] = $aircraft_data[1]; |
612 | 612 | } |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | if ($line[3] == 'PILOT') $SI->add($data); |
621 | 621 | elseif ($line[3] == 'ATC') { |
622 | 622 | //print_r($data); |
623 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
624 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
625 | - $typec = substr($data['ident'],-3); |
|
623 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
624 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
625 | + $typec = substr($data['ident'], -3); |
|
626 | 626 | if ($typec == 'APP') $data['type'] = 'Approach'; |
627 | 627 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
628 | 628 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
634 | 634 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
635 | 635 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
636 | - if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
636 | + if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
637 | 637 | } |
638 | 638 | unset($data); |
639 | 639 | } |
@@ -644,9 +644,9 @@ discard block |
||
644 | 644 | $last_exec[$id]['last'] = time(); |
645 | 645 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
646 | 646 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
647 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
647 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
648 | 648 | if ($buffer != '') { |
649 | - $all_data = json_decode($buffer,true); |
|
649 | + $all_data = json_decode($buffer, true); |
|
650 | 650 | if (isset($all_data['acList'])) { |
651 | 651 | $reset = 0; |
652 | 652 | foreach ($all_data['acList'] as $line) { |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
703 | 703 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
704 | 704 | $buffer = $Common->getData($value['host']); |
705 | - $all_data = json_decode($buffer,true); |
|
705 | + $all_data = json_decode($buffer, true); |
|
706 | 706 | if (isset($all_data['planes'])) { |
707 | 707 | $reset = 0; |
708 | 708 | foreach ($all_data['planes'] as $key => $line) { |
@@ -719,12 +719,12 @@ discard block |
||
719 | 719 | $data['emergency'] = ''; // emergency |
720 | 720 | $data['registration'] = $line[2]; |
721 | 721 | $data['aircraft_icao'] = $line[0]; |
722 | - $deparr = explode('-',$line[1]); |
|
722 | + $deparr = explode('-', $line[1]); |
|
723 | 723 | if (count($deparr) == 2) { |
724 | 724 | $data['departure_airport_icao'] = $deparr[0]; |
725 | 725 | $data['arrival_airport_icao'] = $deparr[1]; |
726 | 726 | } |
727 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
727 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
728 | 728 | $data['format_source'] = 'planeupdatefaa'; |
729 | 729 | $data['id_source'] = $id_source; |
730 | 730 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | $last_exec[$id]['last'] = time(); |
737 | 737 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
738 | 738 | $buffer = $Common->getData($value['host']); |
739 | - $all_data = json_decode($buffer,true); |
|
739 | + $all_data = json_decode($buffer, true); |
|
740 | 740 | if (isset($all_data['states'])) { |
741 | 741 | $reset = 0; |
742 | 742 | foreach ($all_data['states'] as $key => $line) { |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | //$data['emergency'] = ''; // emergency |
754 | 754 | //$data['registration'] = $line[2]; |
755 | 755 | //$data['aircraft_icao'] = $line[0]; |
756 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
756 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
757 | 757 | $data['format_source'] = 'opensky'; |
758 | 758 | $data['id_source'] = $id_source; |
759 | 759 | $SI->add($data); |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
767 | 767 | //$buffer = $Common->getData($hosts[$id]); |
768 | 768 | $buffer = $Common->getData($value['host']); |
769 | - $all_data = json_decode($buffer,true); |
|
769 | + $all_data = json_decode($buffer, true); |
|
770 | 770 | if (!empty($all_data)) $reset = 0; |
771 | 771 | foreach ($all_data as $key => $line) { |
772 | 772 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -798,11 +798,11 @@ discard block |
||
798 | 798 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
799 | 799 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
800 | 800 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
801 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
801 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
802 | 802 | //echo $buffer; |
803 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
804 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
805 | - $all_data = json_decode($buffer,true); |
|
803 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
804 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
805 | + $all_data = json_decode($buffer, true); |
|
806 | 806 | if (json_last_error() != JSON_ERROR_NONE) { |
807 | 807 | die(json_last_error_msg()); |
808 | 808 | } |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | //$data['departure_airport_iata'] = $line[11]; |
826 | 826 | //$data['arrival_airport_iata'] = $line[12]; |
827 | 827 | //$data['emergency'] = ''; // emergency |
828 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
828 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
829 | 829 | $data['format_source'] = 'radarvirtueljson'; |
830 | 830 | $data['id_source'] = $id_source; |
831 | 831 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -840,14 +840,14 @@ discard block |
||
840 | 840 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
841 | 841 | //$buffer = $Common->getData($hosts[$id]); |
842 | 842 | $buffer = $Common->getData($value['host'].'?'.time()); |
843 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
843 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
844 | 844 | |
845 | 845 | if (isset($all_data['pireps'])) { |
846 | 846 | $reset = 0; |
847 | 847 | foreach ($all_data['pireps'] as $line) { |
848 | 848 | $data = array(); |
849 | 849 | $data['id'] = $line['id']; |
850 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
850 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
851 | 851 | $data['ident'] = $line['callsign']; // ident |
852 | 852 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
853 | 853 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -876,9 +876,9 @@ discard block |
||
876 | 876 | $SI->add($data); |
877 | 877 | // print_r($data); |
878 | 878 | } elseif ($line['icon'] == 'ct') { |
879 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
880 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
881 | - $typec = substr($data['ident'],-3); |
|
879 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
880 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
881 | + $typec = substr($data['ident'], -3); |
|
882 | 882 | $data['type'] = ''; |
883 | 883 | if ($typec == 'APP') $data['type'] = 'Approach'; |
884 | 884 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
890 | 890 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
891 | 891 | else $data['type'] = 'Observer'; |
892 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
892 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
893 | 893 | } |
894 | 894 | unset($data); |
895 | 895 | } |
@@ -901,14 +901,14 @@ discard block |
||
901 | 901 | //$buffer = $Common->getData($hosts[$id]); |
902 | 902 | if ($globalDebug) echo 'Get Data...'."\n"; |
903 | 903 | $buffer = $Common->getData($value['host']); |
904 | - $all_data = json_decode($buffer,true); |
|
904 | + $all_data = json_decode($buffer, true); |
|
905 | 905 | if ($buffer != '' && is_array($all_data)) { |
906 | 906 | $reset = 0; |
907 | 907 | foreach ($all_data as $line) { |
908 | 908 | $data = array(); |
909 | 909 | //$data['id'] = $line['id']; // id not usable |
910 | 910 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
911 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
911 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
912 | 912 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
913 | 913 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
914 | 914 | $data['ident'] = $line['flightnum']; // ident |
@@ -931,14 +931,14 @@ discard block |
||
931 | 931 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
932 | 932 | if (isset($line['aircraftname'])) { |
933 | 933 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
934 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
935 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
934 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
935 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
936 | 936 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
937 | 937 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
938 | 938 | else { |
939 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
940 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
941 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
939 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
940 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
941 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
942 | 942 | } |
943 | 943 | } |
944 | 944 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -958,14 +958,14 @@ discard block |
||
958 | 958 | //$buffer = $Common->getData($hosts[$id]); |
959 | 959 | if ($globalDebug) echo 'Get Data...'."\n"; |
960 | 960 | $buffer = $Common->getData($value['host']); |
961 | - $all_data = json_decode($buffer,true); |
|
961 | + $all_data = json_decode($buffer, true); |
|
962 | 962 | if ($buffer != '' && is_array($all_data)) { |
963 | 963 | $reset = 0; |
964 | 964 | foreach ($all_data as $line) { |
965 | 965 | $data = array(); |
966 | 966 | //$data['id'] = $line['id']; // id not usable |
967 | 967 | $data['id'] = trim($line['flight_id']); |
968 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
968 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
969 | 969 | $data['pilot_name'] = $line['pilot_name']; |
970 | 970 | $data['pilot_id'] = $line['pilot_id']; |
971 | 971 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1016,11 +1016,11 @@ discard block |
||
1016 | 1016 | //$value = $formats[$nb]; |
1017 | 1017 | $format = $globalSources[$nb]['format']; |
1018 | 1018 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1019 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1019 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1020 | 1020 | } elseif ($format == 'vrstcp') { |
1021 | 1021 | $buffer = @socket_read($r, 6000); |
1022 | 1022 | } else { |
1023 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1023 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1024 | 1024 | } |
1025 | 1025 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1026 | 1026 | //echo $buffer."\n"; |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | $error = false; |
1030 | 1030 | //$SI::del(); |
1031 | 1031 | if ($format == 'vrstcp') { |
1032 | - $buffer = explode('},{',$buffer); |
|
1033 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1032 | + $buffer = explode('},{', $buffer); |
|
1033 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1034 | 1034 | // SBS format is CSV format |
1035 | 1035 | if ($buffer !== FALSE && $buffer != '') { |
1036 | 1036 | $tt[$format] = 0; |
@@ -1062,10 +1062,10 @@ discard block |
||
1062 | 1062 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1063 | 1063 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1064 | 1064 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1065 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1065 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1066 | 1066 | |
1067 | 1067 | if (isset($ais_data['timestamp'])) { |
1068 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1068 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1069 | 1069 | } else { |
1070 | 1070 | $data['datetime'] = date('Y-m-d H:i:s'); |
1071 | 1071 | } |
@@ -1076,10 +1076,10 @@ discard block |
||
1076 | 1076 | } elseif ($format == 'flightgearsp') { |
1077 | 1077 | //echo $buffer."\n"; |
1078 | 1078 | if (strlen($buffer) > 5) { |
1079 | - $line = explode(',',$buffer); |
|
1079 | + $line = explode(',', $buffer); |
|
1080 | 1080 | $data = array(); |
1081 | 1081 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1082 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1082 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1083 | 1083 | $data['ident'] = $line[6]; |
1084 | 1084 | $data['aircraft_name'] = $line[7]; |
1085 | 1085 | $data['longitude'] = $line[1]; |
@@ -1090,21 +1090,21 @@ discard block |
||
1090 | 1090 | $data['datetime'] = date('Y-m-d H:i:s'); |
1091 | 1091 | $data['format_source'] = 'flightgearsp'; |
1092 | 1092 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1093 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1093 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1094 | 1094 | } |
1095 | 1095 | } elseif ($format == 'acars') { |
1096 | 1096 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1097 | 1097 | $ACARS->add(trim($buffer)); |
1098 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1098 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1099 | 1099 | $ACARS->deleteLiveAcarsData(); |
1100 | 1100 | } elseif ($format == 'flightgearmp') { |
1101 | - if (substr($buffer,0,1) != '#') { |
|
1101 | + if (substr($buffer, 0, 1) != '#') { |
|
1102 | 1102 | $data = array(); |
1103 | 1103 | //echo $buffer."\n"; |
1104 | - $line = explode(' ',$buffer); |
|
1104 | + $line = explode(' ', $buffer); |
|
1105 | 1105 | if (count($line) == 11) { |
1106 | - $userserver = explode('@',$line[0]); |
|
1107 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1106 | + $userserver = explode('@', $line[0]); |
|
1107 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1108 | 1108 | $data['ident'] = $userserver[0]; |
1109 | 1109 | $data['registration'] = $userserver[0]; |
1110 | 1110 | $data['latitude'] = $line[4]; |
@@ -1112,8 +1112,8 @@ discard block |
||
1112 | 1112 | $data['altitude'] = $line[6]; |
1113 | 1113 | $data['datetime'] = date('Y-m-d H:i:s'); |
1114 | 1114 | $aircraft_type = $line[10]; |
1115 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1116 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1115 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1116 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1117 | 1117 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1121,8 +1121,8 @@ discard block |
||
1121 | 1121 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1122 | 1122 | die; |
1123 | 1123 | } elseif ($format == 'vrstcp') { |
1124 | - foreach($buffer as $all_data) { |
|
1125 | - $line = json_decode('{'.$all_data.'}',true); |
|
1124 | + foreach ($buffer as $all_data) { |
|
1125 | + $line = json_decode('{'.$all_data.'}', true); |
|
1126 | 1126 | $data = array(); |
1127 | 1127 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1128 | 1128 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1147,16 +1147,16 @@ discard block |
||
1147 | 1147 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1148 | 1148 | unset($data); |
1149 | 1149 | } |
1150 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1150 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1151 | 1151 | $line = explode("\t", $buffer); |
1152 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1152 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1153 | 1153 | $key = $line[$k]; |
1154 | - $lined[$key] = $line[$k+1]; |
|
1154 | + $lined[$key] = $line[$k + 1]; |
|
1155 | 1155 | } |
1156 | 1156 | if (count($lined) > 3) { |
1157 | 1157 | $data['hex'] = $lined['hexid']; |
1158 | 1158 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1159 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1159 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1160 | 1160 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1161 | 1161 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1162 | 1162 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1174,22 +1174,22 @@ discard block |
||
1174 | 1174 | } else $error = true; |
1175 | 1175 | } elseif ($format == 'aprs' && $use_aprs) { |
1176 | 1176 | if ($aprs_connect == 0) { |
1177 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1177 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1178 | 1178 | $aprs_connect = 1; |
1179 | 1179 | } |
1180 | 1180 | |
1181 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1181 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1182 | 1182 | $aprs_last_tx = time(); |
1183 | 1183 | $data_aprs = "# Keep alive"; |
1184 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1184 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1188 | 1188 | //echo 'APRS data : '.$buffer."\n"; |
1189 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1190 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1189 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1190 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1191 | 1191 | //echo $buffer."\n"; |
1192 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1192 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1193 | 1193 | $line = $APRS->parse($buffer); |
1194 | 1194 | //print_r($line); |
1195 | 1195 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | $data = array(); |
1199 | 1199 | //print_r($line); |
1200 | 1200 | if (isset($line['address'])) $data['hex'] = $line['address']; |
1201 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1201 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1202 | 1202 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1203 | 1203 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1204 | 1204 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | $currentdate = date('Y-m-d H:i:s'); |
1225 | 1225 | $aprsdate = strtotime($data['datetime']); |
1226 | 1226 | // Accept data if time <= system time + 20s |
1227 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1227 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1228 | 1228 | $send = $SI->add($data); |
1229 | 1229 | } elseif (isset($line['stealth'])) { |
1230 | 1230 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | connect_all($sourceee); |
1322 | 1322 | $sourceee = array(); |
1323 | 1323 | //connect_all($globalSources); |
1324 | - $tt[$format]=0; |
|
1324 | + $tt[$format] = 0; |
|
1325 | 1325 | break; |
1326 | 1326 | } |
1327 | 1327 | } |
@@ -1330,14 +1330,14 @@ discard block |
||
1330 | 1330 | } else { |
1331 | 1331 | $error = socket_strerror(socket_last_error()); |
1332 | 1332 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1333 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1333 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1334 | 1334 | if (isset($globalDebug)) echo "Restarting...\n"; |
1335 | 1335 | // Restart the script if possible |
1336 | 1336 | if (is_array($sockets)) { |
1337 | 1337 | if ($globalDebug) echo "Shutdown all sockets..."; |
1338 | 1338 | |
1339 | 1339 | foreach ($sockets as $sock) { |
1340 | - @socket_shutdown($sock,2); |
|
1340 | + @socket_shutdown($sock, 2); |
|
1341 | 1341 | @socket_close($sock); |
1342 | 1342 | } |
1343 | 1343 |
@@ -13,13 +13,17 @@ discard block |
||
13 | 13 | require_once(dirname(__FILE__).'/../require/class.SBS.php'); |
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
16 | +if (isset($globalTracker) && $globalTracker) { |
|
17 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
18 | +} |
|
17 | 19 | if (isset($globalMarine) && $globalMarine) { |
18 | 20 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
20 | 22 | } |
21 | 23 | |
22 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
24 | +if (!isset($globalDebug)) { |
|
25 | + $globalDebug = FALSE; |
|
26 | +} |
|
23 | 27 | |
24 | 28 | // Check if schema is at latest version |
25 | 29 | $Connection = new Connection(); |
@@ -59,22 +63,39 @@ discard block |
||
59 | 63 | $globalSources = array(); |
60 | 64 | $globalSources[] = array('host' => $options['source']); |
61 | 65 | } |
62 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
63 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
64 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
65 | -if (isset($options['server'])) $globalServer = TRUE; |
|
66 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
67 | -else $id_source = 1; |
|
66 | +if (isset($options['aprsserverssid'])) { |
|
67 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
68 | +} |
|
69 | +if (isset($options['aprsserverpass'])) { |
|
70 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
71 | +} |
|
72 | +if (isset($options['nodaemon'])) { |
|
73 | + $globalDaemon = FALSE; |
|
74 | +} |
|
75 | +if (isset($options['server'])) { |
|
76 | + $globalServer = TRUE; |
|
77 | +} |
|
78 | +if (isset($options['idsource'])) { |
|
79 | + $id_source = $options['idsource']; |
|
80 | +} else { |
|
81 | + $id_source = 1; |
|
82 | +} |
|
68 | 83 | if (isset($globalServer) && $globalServer) { |
69 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
84 | + if ($globalDebug) { |
|
85 | + echo "Using Server Mode\n"; |
|
86 | + } |
|
70 | 87 | $SI=new SpotterServer(); |
71 | 88 | /* |
72 | 89 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 90 | $SI = new adsb2aprs(); |
74 | 91 | $SI->connect(); |
75 | 92 | */ |
76 | -} else $SI=new SpotterImport($Connection->db); |
|
77 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
93 | +} else { |
|
94 | + $SI=new SpotterImport($Connection->db); |
|
95 | +} |
|
96 | +if (isset($globalTracker) && $globalTracker) { |
|
97 | + $TI = new TrackerImport($Connection->db); |
|
98 | +} |
|
78 | 99 | if (isset($globalMarine) && $globalMarine) { |
79 | 100 | $AIS = new AIS(); |
80 | 101 | $MI = new MarineImport($Connection->db); |
@@ -96,7 +117,9 @@ discard block |
||
96 | 117 | } |
97 | 118 | |
98 | 119 | // let's try and connect |
99 | -if ($globalDebug) echo "Connecting...\n"; |
|
120 | +if ($globalDebug) { |
|
121 | + echo "Connecting...\n"; |
|
122 | +} |
|
100 | 123 | $use_aprs = false; |
101 | 124 | $aprs_full = false; |
102 | 125 | $reset = 0; |
@@ -105,7 +128,9 @@ discard block |
||
105 | 128 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
106 | 129 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
107 | 130 | $reset++; |
108 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
131 | + if ($globalDebug) { |
|
132 | + echo 'Connect to all...'."\n"; |
|
133 | + } |
|
109 | 134 | foreach ($hosts as $id => $value) { |
110 | 135 | $host = $value['host']; |
111 | 136 | $globalSources[$id]['last_exec'] = 0; |
@@ -115,27 +140,37 @@ discard block |
||
115 | 140 | //$formats[$id] = 'deltadbtxt'; |
116 | 141 | $globalSources[$id]['format'] = 'deltadbtxt'; |
117 | 142 | //$last_exec['deltadbtxt'] = 0; |
118 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
143 | + if ($globalDebug) { |
|
144 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
145 | + } |
|
119 | 146 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
120 | 147 | //$formats[$id] = 'vatsimtxt'; |
121 | 148 | $globalSources[$id]['format'] = 'vatsimtxt'; |
122 | 149 | //$last_exec['vatsimtxt'] = 0; |
123 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
150 | + if ($globalDebug) { |
|
151 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
152 | + } |
|
124 | 153 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
125 | 154 | //$formats[$id] = 'aircraftlistjson'; |
126 | 155 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
127 | 156 | //$last_exec['aircraftlistjson'] = 0; |
128 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
157 | + if ($globalDebug) { |
|
158 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
159 | + } |
|
129 | 160 | } else if (preg_match('/opensky/i',$host)) { |
130 | 161 | //$formats[$id] = 'aircraftlistjson'; |
131 | 162 | $globalSources[$id]['format'] = 'opensky'; |
132 | 163 | //$last_exec['aircraftlistjson'] = 0; |
133 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
164 | + if ($globalDebug) { |
|
165 | + echo "Connect to opensky source (".$host.")...\n"; |
|
166 | + } |
|
134 | 167 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
135 | 168 | //$formats[$id] = 'radarvirtueljson'; |
136 | 169 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
137 | 170 | //$last_exec['radarvirtueljson'] = 0; |
138 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
171 | + if ($globalDebug) { |
|
172 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
173 | + } |
|
139 | 174 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
140 | 175 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
141 | 176 | exit(0); |
@@ -144,7 +179,9 @@ discard block |
||
144 | 179 | //$formats[$id] = 'planeupdatefaa'; |
145 | 180 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
146 | 181 | //$last_exec['planeupdatefaa'] = 0; |
147 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
182 | + if ($globalDebug) { |
|
183 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
184 | + } |
|
148 | 185 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
149 | 186 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
150 | 187 | exit(0); |
@@ -153,26 +190,36 @@ discard block |
||
153 | 190 | //$formats[$id] = 'phpvmacars'; |
154 | 191 | $globalSources[$id]['format'] = 'phpvmacars'; |
155 | 192 | //$last_exec['phpvmacars'] = 0; |
156 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
195 | + } |
|
157 | 196 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
158 | 197 | //$formats[$id] = 'phpvmacars'; |
159 | 198 | $globalSources[$id]['format'] = 'vam'; |
160 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
199 | + if ($globalDebug) { |
|
200 | + echo "Connect to Vam source (".$host.")...\n"; |
|
201 | + } |
|
161 | 202 | } else if (preg_match('/whazzup/i',$host)) { |
162 | 203 | //$formats[$id] = 'whazzup'; |
163 | 204 | $globalSources[$id]['format'] = 'whazzup'; |
164 | 205 | //$last_exec['whazzup'] = 0; |
165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
206 | + if ($globalDebug) { |
|
207 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
208 | + } |
|
166 | 209 | } else if (preg_match('/recentpireps/i',$host)) { |
167 | 210 | //$formats[$id] = 'pirepsjson'; |
168 | 211 | $globalSources[$id]['format'] = 'pirepsjson'; |
169 | 212 | //$last_exec['pirepsjson'] = 0; |
170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
213 | + if ($globalDebug) { |
|
214 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
215 | + } |
|
171 | 216 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
172 | 217 | //$formats[$id] = 'fr24json'; |
173 | 218 | $globalSources[$id]['format'] = 'fr24json'; |
174 | 219 | //$last_exec['fr24json'] = 0; |
175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
220 | + if ($globalDebug) { |
|
221 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
222 | + } |
|
176 | 223 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
177 | 224 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
178 | 225 | exit(0); |
@@ -181,7 +228,9 @@ discard block |
||
181 | 228 | //$formats[$id] = 'fr24json'; |
182 | 229 | $globalSources[$id]['format'] = 'myshiptracking'; |
183 | 230 | //$last_exec['fr24json'] = 0; |
184 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
231 | + if ($globalDebug) { |
|
232 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
233 | + } |
|
185 | 234 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
186 | 235 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
187 | 236 | exit(0); |
@@ -190,17 +239,24 @@ discard block |
||
190 | 239 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
191 | 240 | //$formats[$id] = 'tsv'; |
192 | 241 | $globalSources[$id]['format'] = 'tsv'; |
193 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "Connect to tsv source (".$host.")...\n"; |
|
244 | + } |
|
194 | 245 | } |
195 | 246 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
196 | 247 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
197 | 248 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
198 | 249 | if ($idf !== false) { |
199 | 250 | $httpfeeds[$id] = $idf; |
200 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
251 | + if ($globalDebug) { |
|
252 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
253 | + } |
|
254 | + } elseif ($globalDebug) { |
|
255 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
201 | 256 | } |
202 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
257 | + } elseif ($globalDebug) { |
|
258 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
259 | + } |
|
204 | 260 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
205 | 261 | $hostport = explode(':',$host); |
206 | 262 | if (isset($hostport[1])) { |
@@ -240,17 +296,25 @@ discard block |
||
240 | 296 | //$formats[$id] = 'beast'; |
241 | 297 | $globalSources[$id]['format'] = 'beast'; |
242 | 298 | //} else $formats[$id] = 'sbs'; |
243 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
299 | + } else { |
|
300 | + $globalSources[$id]['format'] = 'sbs'; |
|
301 | + } |
|
244 | 302 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
245 | 303 | } |
246 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
304 | + if ($globalDebug) { |
|
305 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
306 | + } |
|
247 | 307 | } else { |
248 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
308 | + if ($globalDebug) { |
|
309 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
310 | + } |
|
249 | 311 | } |
250 | 312 | } |
251 | 313 | } |
252 | 314 | } |
253 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
315 | +if (!isset($globalMinFetch)) { |
|
316 | + $globalMinFetch = 15; |
|
317 | +} |
|
254 | 318 | |
255 | 319 | // Initialize all |
256 | 320 | $status = array(); |
@@ -259,13 +323,19 @@ discard block |
||
259 | 323 | $formats = array(); |
260 | 324 | $last_exec = array(); |
261 | 325 | $time = time(); |
262 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
263 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
264 | -else $timeout = 20; |
|
326 | +if (isset($globalSourcesTimeout)) { |
|
327 | + $timeout = $globalSourcesTimeOut; |
|
328 | +} else if (isset($globalSBS1TimeOut)) { |
|
329 | + $timeout = $globalSBS1TimeOut; |
|
330 | +} else { |
|
331 | + $timeout = 20; |
|
332 | +} |
|
265 | 333 | $errno = ''; |
266 | 334 | $errstr=''; |
267 | 335 | |
268 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
336 | +if (!isset($globalDaemon)) { |
|
337 | + $globalDaemon = TRUE; |
|
338 | +} |
|
269 | 339 | /* Initiate connections to all the hosts simultaneously */ |
270 | 340 | //connect_all($hosts); |
271 | 341 | //connect_all($globalSources); |
@@ -291,7 +361,9 @@ discard block |
||
291 | 361 | if (isset($source['format']) && $source['format'] == 'aprs') { |
292 | 362 | $aprs_connect = 0; |
293 | 363 | $use_aprs = true; |
294 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
364 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
365 | + $aprs_full = true; |
|
366 | + } |
|
295 | 367 | break; |
296 | 368 | } |
297 | 369 | } |
@@ -302,25 +374,48 @@ discard block |
||
302 | 374 | $aprs_connect = 0; |
303 | 375 | $aprs_keep = 120; |
304 | 376 | $aprs_last_tx = time(); |
305 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
306 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
307 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
308 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
309 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
310 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
311 | - if ($aprs_full) $aprs_filter = ''; |
|
312 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
313 | - else $aprs_pass = '-1'; |
|
377 | + if (isset($globalAPRSversion)) { |
|
378 | + $aprs_version = $globalAPRSversion; |
|
379 | + } else { |
|
380 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
381 | + } |
|
382 | + if (isset($globalAPRSssid)) { |
|
383 | + $aprs_ssid = $globalAPRSssid; |
|
384 | + } else { |
|
385 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
386 | + } |
|
387 | + if (isset($globalAPRSfilter)) { |
|
388 | + $aprs_filter = $globalAPRSfilter; |
|
389 | + } else { |
|
390 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
391 | + } |
|
392 | + if ($aprs_full) { |
|
393 | + $aprs_filter = ''; |
|
394 | + } |
|
395 | + if (isset($globalAPRSpass)) { |
|
396 | + $aprs_pass = $globalAPRSpass; |
|
397 | + } else { |
|
398 | + $aprs_pass = '-1'; |
|
399 | + } |
|
314 | 400 | |
315 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
316 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
317 | -} |
|
401 | + if ($aprs_filter != '') { |
|
402 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
403 | + } else { |
|
404 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
405 | + } |
|
406 | + } |
|
318 | 407 | |
319 | 408 | // connected - lets do some work |
320 | -if ($globalDebug) echo "Connected!\n"; |
|
409 | +if ($globalDebug) { |
|
410 | + echo "Connected!\n"; |
|
411 | +} |
|
321 | 412 | sleep(1); |
322 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
323 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
413 | +if ($globalDebug) { |
|
414 | + echo "SCAN MODE \n\n"; |
|
415 | +} |
|
416 | +if (!isset($globalCronEnd)) { |
|
417 | + $globalCronEnd = 60; |
|
418 | +} |
|
324 | 419 | $endtime = time()+$globalCronEnd; |
325 | 420 | $i = 1; |
326 | 421 | $tt = array(); |
@@ -334,10 +429,14 @@ discard block |
||
334 | 429 | |
335 | 430 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
336 | 431 | while ($i > 0) { |
337 | - if (!$globalDaemon) $i = $endtime-time(); |
|
432 | + if (!$globalDaemon) { |
|
433 | + $i = $endtime-time(); |
|
434 | + } |
|
338 | 435 | // Delete old ATC |
339 | 436 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
340 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
437 | + if ($globalDebug) { |
|
438 | + echo 'Delete old ATC...'."\n"; |
|
439 | + } |
|
341 | 440 | $ATC->deleteOldATC(); |
342 | 441 | } |
343 | 442 | |
@@ -345,10 +444,14 @@ discard block |
||
345 | 444 | if (count($last_exec) == count($globalSources)) { |
346 | 445 | $max = $globalMinFetch; |
347 | 446 | foreach ($last_exec as $last) { |
348 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
447 | + if ((time() - $last['last']) < $max) { |
|
448 | + $max = time() - $last['last']; |
|
449 | + } |
|
349 | 450 | } |
350 | 451 | if ($max != $globalMinFetch) { |
351 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
452 | + if ($globalDebug) { |
|
453 | + echo 'Sleeping...'."\n"; |
|
454 | + } |
|
352 | 455 | sleep($globalMinFetch-$max+2); |
353 | 456 | } |
354 | 457 | } |
@@ -357,11 +460,15 @@ discard block |
||
357 | 460 | //foreach ($formats as $id => $value) { |
358 | 461 | foreach ($globalSources as $id => $value) { |
359 | 462 | date_default_timezone_set('UTC'); |
360 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
463 | + if (!isset($last_exec[$id]['last'])) { |
|
464 | + $last_exec[$id]['last'] = 0; |
|
465 | + } |
|
361 | 466 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
362 | 467 | //$buffer = $Common->getData($hosts[$id]); |
363 | 468 | $buffer = $Common->getData($value['host']); |
364 | - if ($buffer != '') $reset = 0; |
|
469 | + if ($buffer != '') { |
|
470 | + $reset = 0; |
|
471 | + } |
|
365 | 472 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
366 | 473 | $buffer = explode('\n',$buffer); |
367 | 474 | foreach ($buffer as $line) { |
@@ -370,19 +477,38 @@ discard block |
||
370 | 477 | $data = array(); |
371 | 478 | $data['hex'] = $line[1]; // hex |
372 | 479 | $data['ident'] = $line[2]; // ident |
373 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
374 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
375 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
376 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
377 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
480 | + if (isset($line[3])) { |
|
481 | + $data['altitude'] = $line[3]; |
|
482 | + } |
|
483 | + // altitude |
|
484 | + if (isset($line[4])) { |
|
485 | + $data['speed'] = $line[4]; |
|
486 | + } |
|
487 | + // speed |
|
488 | + if (isset($line[5])) { |
|
489 | + $data['heading'] = $line[5]; |
|
490 | + } |
|
491 | + // heading |
|
492 | + if (isset($line[6])) { |
|
493 | + $data['latitude'] = $line[6]; |
|
494 | + } |
|
495 | + // lat |
|
496 | + if (isset($line[7])) { |
|
497 | + $data['longitude'] = $line[7]; |
|
498 | + } |
|
499 | + // long |
|
378 | 500 | $data['verticalrate'] = ''; // vertical rate |
379 | 501 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
380 | 502 | $data['emergency'] = ''; // emergency |
381 | 503 | $data['datetime'] = date('Y-m-d H:i:s'); |
382 | 504 | $data['format_source'] = 'deltadbtxt'; |
383 | 505 | $data['id_source'] = $id_source; |
384 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
385 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
506 | + if (isset($value['name']) && $value['name'] != '') { |
|
507 | + $data['source_name'] = $value['name']; |
|
508 | + } |
|
509 | + if (isset($value['sourcestats'])) { |
|
510 | + $data['sourcestats'] = $value['sourcestats']; |
|
511 | + } |
|
386 | 512 | $SI->add($data); |
387 | 513 | unset($data); |
388 | 514 | } |
@@ -392,7 +518,9 @@ discard block |
||
392 | 518 | date_default_timezone_set('CET'); |
393 | 519 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
394 | 520 | date_default_timezone_set('UTC'); |
395 | - if ($buffer != '') $reset = 0; |
|
521 | + if ($buffer != '') { |
|
522 | + $reset = 0; |
|
523 | + } |
|
396 | 524 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
397 | 525 | $buffer = explode('\n',$buffer); |
398 | 526 | foreach ($buffer as $line) { |
@@ -401,16 +529,36 @@ discard block |
||
401 | 529 | $add = false; |
402 | 530 | $ais_data = $AIS->parse_line(trim($line)); |
403 | 531 | $data = array(); |
404 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
405 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
406 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
407 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
408 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
409 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
410 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
411 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
412 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
413 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
532 | + if (isset($ais_data['ident'])) { |
|
533 | + $data['ident'] = $ais_data['ident']; |
|
534 | + } |
|
535 | + if (isset($ais_data['mmsi'])) { |
|
536 | + $data['mmsi'] = $ais_data['mmsi']; |
|
537 | + } |
|
538 | + if (isset($ais_data['speed'])) { |
|
539 | + $data['speed'] = $ais_data['speed']; |
|
540 | + } |
|
541 | + if (isset($ais_data['heading'])) { |
|
542 | + $data['heading'] = $ais_data['heading']; |
|
543 | + } |
|
544 | + if (isset($ais_data['latitude'])) { |
|
545 | + $data['latitude'] = $ais_data['latitude']; |
|
546 | + } |
|
547 | + if (isset($ais_data['longitude'])) { |
|
548 | + $data['longitude'] = $ais_data['longitude']; |
|
549 | + } |
|
550 | + if (isset($ais_data['status'])) { |
|
551 | + $data['status'] = $ais_data['status']; |
|
552 | + } |
|
553 | + if (isset($ais_data['type'])) { |
|
554 | + $data['type'] = $ais_data['type']; |
|
555 | + } |
|
556 | + if (isset($ais_data['imo'])) { |
|
557 | + $data['imo'] = $ais_data['imo']; |
|
558 | + } |
|
559 | + if (isset($ais_data['callsign'])) { |
|
560 | + $data['callsign'] = $ais_data['callsign']; |
|
561 | + } |
|
414 | 562 | if (isset($ais_data['timestamp'])) { |
415 | 563 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
416 | 564 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -425,7 +573,9 @@ discard block |
||
425 | 573 | $data['id_source'] = $id_source; |
426 | 574 | print_r($data); |
427 | 575 | echo 'Add...'."\n"; |
428 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
576 | + if ($add && $ais_data['mmsi_type'] == 'Ship') { |
|
577 | + $MI->add($data); |
|
578 | + } |
|
429 | 579 | unset($data); |
430 | 580 | } |
431 | 581 | } |
@@ -445,18 +595,42 @@ discard block |
||
445 | 595 | if ($line != '') { |
446 | 596 | $ais_data = $AIS->parse_line(trim($line)); |
447 | 597 | $data = array(); |
448 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
449 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
450 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
451 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
452 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
453 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
454 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
455 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
456 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
457 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
458 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
459 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
598 | + if (isset($ais_data['ident'])) { |
|
599 | + $data['ident'] = $ais_data['ident']; |
|
600 | + } |
|
601 | + if (isset($ais_data['mmsi'])) { |
|
602 | + $data['mmsi'] = $ais_data['mmsi']; |
|
603 | + } |
|
604 | + if (isset($ais_data['speed'])) { |
|
605 | + $data['speed'] = $ais_data['speed']; |
|
606 | + } |
|
607 | + if (isset($ais_data['heading'])) { |
|
608 | + $data['heading'] = $ais_data['heading']; |
|
609 | + } |
|
610 | + if (isset($ais_data['latitude'])) { |
|
611 | + $data['latitude'] = $ais_data['latitude']; |
|
612 | + } |
|
613 | + if (isset($ais_data['longitude'])) { |
|
614 | + $data['longitude'] = $ais_data['longitude']; |
|
615 | + } |
|
616 | + if (isset($ais_data['status'])) { |
|
617 | + $data['status'] = $ais_data['status']; |
|
618 | + } |
|
619 | + if (isset($ais_data['type'])) { |
|
620 | + $data['type'] = $ais_data['type']; |
|
621 | + } |
|
622 | + if (isset($ais_data['imo'])) { |
|
623 | + $data['imo'] = $ais_data['imo']; |
|
624 | + } |
|
625 | + if (isset($ais_data['callsign'])) { |
|
626 | + $data['callsign'] = $ais_data['callsign']; |
|
627 | + } |
|
628 | + if (isset($ais_data['destination'])) { |
|
629 | + $data['arrival_code'] = $ais_data['destination']; |
|
630 | + } |
|
631 | + if (isset($ais_data['eta_ts'])) { |
|
632 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
633 | + } |
|
460 | 634 | if (isset($ais_data['timestamp'])) { |
461 | 635 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
462 | 636 | } else { |
@@ -464,7 +638,9 @@ discard block |
||
464 | 638 | } |
465 | 639 | $data['format_source'] = 'aisnmeahttp'; |
466 | 640 | $data['id_source'] = $id_source; |
467 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
641 | + if ($ais_data['mmsi_type'] == 'Ship') { |
|
642 | + $MI->add($data); |
|
643 | + } |
|
468 | 644 | unset($data); |
469 | 645 | } |
470 | 646 | } |
@@ -513,7 +689,9 @@ discard block |
||
513 | 689 | $data['callsign'] = $line['callsign']; |
514 | 690 | $data['mmsi'] = $line['mmsi']; |
515 | 691 | $data['speed'] = $line['sog']; |
516 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
692 | + if ($line['heading'] != '511') { |
|
693 | + $data['heading'] = $line['heading']; |
|
694 | + } |
|
517 | 695 | $data['latitude'] = $line['latitude']; |
518 | 696 | $data['longitude'] = $line['longitude']; |
519 | 697 | $data['type_id'] = $line['shiptype']; |
@@ -533,7 +711,9 @@ discard block |
||
533 | 711 | echo 'download...'; |
534 | 712 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
535 | 713 | echo 'done !'."\n"; |
536 | - if ($buffer != '') $reset = 0; |
|
714 | + if ($buffer != '') { |
|
715 | + $reset = 0; |
|
716 | + } |
|
537 | 717 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
538 | 718 | $buffer = explode('\n',$buffer); |
539 | 719 | foreach ($buffer as $line) { |
@@ -577,16 +757,28 @@ discard block |
||
577 | 757 | $line = explode(':', $line); |
578 | 758 | if (count($line) > 30 && $line[0] != 'callsign') { |
579 | 759 | $data = array(); |
580 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
581 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
760 | + if (isset($line[37]) && $line[37] != '') { |
|
761 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
762 | + } else { |
|
763 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
764 | + } |
|
582 | 765 | $data['pilot_id'] = $line[1]; |
583 | 766 | $data['pilot_name'] = $line[2]; |
584 | 767 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
585 | 768 | $data['ident'] = $line[0]; // ident |
586 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
769 | + if ($line[7] != '' && $line[7] != 0) { |
|
770 | + $data['altitude'] = $line[7]; |
|
771 | + } |
|
772 | + // altitude |
|
587 | 773 | $data['speed'] = $line[8]; // speed |
588 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
589 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
774 | + if (isset($line[45])) { |
|
775 | + $data['heading'] = $line[45]; |
|
776 | + } |
|
777 | + // heading |
|
778 | + elseif (isset($line[38])) { |
|
779 | + $data['heading'] = $line[38]; |
|
780 | + } |
|
781 | + // heading |
|
590 | 782 | $data['latitude'] = $line[5]; // lat |
591 | 783 | $data['longitude'] = $line[6]; // long |
592 | 784 | $data['verticalrate'] = ''; // vertical rate |
@@ -602,7 +794,9 @@ discard block |
||
602 | 794 | $data['frequency'] = $line[4]; |
603 | 795 | $data['type'] = $line[18]; |
604 | 796 | $data['range'] = $line[19]; |
605 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
797 | + if (isset($line[35])) { |
|
798 | + $data['info'] = $line[35]; |
|
799 | + } |
|
606 | 800 | $data['id_source'] = $id_source; |
607 | 801 | //$data['arrival_airport_time'] = ; |
608 | 802 | if ($line[9] != '') { |
@@ -616,24 +810,41 @@ discard block |
||
616 | 810 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
617 | 811 | */ |
618 | 812 | $data['format_source'] = $value['format']; |
619 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
620 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
621 | - elseif ($line[3] == 'ATC') { |
|
813 | + if (isset($value['name']) && $value['name'] != '') { |
|
814 | + $data['source_name'] = $value['name']; |
|
815 | + } |
|
816 | + if ($line[3] == 'PILOT') { |
|
817 | + $SI->add($data); |
|
818 | + } elseif ($line[3] == 'ATC') { |
|
622 | 819 | //print_r($data); |
623 | 820 | $data['info'] = str_replace('^§','<br />',$data['info']); |
624 | 821 | $data['info'] = str_replace('&sect;','',$data['info']); |
625 | 822 | $typec = substr($data['ident'],-3); |
626 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
627 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
628 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
629 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
630 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
631 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
632 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
633 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
634 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
635 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
636 | - if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
823 | + if ($typec == 'APP') { |
|
824 | + $data['type'] = 'Approach'; |
|
825 | + } elseif ($typec == 'TWR') { |
|
826 | + $data['type'] = 'Tower'; |
|
827 | + } elseif ($typec == 'OBS') { |
|
828 | + $data['type'] = 'Observer'; |
|
829 | + } elseif ($typec == 'GND') { |
|
830 | + $data['type'] = 'Ground'; |
|
831 | + } elseif ($typec == 'DEL') { |
|
832 | + $data['type'] = 'Delivery'; |
|
833 | + } elseif ($typec == 'DEP') { |
|
834 | + $data['type'] = 'Departure'; |
|
835 | + } elseif ($typec == 'FSS') { |
|
836 | + $data['type'] = 'Flight Service Station'; |
|
837 | + } elseif ($typec == 'CTR') { |
|
838 | + $data['type'] = 'Control Radar or Centre'; |
|
839 | + } elseif ($data['type'] == '') { |
|
840 | + $data['type'] = 'Observer'; |
|
841 | + } |
|
842 | + if (!isset($data['source_name'])) { |
|
843 | + $data['source_name'] = ''; |
|
844 | + } |
|
845 | + if (isset($ATC)) { |
|
846 | + echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
847 | + } |
|
637 | 848 | } |
638 | 849 | unset($data); |
639 | 850 | } |
@@ -652,26 +863,55 @@ discard block |
||
652 | 863 | foreach ($all_data['acList'] as $line) { |
653 | 864 | $data = array(); |
654 | 865 | $data['hex'] = $line['Icao']; // hex |
655 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
656 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
657 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
658 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
659 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
660 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
866 | + if (isset($line['Call'])) { |
|
867 | + $data['ident'] = $line['Call']; |
|
868 | + } |
|
869 | + // ident |
|
870 | + if (isset($line['Alt'])) { |
|
871 | + $data['altitude'] = $line['Alt']; |
|
872 | + } |
|
873 | + // altitude |
|
874 | + if (isset($line['Spd'])) { |
|
875 | + $data['speed'] = $line['Spd']; |
|
876 | + } |
|
877 | + // speed |
|
878 | + if (isset($line['Trak'])) { |
|
879 | + $data['heading'] = $line['Trak']; |
|
880 | + } |
|
881 | + // heading |
|
882 | + if (isset($line['Lat'])) { |
|
883 | + $data['latitude'] = $line['Lat']; |
|
884 | + } |
|
885 | + // lat |
|
886 | + if (isset($line['Long'])) { |
|
887 | + $data['longitude'] = $line['Long']; |
|
888 | + } |
|
889 | + // long |
|
661 | 890 | //$data['verticalrate'] = $line['']; // verticale rate |
662 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
891 | + if (isset($line['Sqk'])) { |
|
892 | + $data['squawk'] = $line['Sqk']; |
|
893 | + } |
|
894 | + // squawk |
|
663 | 895 | $data['emergency'] = ''; // emergency |
664 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
896 | + if (isset($line['Reg'])) { |
|
897 | + $data['registration'] = $line['Reg']; |
|
898 | + } |
|
665 | 899 | /* |
666 | 900 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
667 | 901 | else $data['datetime'] = date('Y-m-d H:i:s'); |
668 | 902 | */ |
669 | 903 | $data['datetime'] = date('Y-m-d H:i:s'); |
670 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
904 | + if (isset($line['Type'])) { |
|
905 | + $data['aircraft_icao'] = $line['Type']; |
|
906 | + } |
|
671 | 907 | $data['format_source'] = 'aircraftlistjson'; |
672 | 908 | $data['id_source'] = $id_source; |
673 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
674 | - if (isset($data['latitude'])) $SI->add($data); |
|
909 | + if (isset($value['name']) && $value['name'] != '') { |
|
910 | + $data['source_name'] = $value['name']; |
|
911 | + } |
|
912 | + if (isset($data['latitude'])) { |
|
913 | + $SI->add($data); |
|
914 | + } |
|
675 | 915 | unset($data); |
676 | 916 | } |
677 | 917 | } elseif (is_array($all_data)) { |
@@ -691,7 +931,9 @@ discard block |
||
691 | 931 | $data['datetime'] = date('Y-m-d H:i:s'); |
692 | 932 | $data['format_source'] = 'aircraftlistjson'; |
693 | 933 | $data['id_source'] = $id_source; |
694 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
934 | + if (isset($value['name']) && $value['name'] != '') { |
|
935 | + $data['source_name'] = $value['name']; |
|
936 | + } |
|
695 | 937 | $SI->add($data); |
696 | 938 | unset($data); |
697 | 939 | } |
@@ -727,7 +969,9 @@ discard block |
||
727 | 969 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
728 | 970 | $data['format_source'] = 'planeupdatefaa'; |
729 | 971 | $data['id_source'] = $id_source; |
730 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
972 | + if (isset($value['name']) && $value['name'] != '') { |
|
973 | + $data['source_name'] = $value['name']; |
|
974 | + } |
|
731 | 975 | $SI->add($data); |
732 | 976 | unset($data); |
733 | 977 | } |
@@ -767,7 +1011,9 @@ discard block |
||
767 | 1011 | //$buffer = $Common->getData($hosts[$id]); |
768 | 1012 | $buffer = $Common->getData($value['host']); |
769 | 1013 | $all_data = json_decode($buffer,true); |
770 | - if (!empty($all_data)) $reset = 0; |
|
1014 | + if (!empty($all_data)) { |
|
1015 | + $reset = 0; |
|
1016 | + } |
|
771 | 1017 | foreach ($all_data as $key => $line) { |
772 | 1018 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
773 | 1019 | $data = array(); |
@@ -788,7 +1034,9 @@ discard block |
||
788 | 1034 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
789 | 1035 | $data['format_source'] = 'fr24json'; |
790 | 1036 | $data['id_source'] = $id_source; |
791 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1037 | + if (isset($value['name']) && $value['name'] != '') { |
|
1038 | + $data['source_name'] = $value['name']; |
|
1039 | + } |
|
792 | 1040 | $SI->add($data); |
793 | 1041 | unset($data); |
794 | 1042 | } |
@@ -812,23 +1060,39 @@ discard block |
||
812 | 1060 | if (isset($line['inf'])) { |
813 | 1061 | $data = array(); |
814 | 1062 | $data['hex'] = $line['inf']['ia']; |
815 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1063 | + if (isset($line['inf']['cs'])) { |
|
1064 | + $data['ident'] = $line['inf']['cs']; |
|
1065 | + } |
|
1066 | + //$line[13] |
|
816 | 1067 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
817 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
818 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1068 | + if (isset($line['inf']['gs'])) { |
|
1069 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1070 | + } |
|
1071 | + // speed |
|
1072 | + if (isset($line['inf']['tr'])) { |
|
1073 | + $data['heading'] = $line['inf']['tr']; |
|
1074 | + } |
|
1075 | + // heading |
|
819 | 1076 | $data['latitude'] = $line['pt'][0]; // lat |
820 | 1077 | $data['longitude'] = $line['pt'][1]; // long |
821 | 1078 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
822 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1079 | + if (isset($line['inf']['sq'])) { |
|
1080 | + $data['squawk'] = $line['inf']['sq']; |
|
1081 | + } |
|
1082 | + // squawk |
|
823 | 1083 | //$data['aircraft_icao'] = $line[8]; |
824 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1084 | + if (isset($line['inf']['rc'])) { |
|
1085 | + $data['registration'] = $line['inf']['rc']; |
|
1086 | + } |
|
825 | 1087 | //$data['departure_airport_iata'] = $line[11]; |
826 | 1088 | //$data['arrival_airport_iata'] = $line[12]; |
827 | 1089 | //$data['emergency'] = ''; // emergency |
828 | 1090 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
829 | 1091 | $data['format_source'] = 'radarvirtueljson'; |
830 | 1092 | $data['id_source'] = $id_source; |
831 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1093 | + if (isset($value['name']) && $value['name'] != '') { |
|
1094 | + $data['source_name'] = $value['name']; |
|
1095 | + } |
|
832 | 1096 | $SI->add($data); |
833 | 1097 | unset($data); |
834 | 1098 | } |
@@ -849,29 +1113,62 @@ discard block |
||
849 | 1113 | $data['id'] = $line['id']; |
850 | 1114 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
851 | 1115 | $data['ident'] = $line['callsign']; // ident |
852 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
853 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
854 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
855 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
856 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
857 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1116 | + if (isset($line['pilotid'])) { |
|
1117 | + $data['pilot_id'] = $line['pilotid']; |
|
1118 | + } |
|
1119 | + // pilot id |
|
1120 | + if (isset($line['name'])) { |
|
1121 | + $data['pilot_name'] = $line['name']; |
|
1122 | + } |
|
1123 | + // pilot name |
|
1124 | + if (isset($line['alt'])) { |
|
1125 | + $data['altitude'] = $line['alt']; |
|
1126 | + } |
|
1127 | + // altitude |
|
1128 | + if (isset($line['gs'])) { |
|
1129 | + $data['speed'] = $line['gs']; |
|
1130 | + } |
|
1131 | + // speed |
|
1132 | + if (isset($line['heading'])) { |
|
1133 | + $data['heading'] = $line['heading']; |
|
1134 | + } |
|
1135 | + // heading |
|
1136 | + if (isset($line['route'])) { |
|
1137 | + $data['waypoints'] = $line['route']; |
|
1138 | + } |
|
1139 | + // route |
|
858 | 1140 | $data['latitude'] = $line['lat']; // lat |
859 | 1141 | $data['longitude'] = $line['lon']; // long |
860 | 1142 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
861 | 1143 | //$data['squawk'] = $line['squawk']; // squawk |
862 | 1144 | //$data['emergency'] = ''; // emergency |
863 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
864 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
865 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1145 | + if (isset($line['depicao'])) { |
|
1146 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1147 | + } |
|
1148 | + if (isset($line['deptime'])) { |
|
1149 | + $data['departure_airport_time'] = $line['deptime']; |
|
1150 | + } |
|
1151 | + if (isset($line['arricao'])) { |
|
1152 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1153 | + } |
|
866 | 1154 | //$data['arrival_airport_time'] = $line['arrtime']; |
867 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
868 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
869 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
870 | - else $data['info'] = ''; |
|
1155 | + if (isset($line['aircraft'])) { |
|
1156 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1157 | + } |
|
1158 | + if (isset($line['transponder'])) { |
|
1159 | + $data['squawk'] = $line['transponder']; |
|
1160 | + } |
|
1161 | + if (isset($line['atis'])) { |
|
1162 | + $data['info'] = $line['atis']; |
|
1163 | + } else { |
|
1164 | + $data['info'] = ''; |
|
1165 | + } |
|
871 | 1166 | $data['format_source'] = 'pireps'; |
872 | 1167 | $data['id_source'] = $id_source; |
873 | 1168 | $data['datetime'] = date('Y-m-d H:i:s'); |
874 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1169 | + if (isset($value['name']) && $value['name'] != '') { |
|
1170 | + $data['source_name'] = $value['name']; |
|
1171 | + } |
|
875 | 1172 | if ($line['icon'] == 'plane') { |
876 | 1173 | $SI->add($data); |
877 | 1174 | // print_r($data); |
@@ -880,16 +1177,28 @@ discard block |
||
880 | 1177 | $data['info'] = str_replace('&sect;','',$data['info']); |
881 | 1178 | $typec = substr($data['ident'],-3); |
882 | 1179 | $data['type'] = ''; |
883 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
884 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
885 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
886 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
887 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
888 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
889 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
890 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
891 | - else $data['type'] = 'Observer'; |
|
892 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1180 | + if ($typec == 'APP') { |
|
1181 | + $data['type'] = 'Approach'; |
|
1182 | + } elseif ($typec == 'TWR') { |
|
1183 | + $data['type'] = 'Tower'; |
|
1184 | + } elseif ($typec == 'OBS') { |
|
1185 | + $data['type'] = 'Observer'; |
|
1186 | + } elseif ($typec == 'GND') { |
|
1187 | + $data['type'] = 'Ground'; |
|
1188 | + } elseif ($typec == 'DEL') { |
|
1189 | + $data['type'] = 'Delivery'; |
|
1190 | + } elseif ($typec == 'DEP') { |
|
1191 | + $data['type'] = 'Departure'; |
|
1192 | + } elseif ($typec == 'FSS') { |
|
1193 | + $data['type'] = 'Flight Service Station'; |
|
1194 | + } elseif ($typec == 'CTR') { |
|
1195 | + $data['type'] = 'Control Radar or Centre'; |
|
1196 | + } else { |
|
1197 | + $data['type'] = 'Observer'; |
|
1198 | + } |
|
1199 | + if (isset($ATC)) { |
|
1200 | + echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1201 | + } |
|
893 | 1202 | } |
894 | 1203 | unset($data); |
895 | 1204 | } |
@@ -899,7 +1208,9 @@ discard block |
||
899 | 1208 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
900 | 1209 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
901 | 1210 | //$buffer = $Common->getData($hosts[$id]); |
902 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1211 | + if ($globalDebug) { |
|
1212 | + echo 'Get Data...'."\n"; |
|
1213 | + } |
|
903 | 1214 | $buffer = $Common->getData($value['host']); |
904 | 1215 | $all_data = json_decode($buffer,true); |
905 | 1216 | if ($buffer != '' && is_array($all_data)) { |
@@ -907,10 +1218,16 @@ discard block |
||
907 | 1218 | foreach ($all_data as $line) { |
908 | 1219 | $data = array(); |
909 | 1220 | //$data['id'] = $line['id']; // id not usable |
910 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1221 | + if (isset($line['pilotid'])) { |
|
1222 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1223 | + } |
|
911 | 1224 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
912 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
913 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1225 | + if (isset($line['pilotname'])) { |
|
1226 | + $data['pilot_name'] = $line['pilotname']; |
|
1227 | + } |
|
1228 | + if (isset($line['pilotid'])) { |
|
1229 | + $data['pilot_id'] = $line['pilotid']; |
|
1230 | + } |
|
914 | 1231 | $data['ident'] = $line['flightnum']; // ident |
915 | 1232 | $data['altitude'] = $line['alt']; // altitude |
916 | 1233 | $data['speed'] = $line['gs']; // speed |
@@ -928,27 +1245,41 @@ discard block |
||
928 | 1245 | $data['arrival_airport_icao'] = $line['arricao']; |
929 | 1246 | $data['arrival_airport_time'] = $line['arrtime']; |
930 | 1247 | $data['registration'] = $line['aircraft']; |
931 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1248 | + if (isset($line['route'])) { |
|
1249 | + $data['waypoints'] = $line['route']; |
|
1250 | + } |
|
1251 | + // route |
|
932 | 1252 | if (isset($line['aircraftname'])) { |
933 | 1253 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
934 | 1254 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
935 | 1255 | $aircraft_data = explode('-',$line['aircraftname']); |
936 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
937 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
938 | - else { |
|
1256 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1257 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1258 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1259 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1260 | + } else { |
|
939 | 1261 | $aircraft_data = explode(' ',$line['aircraftname']); |
940 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
941 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1262 | + if (isset($aircraft_data[1])) { |
|
1263 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1264 | + } else { |
|
1265 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1266 | + } |
|
942 | 1267 | } |
943 | 1268 | } |
944 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1269 | + if (isset($line['route'])) { |
|
1270 | + $data['waypoints'] = $line['route']; |
|
1271 | + } |
|
945 | 1272 | $data['id_source'] = $id_source; |
946 | 1273 | $data['format_source'] = 'phpvmacars'; |
947 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1274 | + if (isset($value['name']) && $value['name'] != '') { |
|
1275 | + $data['source_name'] = $value['name']; |
|
1276 | + } |
|
948 | 1277 | $SI->add($data); |
949 | 1278 | unset($data); |
950 | 1279 | } |
951 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1280 | + if ($globalDebug) { |
|
1281 | + echo 'No more data...'."\n"; |
|
1282 | + } |
|
952 | 1283 | unset($buffer); |
953 | 1284 | unset($all_data); |
954 | 1285 | } |
@@ -956,7 +1287,9 @@ discard block |
||
956 | 1287 | $last_exec[$id]['last'] = time(); |
957 | 1288 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
958 | 1289 | //$buffer = $Common->getData($hosts[$id]); |
959 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1290 | + if ($globalDebug) { |
|
1291 | + echo 'Get Data...'."\n"; |
|
1292 | + } |
|
960 | 1293 | $buffer = $Common->getData($value['host']); |
961 | 1294 | $all_data = json_decode($buffer,true); |
962 | 1295 | if ($buffer != '' && is_array($all_data)) { |
@@ -985,15 +1318,22 @@ discard block |
||
985 | 1318 | $data['arrival_airport_icao'] = $line['arrival']; |
986 | 1319 | //$data['arrival_airport_time'] = $line['arrival_time']; |
987 | 1320 | //$data['registration'] = $line['aircraft']; |
988 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1321 | + if (isset($line['route'])) { |
|
1322 | + $data['waypoints'] = $line['route']; |
|
1323 | + } |
|
1324 | + // route |
|
989 | 1325 | $data['aircraft_icao'] = $line['plane_type']; |
990 | 1326 | $data['id_source'] = $id_source; |
991 | 1327 | $data['format_source'] = 'vam'; |
992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1328 | + if (isset($value['name']) && $value['name'] != '') { |
|
1329 | + $data['source_name'] = $value['name']; |
|
1330 | + } |
|
993 | 1331 | $SI->add($data); |
994 | 1332 | unset($data); |
995 | 1333 | } |
996 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1334 | + if ($globalDebug) { |
|
1335 | + echo 'No more data...'."\n"; |
|
1336 | + } |
|
997 | 1337 | unset($buffer); |
998 | 1338 | unset($all_data); |
999 | 1339 | } |
@@ -1001,7 +1341,9 @@ discard block |
||
1001 | 1341 | $last_exec[$id]['last'] = time(); |
1002 | 1342 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1003 | 1343 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1004 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1344 | + if (function_exists('pcntl_fork')) { |
|
1345 | + pcntl_signal_dispatch(); |
|
1346 | + } |
|
1005 | 1347 | //$last_exec[$id]['last'] = time(); |
1006 | 1348 | |
1007 | 1349 | //$read = array( $sockets[$id] ); |
@@ -1009,7 +1351,9 @@ discard block |
||
1009 | 1351 | $write = NULL; |
1010 | 1352 | $e = NULL; |
1011 | 1353 | $n = socket_select($read, $write, $e, $timeout); |
1012 | - if ($e != NULL) var_dump($e); |
|
1354 | + if ($e != NULL) { |
|
1355 | + var_dump($e); |
|
1356 | + } |
|
1013 | 1357 | if ($n > 0) { |
1014 | 1358 | $reset = 0; |
1015 | 1359 | foreach ($read as $nb => $r) { |
@@ -1030,12 +1374,16 @@ discard block |
||
1030 | 1374 | //$SI::del(); |
1031 | 1375 | if ($format == 'vrstcp') { |
1032 | 1376 | $buffer = explode('},{',$buffer); |
1033 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1377 | + } else { |
|
1378 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1379 | + } |
|
1034 | 1380 | // SBS format is CSV format |
1035 | 1381 | if ($buffer !== FALSE && $buffer != '') { |
1036 | 1382 | $tt[$format] = 0; |
1037 | 1383 | if ($format == 'acarssbs3') { |
1038 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1384 | + if ($globalDebug) { |
|
1385 | + echo 'ACARS : '.$buffer."\n"; |
|
1386 | + } |
|
1039 | 1387 | $ACARS->add(trim($buffer)); |
1040 | 1388 | $ACARS->deleteLiveAcarsData(); |
1041 | 1389 | } elseif ($format == 'raw') { |
@@ -1044,25 +1392,55 @@ discard block |
||
1044 | 1392 | if (is_array($data)) { |
1045 | 1393 | $data['datetime'] = date('Y-m-d H:i:s'); |
1046 | 1394 | $data['format_source'] = 'raw'; |
1047 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1048 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1049 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1395 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1396 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1397 | + } |
|
1398 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1399 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1400 | + } |
|
1401 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1402 | + $SI->add($data); |
|
1403 | + } |
|
1050 | 1404 | } |
1051 | 1405 | } elseif ($format == 'ais') { |
1052 | 1406 | $ais_data = $AIS->parse_line(trim($buffer)); |
1053 | 1407 | $data = array(); |
1054 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1055 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1056 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1057 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1058 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1059 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1060 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1061 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1062 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1063 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1064 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1065 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1408 | + if (isset($ais_data['ident'])) { |
|
1409 | + $data['ident'] = $ais_data['ident']; |
|
1410 | + } |
|
1411 | + if (isset($ais_data['mmsi'])) { |
|
1412 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1413 | + } |
|
1414 | + if (isset($ais_data['speed'])) { |
|
1415 | + $data['speed'] = $ais_data['speed']; |
|
1416 | + } |
|
1417 | + if (isset($ais_data['heading'])) { |
|
1418 | + $data['heading'] = $ais_data['heading']; |
|
1419 | + } |
|
1420 | + if (isset($ais_data['latitude'])) { |
|
1421 | + $data['latitude'] = $ais_data['latitude']; |
|
1422 | + } |
|
1423 | + if (isset($ais_data['longitude'])) { |
|
1424 | + $data['longitude'] = $ais_data['longitude']; |
|
1425 | + } |
|
1426 | + if (isset($ais_data['status'])) { |
|
1427 | + $data['status'] = $ais_data['status']; |
|
1428 | + } |
|
1429 | + if (isset($ais_data['type'])) { |
|
1430 | + $data['type'] = $ais_data['type']; |
|
1431 | + } |
|
1432 | + if (isset($ais_data['imo'])) { |
|
1433 | + $data['imo'] = $ais_data['imo']; |
|
1434 | + } |
|
1435 | + if (isset($ais_data['callsign'])) { |
|
1436 | + $data['callsign'] = $ais_data['callsign']; |
|
1437 | + } |
|
1438 | + if (isset($ais_data['destination'])) { |
|
1439 | + $data['arrival_code'] = $ais_data['destination']; |
|
1440 | + } |
|
1441 | + if (isset($ais_data['eta_ts'])) { |
|
1442 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1443 | + } |
|
1066 | 1444 | |
1067 | 1445 | if (isset($ais_data['timestamp'])) { |
1068 | 1446 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1071,7 +1449,9 @@ discard block |
||
1071 | 1449 | } |
1072 | 1450 | $data['format_source'] = 'aisnmea'; |
1073 | 1451 | $data['id_source'] = $id_source; |
1074 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1452 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1453 | + $MI->add($data); |
|
1454 | + } |
|
1075 | 1455 | unset($data); |
1076 | 1456 | } elseif ($format == 'flightgearsp') { |
1077 | 1457 | //echo $buffer."\n"; |
@@ -1089,11 +1469,15 @@ discard block |
||
1089 | 1469 | $data['speed'] = round($line[5]*1.94384); |
1090 | 1470 | $data['datetime'] = date('Y-m-d H:i:s'); |
1091 | 1471 | $data['format_source'] = 'flightgearsp'; |
1092 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1472 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1473 | + $SI->add($data); |
|
1474 | + } |
|
1093 | 1475 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1094 | 1476 | } |
1095 | 1477 | } elseif ($format == 'acars') { |
1096 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1478 | + if ($globalDebug) { |
|
1479 | + echo 'ACARS : '.$buffer."\n"; |
|
1480 | + } |
|
1097 | 1481 | $ACARS->add(trim($buffer)); |
1098 | 1482 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1099 | 1483 | $ACARS->deleteLiveAcarsData(); |
@@ -1114,7 +1498,9 @@ discard block |
||
1114 | 1498 | $aircraft_type = $line[10]; |
1115 | 1499 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1116 | 1500 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1117 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1501 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1502 | + $SI->add($data); |
|
1503 | + } |
|
1118 | 1504 | } |
1119 | 1505 | } |
1120 | 1506 | } elseif ($format == 'beast') { |
@@ -1124,27 +1510,59 @@ discard block |
||
1124 | 1510 | foreach($buffer as $all_data) { |
1125 | 1511 | $line = json_decode('{'.$all_data.'}',true); |
1126 | 1512 | $data = array(); |
1127 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1128 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1129 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1130 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1131 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1132 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1133 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1513 | + if (isset($line['Icao'])) { |
|
1514 | + $data['hex'] = $line['Icao']; |
|
1515 | + } |
|
1516 | + // hex |
|
1517 | + if (isset($line['Call'])) { |
|
1518 | + $data['ident'] = $line['Call']; |
|
1519 | + } |
|
1520 | + // ident |
|
1521 | + if (isset($line['Alt'])) { |
|
1522 | + $data['altitude'] = $line['Alt']; |
|
1523 | + } |
|
1524 | + // altitude |
|
1525 | + if (isset($line['Spd'])) { |
|
1526 | + $data['speed'] = $line['Spd']; |
|
1527 | + } |
|
1528 | + // speed |
|
1529 | + if (isset($line['Trak'])) { |
|
1530 | + $data['heading'] = $line['Trak']; |
|
1531 | + } |
|
1532 | + // heading |
|
1533 | + if (isset($line['Lat'])) { |
|
1534 | + $data['latitude'] = $line['Lat']; |
|
1535 | + } |
|
1536 | + // lat |
|
1537 | + if (isset($line['Long'])) { |
|
1538 | + $data['longitude'] = $line['Long']; |
|
1539 | + } |
|
1540 | + // long |
|
1134 | 1541 | //$data['verticalrate'] = $line['']; // verticale rate |
1135 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1542 | + if (isset($line['Sqk'])) { |
|
1543 | + $data['squawk'] = $line['Sqk']; |
|
1544 | + } |
|
1545 | + // squawk |
|
1136 | 1546 | $data['emergency'] = ''; // emergency |
1137 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1547 | + if (isset($line['Reg'])) { |
|
1548 | + $data['registration'] = $line['Reg']; |
|
1549 | + } |
|
1138 | 1550 | /* |
1139 | 1551 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1140 | 1552 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1141 | 1553 | */ |
1142 | 1554 | $data['datetime'] = date('Y-m-d H:i:s'); |
1143 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1555 | + if (isset($line['Type'])) { |
|
1556 | + $data['aircraft_icao'] = $line['Type']; |
|
1557 | + } |
|
1144 | 1558 | $data['format_source'] = 'vrstcp'; |
1145 | 1559 | $data['id_source'] = $id_source; |
1146 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1147 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1560 | + if (isset($value['name']) && $value['name'] != '') { |
|
1561 | + $data['source_name'] = $value['name']; |
|
1562 | + } |
|
1563 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
1564 | + $SI->add($data); |
|
1565 | + } |
|
1148 | 1566 | unset($data); |
1149 | 1567 | } |
1150 | 1568 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1157,21 +1575,43 @@ discard block |
||
1157 | 1575 | $data['hex'] = $lined['hexid']; |
1158 | 1576 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1159 | 1577 | $data['datetime'] = date('Y-m-d H:i:s');; |
1160 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1161 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1162 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1163 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1164 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1165 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1166 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1578 | + if (isset($lined['ident'])) { |
|
1579 | + $data['ident'] = $lined['ident']; |
|
1580 | + } |
|
1581 | + if (isset($lined['lat'])) { |
|
1582 | + $data['latitude'] = $lined['lat']; |
|
1583 | + } |
|
1584 | + if (isset($lined['lon'])) { |
|
1585 | + $data['longitude'] = $lined['lon']; |
|
1586 | + } |
|
1587 | + if (isset($lined['speed'])) { |
|
1588 | + $data['speed'] = $lined['speed']; |
|
1589 | + } |
|
1590 | + if (isset($lined['squawk'])) { |
|
1591 | + $data['squawk'] = $lined['squawk']; |
|
1592 | + } |
|
1593 | + if (isset($lined['alt'])) { |
|
1594 | + $data['altitude'] = $lined['alt']; |
|
1595 | + } |
|
1596 | + if (isset($lined['heading'])) { |
|
1597 | + $data['heading'] = $lined['heading']; |
|
1598 | + } |
|
1167 | 1599 | $data['id_source'] = $id_source; |
1168 | 1600 | $data['format_source'] = 'tsv'; |
1169 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1170 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1171 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1601 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1602 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1603 | + } |
|
1604 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1605 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1606 | + } |
|
1607 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1608 | + $SI->add($data); |
|
1609 | + } |
|
1172 | 1610 | unset($lined); |
1173 | 1611 | unset($data); |
1174 | - } else $error = true; |
|
1612 | + } else { |
|
1613 | + $error = true; |
|
1614 | + } |
|
1175 | 1615 | } elseif ($format == 'aprs' && $use_aprs) { |
1176 | 1616 | if ($aprs_connect == 0) { |
1177 | 1617 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1197,49 +1637,82 @@ discard block |
||
1197 | 1637 | $aprs_last_tx = time(); |
1198 | 1638 | $data = array(); |
1199 | 1639 | //print_r($line); |
1200 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1201 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1202 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1640 | + if (isset($line['address'])) { |
|
1641 | + $data['hex'] = $line['address']; |
|
1642 | + } |
|
1643 | + if (isset($line['timestamp'])) { |
|
1644 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1645 | + } else { |
|
1646 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1647 | + } |
|
1203 | 1648 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1204 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1649 | + if (isset($line['ident'])) { |
|
1650 | + $data['ident'] = $line['ident']; |
|
1651 | + } |
|
1205 | 1652 | $data['latitude'] = $line['latitude']; |
1206 | 1653 | $data['longitude'] = $line['longitude']; |
1207 | 1654 | //$data['verticalrate'] = $line[16]; |
1208 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1209 | - else $data['speed'] = 0; |
|
1210 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1211 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1212 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1213 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1655 | + if (isset($line['speed'])) { |
|
1656 | + $data['speed'] = $line['speed']; |
|
1657 | + } else { |
|
1658 | + $data['speed'] = 0; |
|
1659 | + } |
|
1660 | + if (isset($line['altitude'])) { |
|
1661 | + $data['altitude'] = $line['altitude']; |
|
1662 | + } |
|
1663 | + if (isset($line['comment'])) { |
|
1664 | + $data['comment'] = $line['comment']; |
|
1665 | + } |
|
1666 | + if (isset($line['symbol'])) { |
|
1667 | + $data['type'] = $line['symbol']; |
|
1668 | + } |
|
1669 | + if (isset($line['heading'])) { |
|
1670 | + $data['heading'] = $line['heading']; |
|
1671 | + } |
|
1214 | 1672 | //else $data['heading'] = 0; |
1215 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1216 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1673 | + if (isset($line['stealth'])) { |
|
1674 | + $data['aircraft_type'] = $line['stealth']; |
|
1675 | + } |
|
1676 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
1677 | + $data['noarchive'] = true; |
|
1678 | + } |
|
1217 | 1679 | $data['id_source'] = $id_source; |
1218 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1219 | - else $data['format_source'] = 'aprs'; |
|
1680 | + if (isset($line['format_source'])) { |
|
1681 | + $data['format_source'] = $line['format_source']; |
|
1682 | + } else { |
|
1683 | + $data['format_source'] = 'aprs'; |
|
1684 | + } |
|
1220 | 1685 | $data['source_name'] = $line['source']; |
1221 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1222 | - else $data['source_type'] = 'flarm'; |
|
1223 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1686 | + if (isset($line['source_type'])) { |
|
1687 | + $data['source_type'] = $line['source_type']; |
|
1688 | + } else { |
|
1689 | + $data['source_type'] = 'flarm'; |
|
1690 | + } |
|
1691 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1692 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1693 | + } |
|
1224 | 1694 | $currentdate = date('Y-m-d H:i:s'); |
1225 | 1695 | $aprsdate = strtotime($data['datetime']); |
1226 | 1696 | // Accept data if time <= system time + 20s |
1227 | 1697 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1228 | 1698 | $send = $SI->add($data); |
1229 | 1699 | } elseif (isset($line['stealth'])) { |
1230 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1231 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1700 | + if ($line['stealth'] != 0) { |
|
1701 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1702 | + } else { |
|
1703 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1704 | + } |
|
1232 | 1705 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1233 | 1706 | } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1234 | 1707 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1235 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
1708 | + if (isset($globalTracker) && $globalTracker) { |
|
1709 | + $send = $TI->add($data); |
|
1710 | + } |
|
1236 | 1711 | } |
1237 | 1712 | unset($data); |
1238 | - } |
|
1239 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1713 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1240 | 1714 | echo '!! Weather Station not yet supported'."\n"; |
1241 | - } |
|
1242 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1715 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1243 | 1716 | echo '!! Car & Trucks not yet supported'."\n"; |
1244 | 1717 | } |
1245 | 1718 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1272,25 +1745,42 @@ discard block |
||
1272 | 1745 | $data['ground'] = $line[21]; |
1273 | 1746 | $data['emergency'] = $line[19]; |
1274 | 1747 | $data['format_source'] = 'sbs'; |
1275 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1276 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1748 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1749 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1750 | + } |
|
1751 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1752 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1753 | + } |
|
1277 | 1754 | $data['id_source'] = $id_source; |
1278 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1279 | - else $error = true; |
|
1755 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1756 | + $send = $SI->add($data); |
|
1757 | + } else { |
|
1758 | + $error = true; |
|
1759 | + } |
|
1280 | 1760 | unset($data); |
1281 | - } else $error = true; |
|
1761 | + } else { |
|
1762 | + $error = true; |
|
1763 | + } |
|
1282 | 1764 | if ($error) { |
1283 | 1765 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1284 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
1766 | + if ($globalDebug) { |
|
1767 | + echo "Not a message. Ignoring... \n"; |
|
1768 | + } |
|
1285 | 1769 | } else { |
1286 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
1770 | + if ($globalDebug) { |
|
1771 | + echo "Wrong line format. Ignoring... \n"; |
|
1772 | + } |
|
1287 | 1773 | if ($globalDebug) { |
1288 | 1774 | echo $buffer; |
1289 | 1775 | print_r($line); |
1290 | 1776 | } |
1291 | 1777 | //socket_close($r); |
1292 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1293 | - if ($format == 'aprs') $aprs_connect = 0; |
|
1778 | + if ($globalDebug) { |
|
1779 | + echo "Reconnect after an error...\n"; |
|
1780 | + } |
|
1781 | + if ($format == 'aprs') { |
|
1782 | + $aprs_connect = 0; |
|
1783 | + } |
|
1294 | 1784 | $sourceer[$nb] = $globalSources[$nb]; |
1295 | 1785 | connect_all($sourceer); |
1296 | 1786 | $sourceer = array(); |
@@ -1298,10 +1788,14 @@ discard block |
||
1298 | 1788 | } |
1299 | 1789 | } |
1300 | 1790 | // Sleep for xxx microseconds |
1301 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
1791 | + if (isset($globalSBSSleep)) { |
|
1792 | + usleep($globalSBSSleep); |
|
1793 | + } |
|
1302 | 1794 | } else { |
1303 | 1795 | if ($format == 'flightgearmp') { |
1304 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1796 | + if ($globalDebug) { |
|
1797 | + echo "Reconnect FlightGear MP..."; |
|
1798 | + } |
|
1305 | 1799 | //@socket_close($r); |
1306 | 1800 | sleep($globalMinFetch); |
1307 | 1801 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1310,10 +1804,15 @@ discard block |
||
1310 | 1804 | break; |
1311 | 1805 | |
1312 | 1806 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1313 | - if (isset($tt[$format])) $tt[$format]++; |
|
1314 | - else $tt[$format] = 0; |
|
1807 | + if (isset($tt[$format])) { |
|
1808 | + $tt[$format]++; |
|
1809 | + } else { |
|
1810 | + $tt[$format] = 0; |
|
1811 | + } |
|
1315 | 1812 | if ($tt[$format] > 30) { |
1316 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
1813 | + if ($globalDebug) { |
|
1814 | + echo "ERROR : Reconnect ".$format."..."; |
|
1815 | + } |
|
1317 | 1816 | //@socket_close($r); |
1318 | 1817 | sleep(2); |
1319 | 1818 | $aprs_connect = 0; |
@@ -1330,11 +1829,17 @@ discard block |
||
1330 | 1829 | } else { |
1331 | 1830 | $error = socket_strerror(socket_last_error()); |
1332 | 1831 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1333 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1334 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
1832 | + if ($globalDebug) { |
|
1833 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1834 | + } |
|
1835 | + if (isset($globalDebug)) { |
|
1836 | + echo "Restarting...\n"; |
|
1837 | + } |
|
1335 | 1838 | // Restart the script if possible |
1336 | 1839 | if (is_array($sockets)) { |
1337 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1840 | + if ($globalDebug) { |
|
1841 | + echo "Shutdown all sockets..."; |
|
1842 | + } |
|
1338 | 1843 | |
1339 | 1844 | foreach ($sockets as $sock) { |
1340 | 1845 | @socket_shutdown($sock,2); |
@@ -1342,18 +1847,24 @@ discard block |
||
1342 | 1847 | } |
1343 | 1848 | |
1344 | 1849 | } |
1345 | - if ($globalDebug) echo "Restart all connections..."; |
|
1850 | + if ($globalDebug) { |
|
1851 | + echo "Restart all connections..."; |
|
1852 | + } |
|
1346 | 1853 | sleep(2); |
1347 | 1854 | $time = time(); |
1348 | 1855 | //connect_all($hosts); |
1349 | 1856 | $aprs_connect = 0; |
1350 | - if ($reset > 40) exit('Too many attempts...'); |
|
1857 | + if ($reset > 40) { |
|
1858 | + exit('Too many attempts...'); |
|
1859 | + } |
|
1351 | 1860 | connect_all($globalSources); |
1352 | 1861 | } |
1353 | 1862 | } |
1354 | 1863 | } |
1355 | 1864 | if ($globalDaemon === false) { |
1356 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1865 | + if ($globalDebug) { |
|
1866 | + echo 'Check all...'."\n"; |
|
1867 | + } |
|
1357 | 1868 | $SI->checkAll(); |
1358 | 1869 | } |
1359 | 1870 | } |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | </span> |
4 | 4 | <div class="sub-menu sub-menu-container"> |
5 | 5 | <ul class="nav nav-pills"> |
6 | - <li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
6 | + <li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
7 | 7 | <li class="dropdown"> |
8 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
8 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
9 | 9 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
10 | 10 | </a> |
11 | 11 | <ul class="dropdown-menu" role="menu"> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | </ul> |
15 | 15 | </li> |
16 | 16 | <li class="dropdown"> |
17 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
17 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
18 | 18 | <?php echo _("Airline"); ?> <span class="caret"></span> |
19 | 19 | </a> |
20 | 20 | <ul class="dropdown-menu" role="menu"> |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | </ul> |
24 | 24 | </li> |
25 | 25 | <li class="dropdown"> |
26 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
26 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
27 | 27 | <?php echo _("Airport"); ?> <span class="caret"></span> |
28 | 28 | </a> |
29 | 29 | <ul class="dropdown-menu" role="menu"> |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/arrival-airport-country/<?php print $manufacturer; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
34 | 34 | </ul> |
35 | 35 | </li> |
36 | - <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
37 | - <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
36 | + <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
37 | + <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
38 | 38 | </ul> |
39 | 39 | </div> |
40 | 40 | \ No newline at end of file |