@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | //waypoint plotting |
93 | - /* |
|
93 | + /* |
|
94 | 94 | $output .= '{'; |
95 | 95 | $output .= '"type": "Feature",'; |
96 | 96 | $output .= '"properties": {'; |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | $output_time .= (strtotime($spotter_history['date'])*1000).','; |
270 | 270 | } |
271 | 271 | if (isset($output_time)) { |
272 | - $output_time = substr($output_time, 0, -1); |
|
273 | - $output .= '"time": ['.$output_time.'],'; |
|
272 | + $output_time = substr($output_time, 0, -1); |
|
273 | + $output .= '"time": ['.$output_time.'],'; |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | $output .= '"coordinates": ['; |
285 | 285 | |
286 | 286 | if (isset($output_history)) { |
287 | - $output_history = substr($output_history, 0, -1); |
|
288 | - $output .= $output_history; |
|
287 | + $output_history = substr($output_history, 0, -1); |
|
288 | + $output .= $output_history; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | $output .= ']'; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | ?> |
250 | 250 | <div class="more"> |
251 | 251 | <?php |
252 | - /* |
|
252 | + /* |
|
253 | 253 | if ($year != '' && $month != '') { |
254 | 254 | ?> |
255 | 255 | <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | <?php |
261 | 261 | } |
262 | 262 | */ |
263 | - ?> |
|
263 | + ?> |
|
264 | 264 | </div> |
265 | 265 | </div> |
266 | 266 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | ?> |
295 | 295 | <div class="more"> |
296 | 296 | <?php |
297 | - /* |
|
297 | + /* |
|
298 | 298 | if ($year != '' && $month != '') { |
299 | 299 | ?> |
300 | 300 | <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | <?php |
306 | 306 | } |
307 | 307 | */ |
308 | - ?> |
|
308 | + ?> |
|
309 | 309 | </div> |
310 | 310 | </div> |
311 | 311 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | public $latest_schema = 46; |
8 | 8 | |
9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | - global $globalNoDB; |
|
11 | - if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
10 | + global $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() { |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | - * Creates the database connection |
|
60 | - * |
|
61 | - * @return Boolean of the database connection |
|
62 | - * |
|
63 | - */ |
|
59 | + * Creates the database connection |
|
60 | + * |
|
61 | + * @return Boolean of the database connection |
|
62 | + * |
|
63 | + */ |
|
64 | 64 | |
65 | 65 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
66 | 66 | { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | if($results->rowCount()>0) { |
161 | - return true; |
|
161 | + return true; |
|
162 | 162 | } |
163 | 163 | else return false; |
164 | 164 | } |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | $sum = $sum->fetchColumn(0); |
177 | 177 | } else $sum = 0; |
178 | 178 | if (intval($sum) !== 2) { |
179 | - return false; |
|
179 | + return false; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | } catch(PDOException $e) { |
183 | 183 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
184 | - throw $e; |
|
185 | - } |
|
186 | - //echo 'error ! '.$e->getMessage(); |
|
184 | + throw $e; |
|
185 | + } |
|
186 | + //echo 'error ! '.$e->getMessage(); |
|
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | return true; |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | $version = 0; |
288 | 288 | if ($this->tableExists('aircraft')) { |
289 | 289 | if (!$this->tableExists('config')) { |
290 | - $version = '1'; |
|
291 | - return $version; |
|
290 | + $version = '1'; |
|
291 | + return $version; |
|
292 | 292 | } else { |
293 | 293 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
294 | 294 | try { |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | * @return Boolean if latest version or not |
310 | 310 | */ |
311 | 311 | public function latest() { |
312 | - global $globalNoDB; |
|
313 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
314 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
315 | - else return false; |
|
312 | + global $globalNoDB; |
|
313 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
314 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
315 | + else return false; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | } |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * Gets all launch site |
|
128 | - * |
|
129 | - * @return Array the launch site list |
|
130 | - * |
|
131 | - */ |
|
127 | + * Gets all launch site |
|
128 | + * |
|
129 | + * @return Array the launch site list |
|
130 | + * |
|
131 | + */ |
|
132 | 132 | public function countAllLaunchSite($limit = true, $filters = array()) |
133 | 133 | { |
134 | 134 | global $globalDBdriver; |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | - * Gets all owners |
|
157 | - * |
|
158 | - * @return Array the owners list |
|
159 | - * |
|
160 | - */ |
|
156 | + * Gets all owners |
|
157 | + * |
|
158 | + * @return Array the owners list |
|
159 | + * |
|
160 | + */ |
|
161 | 161 | public function countAllOwners($limit = true, $filters = array()) |
162 | 162 | { |
163 | 163 | global $globalDBdriver; |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * Gets all countries owners |
|
186 | - * |
|
187 | - * @return Array the countries list |
|
188 | - * |
|
189 | - */ |
|
185 | + * Gets all countries owners |
|
186 | + * |
|
187 | + * @return Array the countries list |
|
188 | + * |
|
189 | + */ |
|
190 | 190 | public function countAllCountriesOwners($limit = true, $filters = array()) |
191 | 191 | { |
192 | 192 | global $globalDBdriver; |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | - * Counts all launch dates during the last year |
|
215 | - * |
|
216 | - * @return Array the launch date list |
|
217 | - * |
|
218 | - */ |
|
214 | + * Counts all launch dates during the last year |
|
215 | + * |
|
216 | + * @return Array the launch date list |
|
217 | + * |
|
218 | + */ |
|
219 | 219 | public function countAllMonthsLastYear($filters = array(), $sincedate = '') |
220 | 220 | { |
221 | 221 | global $globalTimezone, $globalDBdriver; |
@@ -256,11 +256,11 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | - * Counts all dates during the last 10 years |
|
260 | - * |
|
261 | - * @return Array the date list |
|
262 | - * |
|
263 | - */ |
|
259 | + * Counts all dates during the last 10 years |
|
260 | + * |
|
261 | + * @return Array the date list |
|
262 | + * |
|
263 | + */ |
|
264 | 264 | public function countAllYears($filters = array(), $sincedate = '') |
265 | 265 | { |
266 | 266 | global $globalTimezone, $globalDBdriver; |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->connectionExists() === false) { |
28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | - exit(); |
|
28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if ($Connection->latest() === false) { |
32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | - exit(); |
|
32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | if (PHP_SAPI != 'cli') { |
36 | - echo "This script MUST be called from console, not a web browser."; |
|
36 | + echo "This script MUST be called from console, not a web browser."; |
|
37 | 37 | // exit(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | // This is to be compatible with old version of settings.php |
41 | 41 | if (!isset($globalSources)) { |
42 | - if (isset($globalSBS1Hosts)) { |
|
43 | - //$hosts = $globalSBS1Hosts; |
|
44 | - foreach ($globalSBS1Hosts as $host) { |
|
45 | - $globalSources[] = array('host' => $host); |
|
46 | - } |
|
47 | - } else { |
|
48 | - if (!isset($globalSBS1Host)) { |
|
49 | - echo '$globalSources MUST be defined !'; |
|
50 | - die; |
|
42 | + if (isset($globalSBS1Hosts)) { |
|
43 | + //$hosts = $globalSBS1Hosts; |
|
44 | + foreach ($globalSBS1Hosts as $host) { |
|
45 | + $globalSources[] = array('host' => $host); |
|
46 | + } |
|
47 | + } else { |
|
48 | + if (!isset($globalSBS1Host)) { |
|
49 | + echo '$globalSources MUST be defined !'; |
|
50 | + die; |
|
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['s']); |
|
64 | 64 | } elseif (isset($options['source'])) { |
65 | - $globalSources = array(); |
|
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
65 | + $globalSources = array(); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | + else $globalSources[] = array('host' => $options['source']); |
|
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
70 | 70 | $globalServerAPRS = TRUE; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
80 | 80 | else $id_source = 1; |
81 | 81 | if (isset($globalServer) && $globalServer) { |
82 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
83 | - $SI=new SpotterServer(); |
|
82 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
83 | + $SI=new SpotterServer(); |
|
84 | 84 | /* |
85 | 85 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
86 | 86 | $SI = new adsb2aprs(); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | } else $SI=new SpotterImport($Connection->db); |
90 | 90 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
91 | 91 | if (isset($globalMarine) && $globalMarine) { |
92 | - $AIS = new AIS(); |
|
93 | - $MI = new MarineImport($Connection->db); |
|
92 | + $AIS = new AIS(); |
|
93 | + $MI = new MarineImport($Connection->db); |
|
94 | 94 | } |
95 | 95 | //$APRS=new APRS($Connection->db); |
96 | 96 | $SBS=new SBS(); |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | //$servertz = system('date +%Z'); |
102 | 102 | // signal handler - playing nice with sockets and dump1090 |
103 | 103 | if (function_exists('pcntl_fork')) { |
104 | - pcntl_signal(SIGINT, function() { |
|
105 | - global $sockets; |
|
106 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
107 | - die("Bye!\n"); |
|
108 | - }); |
|
109 | - pcntl_signal_dispatch(); |
|
104 | + pcntl_signal(SIGINT, function() { |
|
105 | + global $sockets; |
|
106 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
107 | + die("Bye!\n"); |
|
108 | + }); |
|
109 | + pcntl_signal_dispatch(); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // let's try and connect |
@@ -116,36 +116,36 @@ discard block |
||
116 | 116 | $reset = 0; |
117 | 117 | |
118 | 118 | function connect_all($hosts) { |
119 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
120 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
121 | - $reset++; |
|
122 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
123 | - foreach ($hosts as $id => $value) { |
|
119 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
120 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
121 | + $reset++; |
|
122 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
123 | + foreach ($hosts as $id => $value) { |
|
124 | 124 | $host = $value['host']; |
125 | 125 | $globalSources[$id]['last_exec'] = 0; |
126 | 126 | // Here we check type of source(s) |
127 | 127 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
128 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
129 | - //$formats[$id] = 'deltadbtxt'; |
|
130 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
131 | - //$last_exec['deltadbtxt'] = 0; |
|
132 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
133 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
134 | - //$formats[$id] = 'vatsimtxt'; |
|
135 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
136 | - //$last_exec['vatsimtxt'] = 0; |
|
137 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
138 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
139 | - //$formats[$id] = 'aircraftlistjson'; |
|
140 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
141 | - //$last_exec['aircraftlistjson'] = 0; |
|
142 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
143 | - } else if (preg_match('/opensky/i',$host)) { |
|
144 | - //$formats[$id] = 'aircraftlistjson'; |
|
145 | - $globalSources[$id]['format'] = 'opensky'; |
|
146 | - //$last_exec['aircraftlistjson'] = 0; |
|
147 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
148 | - /* |
|
128 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
129 | + //$formats[$id] = 'deltadbtxt'; |
|
130 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
131 | + //$last_exec['deltadbtxt'] = 0; |
|
132 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
133 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
134 | + //$formats[$id] = 'vatsimtxt'; |
|
135 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
136 | + //$last_exec['vatsimtxt'] = 0; |
|
137 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
138 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
139 | + //$formats[$id] = 'aircraftlistjson'; |
|
140 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
141 | + //$last_exec['aircraftlistjson'] = 0; |
|
142 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
143 | + } else if (preg_match('/opensky/i',$host)) { |
|
144 | + //$formats[$id] = 'aircraftlistjson'; |
|
145 | + $globalSources[$id]['format'] = 'opensky'; |
|
146 | + //$last_exec['aircraftlistjson'] = 0; |
|
147 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
148 | + /* |
|
149 | 149 | // Disabled for now, site change source format |
150 | 150 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
151 | 151 | //$formats[$id] = 'radarvirtueljson'; |
@@ -157,121 +157,121 @@ discard block |
||
157 | 157 | exit(0); |
158 | 158 | } |
159 | 159 | */ |
160 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
161 | - //$formats[$id] = 'planeupdatefaa'; |
|
162 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
163 | - //$last_exec['planeupdatefaa'] = 0; |
|
164 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
165 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
166 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
167 | - exit(0); |
|
168 | - } |
|
169 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
170 | - //$formats[$id] = 'phpvmacars'; |
|
171 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
172 | - //$last_exec['phpvmacars'] = 0; |
|
173 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
175 | - //$formats[$id] = 'phpvmacars'; |
|
176 | - $globalSources[$id]['format'] = 'vam'; |
|
177 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
178 | - } else if (preg_match('/whazzup/i',$host)) { |
|
179 | - //$formats[$id] = 'whazzup'; |
|
180 | - $globalSources[$id]['format'] = 'whazzup'; |
|
181 | - //$last_exec['whazzup'] = 0; |
|
182 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
183 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
184 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
185 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
186 | - } else if (preg_match('/airwhere/i',$host)) { |
|
187 | - $globalSources[$id]['format'] = 'airwhere'; |
|
188 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
189 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
190 | - //$formats[$id] = 'pirepsjson'; |
|
191 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
192 | - //$last_exec['pirepsjson'] = 0; |
|
193 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
194 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
195 | - //$formats[$id] = 'fr24json'; |
|
196 | - $globalSources[$id]['format'] = 'fr24json'; |
|
197 | - //$last_exec['fr24json'] = 0; |
|
198 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
199 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
200 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
201 | - exit(0); |
|
202 | - } |
|
203 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
204 | - //$formats[$id] = 'fr24json'; |
|
205 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
206 | - //$last_exec['fr24json'] = 0; |
|
207 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
208 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
209 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
210 | - exit(0); |
|
211 | - } |
|
212 | - //} else if (preg_match('/10001/',$host)) { |
|
213 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
214 | - //$formats[$id] = 'tsv'; |
|
215 | - $globalSources[$id]['format'] = 'tsv'; |
|
216 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
217 | - } |
|
218 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
219 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
220 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
221 | - if ($idf !== false) { |
|
222 | - $httpfeeds[$id] = $idf; |
|
223 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
224 | - } |
|
225 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
226 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
227 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
228 | - $hostport = explode(':',$host); |
|
229 | - if (isset($hostport[1])) { |
|
160 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
161 | + //$formats[$id] = 'planeupdatefaa'; |
|
162 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
163 | + //$last_exec['planeupdatefaa'] = 0; |
|
164 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
165 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
166 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
167 | + exit(0); |
|
168 | + } |
|
169 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
170 | + //$formats[$id] = 'phpvmacars'; |
|
171 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
172 | + //$last_exec['phpvmacars'] = 0; |
|
173 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
175 | + //$formats[$id] = 'phpvmacars'; |
|
176 | + $globalSources[$id]['format'] = 'vam'; |
|
177 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
178 | + } else if (preg_match('/whazzup/i',$host)) { |
|
179 | + //$formats[$id] = 'whazzup'; |
|
180 | + $globalSources[$id]['format'] = 'whazzup'; |
|
181 | + //$last_exec['whazzup'] = 0; |
|
182 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
183 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
184 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
185 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
186 | + } else if (preg_match('/airwhere/i',$host)) { |
|
187 | + $globalSources[$id]['format'] = 'airwhere'; |
|
188 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
189 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
190 | + //$formats[$id] = 'pirepsjson'; |
|
191 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
192 | + //$last_exec['pirepsjson'] = 0; |
|
193 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
194 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
195 | + //$formats[$id] = 'fr24json'; |
|
196 | + $globalSources[$id]['format'] = 'fr24json'; |
|
197 | + //$last_exec['fr24json'] = 0; |
|
198 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
199 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
200 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
201 | + exit(0); |
|
202 | + } |
|
203 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
204 | + //$formats[$id] = 'fr24json'; |
|
205 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
206 | + //$last_exec['fr24json'] = 0; |
|
207 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
208 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
209 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
210 | + exit(0); |
|
211 | + } |
|
212 | + //} else if (preg_match('/10001/',$host)) { |
|
213 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
214 | + //$formats[$id] = 'tsv'; |
|
215 | + $globalSources[$id]['format'] = 'tsv'; |
|
216 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
217 | + } |
|
218 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
219 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
220 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
221 | + if ($idf !== false) { |
|
222 | + $httpfeeds[$id] = $idf; |
|
223 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
224 | + } |
|
225 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
226 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
227 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
228 | + $hostport = explode(':',$host); |
|
229 | + if (isset($hostport[1])) { |
|
230 | 230 | $port = $hostport[1]; |
231 | 231 | $hostn = $hostport[0]; |
232 | - } else { |
|
232 | + } else { |
|
233 | 233 | $port = $globalSources[$id]['port']; |
234 | 234 | $hostn = $globalSources[$id]['host']; |
235 | - } |
|
236 | - $Common = new Common(); |
|
237 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
238 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
239 | - } else { |
|
240 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
241 | - } |
|
242 | - if ($s) { |
|
243 | - $sockets[$id] = $s; |
|
244 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
245 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
235 | + } |
|
236 | + $Common = new Common(); |
|
237 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
238 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
239 | + } else { |
|
240 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
241 | + } |
|
242 | + if ($s) { |
|
243 | + $sockets[$id] = $s; |
|
244 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
245 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
246 | 246 | //$formats[$id] = 'aprs'; |
247 | 247 | $globalSources[$id]['format'] = 'aprs'; |
248 | 248 | //$aprs_connect = 0; |
249 | 249 | //$use_aprs = true; |
250 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
250 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
251 | 251 | $globalSources[$id]['format'] = 'vrstcp'; |
252 | - } elseif ($port == '10001') { |
|
253 | - //$formats[$id] = 'tsv'; |
|
254 | - $globalSources[$id]['format'] = 'tsv'; |
|
255 | - } elseif ($port == '30002') { |
|
256 | - //$formats[$id] = 'raw'; |
|
257 | - $globalSources[$id]['format'] = 'raw'; |
|
258 | - } elseif ($port == '5001') { |
|
259 | - //$formats[$id] = 'raw'; |
|
260 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
261 | - } elseif ($port == '30005') { |
|
252 | + } elseif ($port == '10001') { |
|
253 | + //$formats[$id] = 'tsv'; |
|
254 | + $globalSources[$id]['format'] = 'tsv'; |
|
255 | + } elseif ($port == '30002') { |
|
256 | + //$formats[$id] = 'raw'; |
|
257 | + $globalSources[$id]['format'] = 'raw'; |
|
258 | + } elseif ($port == '5001') { |
|
259 | + //$formats[$id] = 'raw'; |
|
260 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
261 | + } elseif ($port == '30005') { |
|
262 | 262 | // Not yet supported |
263 | - //$formats[$id] = 'beast'; |
|
264 | - $globalSources[$id]['format'] = 'beast'; |
|
265 | - //} else $formats[$id] = 'sbs'; |
|
266 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
267 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
263 | + //$formats[$id] = 'beast'; |
|
264 | + $globalSources[$id]['format'] = 'beast'; |
|
265 | + //} else $formats[$id] = 'sbs'; |
|
266 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
267 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
268 | 268 | } |
269 | 269 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
270 | - } else { |
|
270 | + } else { |
|
271 | 271 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
272 | - } |
|
273 | - } |
|
274 | - } |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | } |
276 | 276 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
277 | 277 | |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | //connect_all($globalSources); |
295 | 295 | |
296 | 296 | if (isset($globalProxy) && $globalProxy) { |
297 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
297 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
298 | 298 | } else { |
299 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
299 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // APRS Configuration |
@@ -305,21 +305,21 @@ discard block |
||
305 | 305 | die; |
306 | 306 | } |
307 | 307 | foreach ($globalSources as $key => $source) { |
308 | - if (!isset($source['format'])) { |
|
309 | - $globalSources[$key]['format'] = 'auto'; |
|
310 | - } |
|
311 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
312 | - unset($globalSources[$key]); |
|
313 | - } |
|
308 | + if (!isset($source['format'])) { |
|
309 | + $globalSources[$key]['format'] = 'auto'; |
|
310 | + } |
|
311 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
312 | + unset($globalSources[$key]); |
|
313 | + } |
|
314 | 314 | } |
315 | 315 | connect_all($globalSources); |
316 | 316 | foreach ($globalSources as $key => $source) { |
317 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
317 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
318 | 318 | $aprs_connect = 0; |
319 | 319 | $use_aprs = true; |
320 | 320 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
321 | 321 | break; |
322 | - } |
|
322 | + } |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | if ($use_aprs) { |
@@ -360,126 +360,126 @@ discard block |
||
360 | 360 | |
361 | 361 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
362 | 362 | while ($i > 0) { |
363 | - if (!$globalDaemon) $i = $endtime-time(); |
|
364 | - // Delete old ATC |
|
365 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
363 | + if (!$globalDaemon) $i = $endtime-time(); |
|
364 | + // Delete old ATC |
|
365 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
366 | 366 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
367 | - $ATC->deleteOldATC(); |
|
368 | - } |
|
367 | + $ATC->deleteOldATC(); |
|
368 | + } |
|
369 | 369 | |
370 | - if (count($last_exec) == count($globalSources)) { |
|
370 | + if (count($last_exec) == count($globalSources)) { |
|
371 | 371 | $max = $globalMinFetch; |
372 | 372 | foreach ($last_exec as $last) { |
373 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
373 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
374 | 374 | } |
375 | 375 | if ($max != $globalMinFetch) { |
376 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
377 | - sleep($globalMinFetch-$max+2); |
|
376 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
377 | + sleep($globalMinFetch-$max+2); |
|
378 | + } |
|
378 | 379 | } |
379 | - } |
|
380 | 380 | |
381 | 381 | |
382 | - //foreach ($formats as $id => $value) { |
|
383 | - foreach ($globalSources as $id => $value) { |
|
382 | + //foreach ($formats as $id => $value) { |
|
383 | + foreach ($globalSources as $id => $value) { |
|
384 | 384 | date_default_timezone_set('UTC'); |
385 | 385 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
386 | 386 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
387 | 387 | if ($value['format'] == 'deltadbtxt' && |
388 | - ( |
|
388 | + ( |
|
389 | 389 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
390 | 390 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
391 | - ) |
|
391 | + ) |
|
392 | 392 | ) { |
393 | - //$buffer = $Common->getData($hosts[$id]); |
|
394 | - $buffer = $Common->getData($value['host']); |
|
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 | - if ($line != '' && count($line) > 7) { |
|
400 | - $line = explode(',', $line); |
|
401 | - $data = array(); |
|
402 | - $data['hex'] = $line[1]; // hex |
|
403 | - $data['ident'] = $line[2]; // ident |
|
404 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
405 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
406 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
407 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
408 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
409 | - $data['verticalrate'] = ''; // vertical rate |
|
410 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
411 | - $data['emergency'] = ''; // emergency |
|
412 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
413 | - $data['format_source'] = 'deltadbtxt'; |
|
414 | - $data['id_source'] = $id_source; |
|
415 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
416 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
417 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
418 | - $SI->add($data); |
|
419 | - unset($data); |
|
420 | - } |
|
421 | - } |
|
422 | - $last_exec[$id]['last'] = time(); |
|
393 | + //$buffer = $Common->getData($hosts[$id]); |
|
394 | + $buffer = $Common->getData($value['host']); |
|
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 | + if ($line != '' && count($line) > 7) { |
|
400 | + $line = explode(',', $line); |
|
401 | + $data = array(); |
|
402 | + $data['hex'] = $line[1]; // hex |
|
403 | + $data['ident'] = $line[2]; // ident |
|
404 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
405 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
406 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
407 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
408 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
409 | + $data['verticalrate'] = ''; // vertical rate |
|
410 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
411 | + $data['emergency'] = ''; // emergency |
|
412 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
413 | + $data['format_source'] = 'deltadbtxt'; |
|
414 | + $data['id_source'] = $id_source; |
|
415 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
416 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
417 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
418 | + $SI->add($data); |
|
419 | + unset($data); |
|
420 | + } |
|
421 | + } |
|
422 | + $last_exec[$id]['last'] = time(); |
|
423 | 423 | } elseif ($value['format'] == 'aisnmeatxt' && |
424 | - ( |
|
424 | + ( |
|
425 | 425 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
426 | 426 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
427 | - ) |
|
427 | + ) |
|
428 | 428 | ) { |
429 | - date_default_timezone_set('CET'); |
|
430 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
431 | - date_default_timezone_set('UTC'); |
|
432 | - if ($buffer != '') $reset = 0; |
|
433 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | - $buffer = explode('\n',$buffer); |
|
435 | - foreach ($buffer as $line) { |
|
429 | + date_default_timezone_set('CET'); |
|
430 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
431 | + date_default_timezone_set('UTC'); |
|
432 | + if ($buffer != '') $reset = 0; |
|
433 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | + $buffer = explode('\n',$buffer); |
|
435 | + foreach ($buffer as $line) { |
|
436 | 436 | if ($line != '') { |
437 | - //echo "'".$line."'\n"; |
|
438 | - $add = false; |
|
439 | - $ais_data = $AIS->parse_line(trim($line)); |
|
440 | - $data = array(); |
|
441 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
442 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
443 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
444 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
445 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
446 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
447 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
448 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
449 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
450 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
451 | - if (isset($ais_data['timestamp'])) { |
|
437 | + //echo "'".$line."'\n"; |
|
438 | + $add = false; |
|
439 | + $ais_data = $AIS->parse_line(trim($line)); |
|
440 | + $data = array(); |
|
441 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
442 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
443 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
444 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
445 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
446 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
447 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
448 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
449 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
450 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
451 | + if (isset($ais_data['timestamp'])) { |
|
452 | 452 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
453 | 453 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
454 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
455 | - $add = true; |
|
454 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
455 | + $add = true; |
|
456 | 456 | } |
457 | - } else { |
|
457 | + } else { |
|
458 | 458 | $data['datetime'] = date('Y-m-d H:i:s'); |
459 | 459 | $add = true; |
460 | - } |
|
461 | - $data['format_source'] = 'aisnmeatxt'; |
|
462 | - $data['id_source'] = $id_source; |
|
463 | - //print_r($data); |
|
464 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
465 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
466 | - unset($data); |
|
460 | + } |
|
461 | + $data['format_source'] = 'aisnmeatxt'; |
|
462 | + $data['id_source'] = $id_source; |
|
463 | + //print_r($data); |
|
464 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
465 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
466 | + unset($data); |
|
467 | 467 | } |
468 | - } |
|
469 | - $last_exec[$id]['last'] = time(); |
|
468 | + } |
|
469 | + $last_exec[$id]['last'] = time(); |
|
470 | 470 | } elseif ($value['format'] == 'aisnmeahttp') { |
471 | - $arr = $httpfeeds; |
|
472 | - $w = $e = null; |
|
471 | + $arr = $httpfeeds; |
|
472 | + $w = $e = null; |
|
473 | 473 | |
474 | - if (isset($arr[$id])) { |
|
474 | + if (isset($arr[$id])) { |
|
475 | 475 | $nn = stream_select($arr,$w,$e,$timeout); |
476 | 476 | if ($nn > 0) { |
477 | - foreach ($httpfeeds as $feed) { |
|
477 | + foreach ($httpfeeds as $feed) { |
|
478 | 478 | $buffer = stream_get_line($feed,2000,"\n"); |
479 | 479 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
480 | 480 | $buffer = explode('\n',$buffer); |
481 | 481 | foreach ($buffer as $line) { |
482 | - if ($line != '') { |
|
482 | + if ($line != '') { |
|
483 | 483 | $ais_data = $AIS->parse_line(trim($line)); |
484 | 484 | $data = array(); |
485 | 485 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -497,111 +497,111 @@ discard block |
||
497 | 497 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
498 | 498 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
499 | 499 | if (isset($ais_data['timestamp'])) { |
500 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
500 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
501 | 501 | } else { |
502 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
502 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
503 | 503 | } |
504 | 504 | $data['format_source'] = 'aisnmeahttp'; |
505 | 505 | $data['id_source'] = $id_source; |
506 | 506 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
507 | 507 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
508 | 508 | unset($data); |
509 | - } |
|
509 | + } |
|
510 | + } |
|
510 | 511 | } |
511 | - } |
|
512 | 512 | } else { |
513 | - $format = $value['format']; |
|
514 | - if (isset($tt[$format])) $tt[$format]++; |
|
515 | - else $tt[$format] = 0; |
|
516 | - if ($tt[$format] > 30) { |
|
513 | + $format = $value['format']; |
|
514 | + if (isset($tt[$format])) $tt[$format]++; |
|
515 | + else $tt[$format] = 0; |
|
516 | + if ($tt[$format] > 30) { |
|
517 | 517 | if ($globalDebug) echo 'Reconnect...'."\n"; |
518 | 518 | sleep(2); |
519 | 519 | $sourceeen[] = $value; |
520 | 520 | connect_all($sourceeen); |
521 | 521 | $sourceeen = array(); |
522 | - } |
|
522 | + } |
|
523 | + } |
|
523 | 524 | } |
524 | - } |
|
525 | 525 | } elseif ($value['format'] == 'myshiptracking' && |
526 | - ( |
|
526 | + ( |
|
527 | 527 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
528 | 528 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
529 | - ) |
|
529 | + ) |
|
530 | 530 | ) { |
531 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
532 | - if ($buffer != '') { |
|
531 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
532 | + if ($buffer != '') { |
|
533 | 533 | //echo $buffer; |
534 | 534 | $all_data = json_decode($buffer,true); |
535 | 535 | //print_r($all_data); |
536 | 536 | if (isset($all_data[0]['DATA'])) { |
537 | - foreach ($all_data[0]['DATA'] as $line) { |
|
537 | + foreach ($all_data[0]['DATA'] as $line) { |
|
538 | 538 | if ($line != '') { |
539 | - $data = array(); |
|
540 | - $data['ident'] = $line['NAME']; |
|
541 | - $data['mmsi'] = $line['MMSI']; |
|
542 | - $data['speed'] = $line['SOG']; |
|
543 | - $data['heading'] = $line['COG']; |
|
544 | - $data['latitude'] = $line['LAT']; |
|
545 | - $data['longitude'] = $line['LNG']; |
|
546 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
547 | - $data['imo'] = $line['IMO']; |
|
548 | - //$data['arrival_code'] = $ais_data['destination']; |
|
549 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
550 | - $data['format_source'] = 'myshiptracking'; |
|
551 | - $data['id_source'] = $id_source; |
|
552 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
553 | - $MI->add($data); |
|
554 | - unset($data); |
|
539 | + $data = array(); |
|
540 | + $data['ident'] = $line['NAME']; |
|
541 | + $data['mmsi'] = $line['MMSI']; |
|
542 | + $data['speed'] = $line['SOG']; |
|
543 | + $data['heading'] = $line['COG']; |
|
544 | + $data['latitude'] = $line['LAT']; |
|
545 | + $data['longitude'] = $line['LNG']; |
|
546 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
547 | + $data['imo'] = $line['IMO']; |
|
548 | + //$data['arrival_code'] = $ais_data['destination']; |
|
549 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
550 | + $data['format_source'] = 'myshiptracking'; |
|
551 | + $data['id_source'] = $id_source; |
|
552 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
553 | + $MI->add($data); |
|
554 | + unset($data); |
|
555 | + } |
|
555 | 556 | } |
556 | - } |
|
557 | 557 | } |
558 | - } |
|
559 | - $last_exec[$id]['last'] = time(); |
|
558 | + } |
|
559 | + $last_exec[$id]['last'] = time(); |
|
560 | 560 | } elseif ($value['format'] == 'boatbeaconapp' && |
561 | - ( |
|
561 | + ( |
|
562 | 562 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
563 | 563 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
564 | - ) |
|
564 | + ) |
|
565 | 565 | ) { |
566 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
567 | - if ($buffer != '') { |
|
566 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
567 | + if ($buffer != '') { |
|
568 | 568 | $all_data = json_decode($buffer,true); |
569 | 569 | if (isset($all_data[0]['mmsi'])) { |
570 | - foreach ($all_data as $line) { |
|
570 | + foreach ($all_data as $line) { |
|
571 | 571 | if ($line != '') { |
572 | - $data = array(); |
|
573 | - $data['ident'] = $line['shipname']; |
|
574 | - $data['callsign'] = $line['callsign']; |
|
575 | - $data['mmsi'] = $line['mmsi']; |
|
576 | - $data['speed'] = $line['sog']; |
|
577 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
578 | - $data['latitude'] = $line['latitude']; |
|
579 | - $data['longitude'] = $line['longitude']; |
|
580 | - $data['type_id'] = $line['shiptype']; |
|
581 | - $data['arrival_code'] = $line['destination']; |
|
582 | - $data['datetime'] = $line['time']; |
|
583 | - $data['format_source'] = 'boatbeaconapp'; |
|
584 | - $data['id_source'] = $id_source; |
|
585 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
586 | - $MI->add($data); |
|
587 | - unset($data); |
|
572 | + $data = array(); |
|
573 | + $data['ident'] = $line['shipname']; |
|
574 | + $data['callsign'] = $line['callsign']; |
|
575 | + $data['mmsi'] = $line['mmsi']; |
|
576 | + $data['speed'] = $line['sog']; |
|
577 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
578 | + $data['latitude'] = $line['latitude']; |
|
579 | + $data['longitude'] = $line['longitude']; |
|
580 | + $data['type_id'] = $line['shiptype']; |
|
581 | + $data['arrival_code'] = $line['destination']; |
|
582 | + $data['datetime'] = $line['time']; |
|
583 | + $data['format_source'] = 'boatbeaconapp'; |
|
584 | + $data['id_source'] = $id_source; |
|
585 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
586 | + $MI->add($data); |
|
587 | + unset($data); |
|
588 | + } |
|
588 | 589 | } |
589 | - } |
|
590 | 590 | } |
591 | 591 | |
592 | - } |
|
593 | - $last_exec[$id]['last'] = time(); |
|
592 | + } |
|
593 | + $last_exec[$id]['last'] = time(); |
|
594 | 594 | } elseif ($value['format'] == 'boatnerd' && |
595 | - ( |
|
595 | + ( |
|
596 | 596 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
597 | 597 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
598 | - ) |
|
598 | + ) |
|
599 | 599 | ) { |
600 | - $buffer = $Common->getData($value['host']); |
|
601 | - if ($buffer != '') { |
|
600 | + $buffer = $Common->getData($value['host']); |
|
601 | + if ($buffer != '') { |
|
602 | 602 | $all_data = json_decode($buffer,true); |
603 | 603 | if (isset($all_data['features'][0]['id'])) { |
604 | - foreach ($all_data['features'] as $line) { |
|
604 | + foreach ($all_data['features'] as $line) { |
|
605 | 605 | $data = array(); |
606 | 606 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
607 | 607 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -620,78 +620,78 @@ discard block |
||
620 | 620 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
621 | 621 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
622 | 622 | unset($data); |
623 | - } |
|
623 | + } |
|
624 | 624 | } |
625 | 625 | |
626 | - } |
|
627 | - $last_exec[$id]['last'] = time(); |
|
626 | + } |
|
627 | + $last_exec[$id]['last'] = time(); |
|
628 | 628 | } elseif ($value['format'] == 'shipplotter' && |
629 | - ( |
|
629 | + ( |
|
630 | 630 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
631 | 631 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
632 | - ) |
|
632 | + ) |
|
633 | 633 | ) { |
634 | - echo 'download...'; |
|
635 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
636 | - echo 'done !'."\n"; |
|
637 | - if ($buffer != '') $reset = 0; |
|
638 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
639 | - $buffer = explode('\n',$buffer); |
|
640 | - foreach ($buffer as $line) { |
|
634 | + echo 'download...'; |
|
635 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
636 | + echo 'done !'."\n"; |
|
637 | + if ($buffer != '') $reset = 0; |
|
638 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
639 | + $buffer = explode('\n',$buffer); |
|
640 | + foreach ($buffer as $line) { |
|
641 | 641 | if ($line != '') { |
642 | - $data = array(); |
|
643 | - $data['mmsi'] = (int)substr($line,0,9); |
|
644 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
645 | - //$data['status'] = substr($line,21,2); |
|
646 | - //$data['type'] = substr($line,24,3); |
|
647 | - $data['latitude'] = substr($line,29,9); |
|
648 | - $data['longitude'] = substr($line,41,9); |
|
649 | - $data['speed'] = round(substr($line,51,5)); |
|
650 | - //$data['course'] = substr($line,57,5); |
|
651 | - $data['heading'] = round(substr($line,63,3)); |
|
652 | - //$data['draft'] = substr($line,67,4); |
|
653 | - //$data['length'] = substr($line,72,3); |
|
654 | - //$data['beam'] = substr($line,76,2); |
|
655 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
656 | - //$data['callsign'] = trim(substr($line,100,7); |
|
657 | - //$data['dest'] = substr($line,108,20); |
|
658 | - //$data['etaDate'] = substr($line,129,5); |
|
659 | - //$data['etaTime'] = substr($line,135,5); |
|
660 | - $data['format_source'] = 'shipplotter'; |
|
661 | - $data['id_source'] = $id_source; |
|
662 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
663 | - //print_r($data); |
|
664 | - echo 'Add...'."\n"; |
|
665 | - $MI->add($data); |
|
666 | - unset($data); |
|
642 | + $data = array(); |
|
643 | + $data['mmsi'] = (int)substr($line,0,9); |
|
644 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
645 | + //$data['status'] = substr($line,21,2); |
|
646 | + //$data['type'] = substr($line,24,3); |
|
647 | + $data['latitude'] = substr($line,29,9); |
|
648 | + $data['longitude'] = substr($line,41,9); |
|
649 | + $data['speed'] = round(substr($line,51,5)); |
|
650 | + //$data['course'] = substr($line,57,5); |
|
651 | + $data['heading'] = round(substr($line,63,3)); |
|
652 | + //$data['draft'] = substr($line,67,4); |
|
653 | + //$data['length'] = substr($line,72,3); |
|
654 | + //$data['beam'] = substr($line,76,2); |
|
655 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
656 | + //$data['callsign'] = trim(substr($line,100,7); |
|
657 | + //$data['dest'] = substr($line,108,20); |
|
658 | + //$data['etaDate'] = substr($line,129,5); |
|
659 | + //$data['etaTime'] = substr($line,135,5); |
|
660 | + $data['format_source'] = 'shipplotter'; |
|
661 | + $data['id_source'] = $id_source; |
|
662 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
663 | + //print_r($data); |
|
664 | + echo 'Add...'."\n"; |
|
665 | + $MI->add($data); |
|
666 | + unset($data); |
|
667 | 667 | } |
668 | - } |
|
669 | - $last_exec[$id]['last'] = time(); |
|
668 | + } |
|
669 | + $last_exec[$id]['last'] = time(); |
|
670 | 670 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
671 | 671 | } elseif ( |
672 | - ( |
|
672 | + ( |
|
673 | 673 | $value['format'] == 'whazzup' && |
674 | 674 | ( |
675 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
676 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
675 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
676 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
677 | 677 | ) |
678 | - ) || ( |
|
678 | + ) || ( |
|
679 | 679 | $value['format'] == 'vatsimtxt' && |
680 | 680 | ( |
681 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
682 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
681 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
682 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
683 | + ) |
|
683 | 684 | ) |
684 | - ) |
|
685 | 685 | ) { |
686 | - //$buffer = $Common->getData($hosts[$id]); |
|
687 | - $buffer = $Common->getData($value['host']); |
|
688 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | - $buffer = explode('\n',$buffer); |
|
690 | - $reset = 0; |
|
691 | - foreach ($buffer as $line) { |
|
692 | - if ($line != '') { |
|
693 | - $line = explode(':', $line); |
|
694 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
686 | + //$buffer = $Common->getData($hosts[$id]); |
|
687 | + $buffer = $Common->getData($value['host']); |
|
688 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | + $buffer = explode('\n',$buffer); |
|
690 | + $reset = 0; |
|
691 | + foreach ($buffer as $line) { |
|
692 | + if ($line != '') { |
|
693 | + $line = explode(':', $line); |
|
694 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
695 | 695 | $data = array(); |
696 | 696 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
697 | 697 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -704,37 +704,37 @@ discard block |
||
704 | 704 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
705 | 705 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
706 | 706 | $data['latitude'] = $line[5]; // lat |
707 | - $data['longitude'] = $line[6]; // long |
|
708 | - $data['verticalrate'] = ''; // vertical rate |
|
709 | - $data['squawk'] = ''; // squawk |
|
710 | - $data['emergency'] = ''; // emergency |
|
711 | - $data['waypoints'] = $line[30]; |
|
707 | + $data['longitude'] = $line[6]; // long |
|
708 | + $data['verticalrate'] = ''; // vertical rate |
|
709 | + $data['squawk'] = ''; // squawk |
|
710 | + $data['emergency'] = ''; // emergency |
|
711 | + $data['waypoints'] = $line[30]; |
|
712 | 712 | $data['datetime'] = date('Y-m-d H:i:s'); |
713 | 713 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
714 | 714 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
715 | - $data['departure_airport_icao'] = $line[11]; |
|
716 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
717 | - $data['arrival_airport_icao'] = $line[13]; |
|
715 | + $data['departure_airport_icao'] = $line[11]; |
|
716 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
717 | + $data['arrival_airport_icao'] = $line[13]; |
|
718 | 718 | $data['frequency'] = $line[4]; |
719 | 719 | $data['type'] = $line[18]; |
720 | 720 | $data['range'] = $line[19]; |
721 | 721 | if (isset($line[35])) $data['info'] = $line[35]; |
722 | - $data['id_source'] = $id_source; |
|
723 | - //$data['arrival_airport_time'] = ; |
|
724 | - if ($line[9] != '') { |
|
725 | - $aircraft_data = explode('/',$line[9]); |
|
726 | - if (isset($aircraft_data[1])) { |
|
727 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
728 | - } |
|
729 | - } |
|
730 | - /* |
|
722 | + $data['id_source'] = $id_source; |
|
723 | + //$data['arrival_airport_time'] = ; |
|
724 | + if ($line[9] != '') { |
|
725 | + $aircraft_data = explode('/',$line[9]); |
|
726 | + if (isset($aircraft_data[1])) { |
|
727 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
728 | + } |
|
729 | + } |
|
730 | + /* |
|
731 | 731 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
732 | 732 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
733 | 733 | */ |
734 | - $data['format_source'] = $value['format']; |
|
734 | + $data['format_source'] = $value['format']; |
|
735 | 735 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
736 | 736 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
737 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
737 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
738 | 738 | elseif ($line[3] == 'ATC') { |
739 | 739 | //print_r($data); |
740 | 740 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -755,21 +755,21 @@ discard block |
||
755 | 755 | else 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']); |
756 | 756 | } |
757 | 757 | } |
758 | - unset($data); |
|
759 | - } |
|
760 | - } |
|
761 | - } |
|
762 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
763 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
764 | - $last_exec[$id]['last'] = time(); |
|
765 | - } elseif ($value['format'] == 'airwhere' && |
|
766 | - ( |
|
767 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
768 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
769 | - ) |
|
770 | - ) { |
|
771 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
772 | - if ($buffer != '') { |
|
758 | + unset($data); |
|
759 | + } |
|
760 | + } |
|
761 | + } |
|
762 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
763 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
764 | + $last_exec[$id]['last'] = time(); |
|
765 | + } elseif ($value['format'] == 'airwhere' && |
|
766 | + ( |
|
767 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
768 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
769 | + ) |
|
770 | + ) { |
|
771 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
772 | + if ($buffer != '') { |
|
773 | 773 | $all_data = simplexml_load_string($buffer); |
774 | 774 | foreach($all_data->children() as $childdata) { |
775 | 775 | $data = array(); |
@@ -791,10 +791,10 @@ discard block |
||
791 | 791 | $SI->add($data); |
792 | 792 | unset($data); |
793 | 793 | } |
794 | - } |
|
795 | - $Source->deleteOldLocationByType('gs'); |
|
796 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
797 | - if ($buffer != '') { |
|
794 | + } |
|
795 | + $Source->deleteOldLocationByType('gs'); |
|
796 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
797 | + if ($buffer != '') { |
|
798 | 798 | $all_data = simplexml_load_string($buffer); |
799 | 799 | foreach($all_data->children() as $childdata) { |
800 | 800 | $data = array(); |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | } |
813 | 813 | unset($data); |
814 | 814 | } |
815 | - } |
|
816 | - $last_exec[$id]['last'] = time(); |
|
815 | + } |
|
816 | + $last_exec[$id]['last'] = time(); |
|
817 | 817 | /* |
818 | 818 | } if ($value['format'] == 'aircraftlistjson') { |
819 | 819 | print_r($globalSources); |
@@ -821,17 +821,17 @@ discard block |
||
821 | 821 | echo $globalMinFetch; |
822 | 822 | */ |
823 | 823 | } elseif ($value['format'] == 'aircraftlistjson' && |
824 | - ( |
|
824 | + ( |
|
825 | 825 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
826 | 826 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
827 | - ) |
|
827 | + ) |
|
828 | 828 | ) { |
829 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
830 | - if ($buffer != '') { |
|
831 | - $all_data = json_decode($buffer,true); |
|
829 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
830 | + if ($buffer != '') { |
|
831 | + $all_data = json_decode($buffer,true); |
|
832 | 832 | if (isset($all_data['acList'])) { |
833 | - $reset = 0; |
|
834 | - foreach ($all_data['acList'] as $line) { |
|
833 | + $reset = 0; |
|
834 | + foreach ($all_data['acList'] as $line) { |
|
835 | 835 | $data = array(); |
836 | 836 | $data['hex'] = $line['Icao']; // hex |
837 | 837 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -854,10 +854,10 @@ discard block |
||
854 | 854 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
855 | 855 | if (isset($data['latitude'])) $SI->add($data); |
856 | 856 | unset($data); |
857 | - } |
|
857 | + } |
|
858 | 858 | } elseif (is_array($all_data)) { |
859 | - $reset = 0; |
|
860 | - foreach ($all_data as $line) { |
|
859 | + $reset = 0; |
|
860 | + foreach ($all_data as $line) { |
|
861 | 861 | $data = array(); |
862 | 862 | $data['hex'] = $line['hex']; // hex |
863 | 863 | $data['ident'] = $line['flight']; // ident |
@@ -877,218 +877,218 @@ discard block |
||
877 | 877 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
878 | 878 | $SI->add($data); |
879 | 879 | unset($data); |
880 | - } |
|
880 | + } |
|
881 | 881 | } |
882 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
883 | - //$last_exec['aircraftlistjson'] = time(); |
|
884 | - $last_exec[$id]['last'] = time(); |
|
885 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
886 | - } elseif ($value['format'] == 'planeupdatefaa' && |
|
887 | - ( |
|
888 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
889 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
890 | - ) |
|
891 | - ) { |
|
892 | - $buffer = $Common->getData($value['host']); |
|
893 | - $all_data = json_decode($buffer,true); |
|
894 | - if (isset($all_data['planes'])) { |
|
882 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
883 | + //$last_exec['aircraftlistjson'] = time(); |
|
884 | + $last_exec[$id]['last'] = time(); |
|
885 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
886 | + } elseif ($value['format'] == 'planeupdatefaa' && |
|
887 | + ( |
|
888 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
889 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
890 | + ) |
|
891 | + ) { |
|
892 | + $buffer = $Common->getData($value['host']); |
|
893 | + $all_data = json_decode($buffer,true); |
|
894 | + if (isset($all_data['planes'])) { |
|
895 | 895 | $reset = 0; |
896 | 896 | foreach ($all_data['planes'] as $key => $line) { |
897 | - $data = array(); |
|
898 | - $data['hex'] = $key; // hex |
|
899 | - $data['ident'] = $line[3]; // ident |
|
900 | - $data['altitude'] = $line[6]; // altitude |
|
901 | - $data['speed'] = $line[8]; // speed |
|
902 | - $data['heading'] = $line[7]; // heading |
|
903 | - $data['latitude'] = $line[4]; // lat |
|
904 | - $data['longitude'] = $line[5]; // long |
|
905 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
906 | - $data['squawk'] = $line[10]; // squawk |
|
907 | - $data['emergency'] = ''; // emergency |
|
908 | - $data['registration'] = $line[2]; |
|
909 | - $data['aircraft_icao'] = $line[0]; |
|
910 | - $deparr = explode('-',$line[1]); |
|
911 | - if (count($deparr) == 2) { |
|
897 | + $data = array(); |
|
898 | + $data['hex'] = $key; // hex |
|
899 | + $data['ident'] = $line[3]; // ident |
|
900 | + $data['altitude'] = $line[6]; // altitude |
|
901 | + $data['speed'] = $line[8]; // speed |
|
902 | + $data['heading'] = $line[7]; // heading |
|
903 | + $data['latitude'] = $line[4]; // lat |
|
904 | + $data['longitude'] = $line[5]; // long |
|
905 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
906 | + $data['squawk'] = $line[10]; // squawk |
|
907 | + $data['emergency'] = ''; // emergency |
|
908 | + $data['registration'] = $line[2]; |
|
909 | + $data['aircraft_icao'] = $line[0]; |
|
910 | + $deparr = explode('-',$line[1]); |
|
911 | + if (count($deparr) == 2) { |
|
912 | 912 | $data['departure_airport_icao'] = $deparr[0]; |
913 | 913 | $data['arrival_airport_icao'] = $deparr[1]; |
914 | - } |
|
915 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
916 | - $data['format_source'] = 'planeupdatefaa'; |
|
917 | - $data['id_source'] = $id_source; |
|
918 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
919 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
920 | - $SI->add($data); |
|
921 | - unset($data); |
|
914 | + } |
|
915 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
916 | + $data['format_source'] = 'planeupdatefaa'; |
|
917 | + $data['id_source'] = $id_source; |
|
918 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
919 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
920 | + $SI->add($data); |
|
921 | + unset($data); |
|
922 | + } |
|
922 | 923 | } |
923 | - } |
|
924 | - //$last_exec['planeupdatefaa'] = time(); |
|
925 | - $last_exec[$id]['last'] = time(); |
|
924 | + //$last_exec['planeupdatefaa'] = time(); |
|
925 | + $last_exec[$id]['last'] = time(); |
|
926 | 926 | } elseif ($value['format'] == 'opensky' && |
927 | - ( |
|
927 | + ( |
|
928 | 928 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
929 | 929 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
930 | - ) |
|
930 | + ) |
|
931 | 931 | ) { |
932 | - $buffer = $Common->getData($value['host']); |
|
933 | - $all_data = json_decode($buffer,true); |
|
934 | - if (isset($all_data['states'])) { |
|
932 | + $buffer = $Common->getData($value['host']); |
|
933 | + $all_data = json_decode($buffer,true); |
|
934 | + if (isset($all_data['states'])) { |
|
935 | 935 | $reset = 0; |
936 | 936 | foreach ($all_data['states'] as $key => $line) { |
937 | - $data = array(); |
|
938 | - $data['hex'] = $line[0]; // hex |
|
939 | - $data['ident'] = trim($line[1]); // ident |
|
940 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
941 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
942 | - $data['heading'] = round($line[10]); // heading |
|
943 | - $data['latitude'] = $line[6]; // lat |
|
944 | - $data['longitude'] = $line[5]; // long |
|
945 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
946 | - //$data['squawk'] = $line[10]; // squawk |
|
947 | - //$data['emergency'] = ''; // emergency |
|
948 | - //$data['registration'] = $line[2]; |
|
949 | - //$data['aircraft_icao'] = $line[0]; |
|
950 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
951 | - $data['format_source'] = 'opensky'; |
|
952 | - $data['id_source'] = $id_source; |
|
953 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
954 | - $SI->add($data); |
|
955 | - unset($data); |
|
937 | + $data = array(); |
|
938 | + $data['hex'] = $line[0]; // hex |
|
939 | + $data['ident'] = trim($line[1]); // ident |
|
940 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
941 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
942 | + $data['heading'] = round($line[10]); // heading |
|
943 | + $data['latitude'] = $line[6]; // lat |
|
944 | + $data['longitude'] = $line[5]; // long |
|
945 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
946 | + //$data['squawk'] = $line[10]; // squawk |
|
947 | + //$data['emergency'] = ''; // emergency |
|
948 | + //$data['registration'] = $line[2]; |
|
949 | + //$data['aircraft_icao'] = $line[0]; |
|
950 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
951 | + $data['format_source'] = 'opensky'; |
|
952 | + $data['id_source'] = $id_source; |
|
953 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
954 | + $SI->add($data); |
|
955 | + unset($data); |
|
956 | 956 | } |
957 | - } |
|
958 | - //$last_exec['planeupdatefaa'] = time(); |
|
959 | - $last_exec[$id]['last'] = time(); |
|
957 | + } |
|
958 | + //$last_exec['planeupdatefaa'] = time(); |
|
959 | + $last_exec[$id]['last'] = time(); |
|
960 | 960 | //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
961 | 961 | } elseif ($value['format'] == 'fr24json' && |
962 | - ( |
|
962 | + ( |
|
963 | 963 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
964 | 964 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
965 | - ) |
|
965 | + ) |
|
966 | 966 | ) { |
967 | - //$buffer = $Common->getData($hosts[$id]); |
|
968 | - $buffer = $Common->getData($value['host']); |
|
969 | - $all_data = json_decode($buffer,true); |
|
970 | - if (!empty($all_data)) $reset = 0; |
|
971 | - foreach ($all_data as $key => $line) { |
|
967 | + //$buffer = $Common->getData($hosts[$id]); |
|
968 | + $buffer = $Common->getData($value['host']); |
|
969 | + $all_data = json_decode($buffer,true); |
|
970 | + if (!empty($all_data)) $reset = 0; |
|
971 | + foreach ($all_data as $key => $line) { |
|
972 | 972 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
973 | - $data = array(); |
|
974 | - $data['hex'] = $line[0]; |
|
975 | - $data['ident'] = $line[16]; //$line[13] |
|
976 | - $data['altitude'] = $line[4]; // altitude |
|
977 | - $data['speed'] = $line[5]; // speed |
|
978 | - $data['heading'] = $line[3]; // heading |
|
979 | - $data['latitude'] = $line[1]; // lat |
|
980 | - $data['longitude'] = $line[2]; // long |
|
981 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
982 | - $data['squawk'] = $line[6]; // squawk |
|
983 | - $data['aircraft_icao'] = $line[8]; |
|
984 | - $data['registration'] = $line[9]; |
|
985 | - $data['departure_airport_iata'] = $line[11]; |
|
986 | - $data['arrival_airport_iata'] = $line[12]; |
|
987 | - $data['emergency'] = ''; // emergency |
|
988 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
989 | - $data['format_source'] = 'fr24json'; |
|
990 | - $data['id_source'] = $id_source; |
|
991 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
993 | - $SI->add($data); |
|
994 | - unset($data); |
|
973 | + $data = array(); |
|
974 | + $data['hex'] = $line[0]; |
|
975 | + $data['ident'] = $line[16]; //$line[13] |
|
976 | + $data['altitude'] = $line[4]; // altitude |
|
977 | + $data['speed'] = $line[5]; // speed |
|
978 | + $data['heading'] = $line[3]; // heading |
|
979 | + $data['latitude'] = $line[1]; // lat |
|
980 | + $data['longitude'] = $line[2]; // long |
|
981 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
982 | + $data['squawk'] = $line[6]; // squawk |
|
983 | + $data['aircraft_icao'] = $line[8]; |
|
984 | + $data['registration'] = $line[9]; |
|
985 | + $data['departure_airport_iata'] = $line[11]; |
|
986 | + $data['arrival_airport_iata'] = $line[12]; |
|
987 | + $data['emergency'] = ''; // emergency |
|
988 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
989 | + $data['format_source'] = 'fr24json'; |
|
990 | + $data['id_source'] = $id_source; |
|
991 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
992 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
993 | + $SI->add($data); |
|
994 | + unset($data); |
|
995 | 995 | } |
996 | - } |
|
997 | - //$last_exec['fr24json'] = time(); |
|
998 | - $last_exec[$id]['last'] = time(); |
|
996 | + } |
|
997 | + //$last_exec['fr24json'] = time(); |
|
998 | + $last_exec[$id]['last'] = time(); |
|
999 | 999 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1000 | 1000 | } elseif ($value['format'] == 'radarvirtueljson' && |
1001 | - ( |
|
1001 | + ( |
|
1002 | 1002 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1003 | 1003 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1004 | - ) |
|
1004 | + ) |
|
1005 | 1005 | ) { |
1006 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1007 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1008 | - //echo $buffer; |
|
1009 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1010 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1011 | - $all_data = json_decode($buffer,true); |
|
1012 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1006 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1007 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1008 | + //echo $buffer; |
|
1009 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1010 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1011 | + $all_data = json_decode($buffer,true); |
|
1012 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1013 | 1013 | die(json_last_error_msg()); |
1014 | - } |
|
1015 | - if (isset($all_data['mrkrs'])) { |
|
1014 | + } |
|
1015 | + if (isset($all_data['mrkrs'])) { |
|
1016 | 1016 | $reset = 0; |
1017 | 1017 | foreach ($all_data['mrkrs'] as $key => $line) { |
1018 | - if (isset($line['inf'])) { |
|
1018 | + if (isset($line['inf'])) { |
|
1019 | 1019 | $data = array(); |
1020 | 1020 | $data['hex'] = $line['inf']['ia']; |
1021 | 1021 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1022 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1023 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1024 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1025 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1026 | - $data['longitude'] = $line['pt'][1]; // long |
|
1027 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1028 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1029 | - //$data['aircraft_icao'] = $line[8]; |
|
1030 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1022 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1023 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1024 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1025 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1026 | + $data['longitude'] = $line['pt'][1]; // long |
|
1027 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1028 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1029 | + //$data['aircraft_icao'] = $line[8]; |
|
1030 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1031 | 1031 | //$data['departure_airport_iata'] = $line[11]; |
1032 | 1032 | //$data['arrival_airport_iata'] = $line[12]; |
1033 | - //$data['emergency'] = ''; // emergency |
|
1033 | + //$data['emergency'] = ''; // emergency |
|
1034 | 1034 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1035 | - $data['format_source'] = 'radarvirtueljson'; |
|
1036 | - $data['id_source'] = $id_source; |
|
1035 | + $data['format_source'] = 'radarvirtueljson'; |
|
1036 | + $data['id_source'] = $id_source; |
|
1037 | 1037 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1038 | 1038 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1039 | 1039 | $SI->add($data); |
1040 | 1040 | unset($data); |
1041 | - } |
|
1041 | + } |
|
1042 | + } |
|
1042 | 1043 | } |
1043 | - } |
|
1044 | - //$last_exec['radarvirtueljson'] = time(); |
|
1045 | - $last_exec[$id]['last'] = time(); |
|
1044 | + //$last_exec['radarvirtueljson'] = time(); |
|
1045 | + $last_exec[$id]['last'] = time(); |
|
1046 | 1046 | //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1047 | 1047 | } elseif ($value['format'] == 'pirepsjson' && |
1048 | - ( |
|
1048 | + ( |
|
1049 | 1049 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1050 | 1050 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1051 | - ) |
|
1051 | + ) |
|
1052 | 1052 | ) { |
1053 | - //$buffer = $Common->getData($hosts[$id]); |
|
1054 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1055 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1053 | + //$buffer = $Common->getData($hosts[$id]); |
|
1054 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1055 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1056 | 1056 | |
1057 | - if (isset($all_data['pireps'])) { |
|
1057 | + if (isset($all_data['pireps'])) { |
|
1058 | 1058 | $reset = 0; |
1059 | - foreach ($all_data['pireps'] as $line) { |
|
1060 | - $data = array(); |
|
1061 | - $data['id'] = $line['id']; |
|
1062 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1063 | - $data['ident'] = $line['callsign']; // ident |
|
1064 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1065 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1066 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1067 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1068 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1069 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1070 | - $data['latitude'] = $line['lat']; // lat |
|
1071 | - $data['longitude'] = $line['lon']; // long |
|
1072 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1073 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1074 | - //$data['emergency'] = ''; // emergency |
|
1075 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1076 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1077 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1078 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1079 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1080 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1081 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1082 | - else $data['info'] = ''; |
|
1083 | - $data['format_source'] = 'pireps'; |
|
1084 | - $data['id_source'] = $id_source; |
|
1085 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1086 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1087 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1088 | - if ($line['icon'] == 'plane') { |
|
1059 | + foreach ($all_data['pireps'] as $line) { |
|
1060 | + $data = array(); |
|
1061 | + $data['id'] = $line['id']; |
|
1062 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1063 | + $data['ident'] = $line['callsign']; // ident |
|
1064 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1065 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1066 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1067 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1068 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1069 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1070 | + $data['latitude'] = $line['lat']; // lat |
|
1071 | + $data['longitude'] = $line['lon']; // long |
|
1072 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1073 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1074 | + //$data['emergency'] = ''; // emergency |
|
1075 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1076 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1077 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1078 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1079 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1080 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1081 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1082 | + else $data['info'] = ''; |
|
1083 | + $data['format_source'] = 'pireps'; |
|
1084 | + $data['id_source'] = $id_source; |
|
1085 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1086 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1087 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1088 | + if ($line['icon'] == 'plane') { |
|
1089 | 1089 | $SI->add($data); |
1090 | - // print_r($data); |
|
1091 | - } elseif ($line['icon'] == 'ct') { |
|
1090 | + // print_r($data); |
|
1091 | + } elseif ($line['icon'] == 'ct') { |
|
1092 | 1092 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1093 | 1093 | $data['info'] = str_replace('&sect;','',$data['info']); |
1094 | 1094 | $typec = substr($data['ident'],-3); |
@@ -1103,148 +1103,148 @@ discard block |
||
1103 | 1103 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1104 | 1104 | else $data['type'] = 'Observer'; |
1105 | 1105 | 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']); |
1106 | - } |
|
1107 | - unset($data); |
|
1106 | + } |
|
1107 | + unset($data); |
|
1108 | + } |
|
1108 | 1109 | } |
1109 | - } |
|
1110 | - //$last_exec['pirepsjson'] = time(); |
|
1111 | - $last_exec[$id]['last'] = time(); |
|
1110 | + //$last_exec['pirepsjson'] = time(); |
|
1111 | + $last_exec[$id]['last'] = time(); |
|
1112 | 1112 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1113 | 1113 | } elseif ($value['format'] == 'phpvmacars' && |
1114 | - ( |
|
1114 | + ( |
|
1115 | 1115 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1116 | 1116 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1117 | - ) |
|
1117 | + ) |
|
1118 | 1118 | ) { |
1119 | - //$buffer = $Common->getData($hosts[$id]); |
|
1120 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1121 | - $buffer = $Common->getData($value['host']); |
|
1122 | - $all_data = json_decode($buffer,true); |
|
1123 | - if ($buffer != '' && is_array($all_data)) { |
|
1119 | + //$buffer = $Common->getData($hosts[$id]); |
|
1120 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1121 | + $buffer = $Common->getData($value['host']); |
|
1122 | + $all_data = json_decode($buffer,true); |
|
1123 | + if ($buffer != '' && is_array($all_data)) { |
|
1124 | 1124 | $reset = 0; |
1125 | 1125 | foreach ($all_data as $line) { |
1126 | - $data = array(); |
|
1127 | - //$data['id'] = $line['id']; // id not usable |
|
1128 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1129 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1130 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1131 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1132 | - $data['ident'] = $line['flightnum']; // ident |
|
1133 | - $data['altitude'] = $line['alt']; // altitude |
|
1134 | - $data['speed'] = $line['gs']; // speed |
|
1135 | - $data['heading'] = $line['heading']; // heading |
|
1136 | - $data['latitude'] = $line['lat']; // lat |
|
1137 | - $data['longitude'] = $line['lng']; // long |
|
1138 | - $data['verticalrate'] = ''; // verticale rate |
|
1139 | - $data['squawk'] = ''; // squawk |
|
1140 | - $data['emergency'] = ''; // emergency |
|
1141 | - //$data['datetime'] = $line['lastupdate']; |
|
1142 | - //$data['last_update'] = $line['lastupdate']; |
|
1143 | - if (isset($value['timezone'])) { |
|
1144 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1145 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1146 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1147 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1148 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1149 | - $data['departure_airport_time'] = $line['deptime']; |
|
1150 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1151 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1152 | - $data['registration'] = $line['aircraft']; |
|
1153 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1154 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1155 | - if (isset($line['aircraftname'])) { |
|
1126 | + $data = array(); |
|
1127 | + //$data['id'] = $line['id']; // id not usable |
|
1128 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1129 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1130 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1131 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1132 | + $data['ident'] = $line['flightnum']; // ident |
|
1133 | + $data['altitude'] = $line['alt']; // altitude |
|
1134 | + $data['speed'] = $line['gs']; // speed |
|
1135 | + $data['heading'] = $line['heading']; // heading |
|
1136 | + $data['latitude'] = $line['lat']; // lat |
|
1137 | + $data['longitude'] = $line['lng']; // long |
|
1138 | + $data['verticalrate'] = ''; // verticale rate |
|
1139 | + $data['squawk'] = ''; // squawk |
|
1140 | + $data['emergency'] = ''; // emergency |
|
1141 | + //$data['datetime'] = $line['lastupdate']; |
|
1142 | + //$data['last_update'] = $line['lastupdate']; |
|
1143 | + if (isset($value['timezone'])) { |
|
1144 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1145 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1146 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1147 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1148 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1149 | + $data['departure_airport_time'] = $line['deptime']; |
|
1150 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1151 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1152 | + $data['registration'] = $line['aircraft']; |
|
1153 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1154 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1155 | + if (isset($line['aircraftname'])) { |
|
1156 | 1156 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1157 | 1157 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1158 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1159 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1160 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1161 | - else { |
|
1162 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1163 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1164 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1165 | - } |
|
1166 | - } |
|
1167 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1168 | - $data['id_source'] = $id_source; |
|
1169 | - $data['format_source'] = 'phpvmacars'; |
|
1170 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1171 | - $SI->add($data); |
|
1172 | - unset($data); |
|
1158 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1159 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1160 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1161 | + else { |
|
1162 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1163 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1164 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1165 | + } |
|
1166 | + } |
|
1167 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1168 | + $data['id_source'] = $id_source; |
|
1169 | + $data['format_source'] = 'phpvmacars'; |
|
1170 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1171 | + $SI->add($data); |
|
1172 | + unset($data); |
|
1173 | 1173 | } |
1174 | 1174 | if ($globalDebug) echo 'No more data...'."\n"; |
1175 | 1175 | unset($buffer); |
1176 | 1176 | unset($all_data); |
1177 | - } |
|
1178 | - //$last_exec['phpvmacars'] = time(); |
|
1179 | - $last_exec[$id]['last'] = time(); |
|
1177 | + } |
|
1178 | + //$last_exec['phpvmacars'] = time(); |
|
1179 | + $last_exec[$id]['last'] = time(); |
|
1180 | 1180 | } elseif ($value['format'] == 'vam' && |
1181 | - ( |
|
1181 | + ( |
|
1182 | 1182 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1183 | 1183 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1184 | - ) |
|
1184 | + ) |
|
1185 | 1185 | ) { |
1186 | - //$buffer = $Common->getData($hosts[$id]); |
|
1187 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1188 | - $buffer = $Common->getData($value['host']); |
|
1189 | - $all_data = json_decode($buffer,true); |
|
1190 | - if ($buffer != '' && is_array($all_data)) { |
|
1186 | + //$buffer = $Common->getData($hosts[$id]); |
|
1187 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1188 | + $buffer = $Common->getData($value['host']); |
|
1189 | + $all_data = json_decode($buffer,true); |
|
1190 | + if ($buffer != '' && is_array($all_data)) { |
|
1191 | 1191 | $reset = 0; |
1192 | 1192 | foreach ($all_data as $line) { |
1193 | - $data = array(); |
|
1194 | - //$data['id'] = $line['id']; // id not usable |
|
1195 | - $data['id'] = trim($line['flight_id']); |
|
1196 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1197 | - $data['pilot_name'] = $line['pilot_name']; |
|
1198 | - $data['pilot_id'] = $line['pilot_id']; |
|
1199 | - $data['ident'] = trim($line['callsign']); // ident |
|
1200 | - $data['altitude'] = $line['altitude']; // altitude |
|
1201 | - $data['speed'] = $line['gs']; // speed |
|
1202 | - $data['heading'] = $line['heading']; // heading |
|
1203 | - $data['latitude'] = $line['latitude']; // lat |
|
1204 | - $data['longitude'] = $line['longitude']; // long |
|
1205 | - $data['verticalrate'] = ''; // verticale rate |
|
1206 | - $data['squawk'] = ''; // squawk |
|
1207 | - $data['emergency'] = ''; // emergency |
|
1208 | - //$data['datetime'] = $line['lastupdate']; |
|
1209 | - $data['last_update'] = $line['last_update']; |
|
1210 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1211 | - $data['departure_airport_icao'] = $line['departure']; |
|
1212 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1213 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1214 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1215 | - //$data['registration'] = $line['aircraft']; |
|
1216 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1217 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1218 | - $data['id_source'] = $id_source; |
|
1219 | - $data['format_source'] = 'vam'; |
|
1220 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1222 | - $SI->add($data); |
|
1223 | - unset($data); |
|
1193 | + $data = array(); |
|
1194 | + //$data['id'] = $line['id']; // id not usable |
|
1195 | + $data['id'] = trim($line['flight_id']); |
|
1196 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1197 | + $data['pilot_name'] = $line['pilot_name']; |
|
1198 | + $data['pilot_id'] = $line['pilot_id']; |
|
1199 | + $data['ident'] = trim($line['callsign']); // ident |
|
1200 | + $data['altitude'] = $line['altitude']; // altitude |
|
1201 | + $data['speed'] = $line['gs']; // speed |
|
1202 | + $data['heading'] = $line['heading']; // heading |
|
1203 | + $data['latitude'] = $line['latitude']; // lat |
|
1204 | + $data['longitude'] = $line['longitude']; // long |
|
1205 | + $data['verticalrate'] = ''; // verticale rate |
|
1206 | + $data['squawk'] = ''; // squawk |
|
1207 | + $data['emergency'] = ''; // emergency |
|
1208 | + //$data['datetime'] = $line['lastupdate']; |
|
1209 | + $data['last_update'] = $line['last_update']; |
|
1210 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1211 | + $data['departure_airport_icao'] = $line['departure']; |
|
1212 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1213 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1214 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1215 | + //$data['registration'] = $line['aircraft']; |
|
1216 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1217 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1218 | + $data['id_source'] = $id_source; |
|
1219 | + $data['format_source'] = 'vam'; |
|
1220 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1221 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1222 | + $SI->add($data); |
|
1223 | + unset($data); |
|
1224 | 1224 | } |
1225 | 1225 | if ($globalDebug) echo 'No more data...'."\n"; |
1226 | 1226 | unset($buffer); |
1227 | 1227 | unset($all_data); |
1228 | - } |
|
1229 | - //$last_exec['phpvmacars'] = time(); |
|
1230 | - $last_exec[$id]['last'] = time(); |
|
1228 | + } |
|
1229 | + //$last_exec['phpvmacars'] = time(); |
|
1230 | + $last_exec[$id]['last'] = time(); |
|
1231 | 1231 | } elseif ($value['format'] == 'blitzortung' && |
1232 | - ( |
|
1232 | + ( |
|
1233 | 1233 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1234 | 1234 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1235 | - ) |
|
1235 | + ) |
|
1236 | 1236 | ) { |
1237 | - //$buffer = $Common->getData($hosts[$id]); |
|
1238 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1239 | - $buffer = $Common->getData($value['host']); |
|
1240 | - $all_data = json_decode($buffer,true); |
|
1241 | - if ($buffer != '') { |
|
1237 | + //$buffer = $Common->getData($hosts[$id]); |
|
1238 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1239 | + $buffer = $Common->getData($value['host']); |
|
1240 | + $all_data = json_decode($buffer,true); |
|
1241 | + if ($buffer != '') { |
|
1242 | 1242 | $Source->deleteLocationBySource('blitzortung'); |
1243 | 1243 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1244 | 1244 | $buffer = explode('\n',$buffer); |
1245 | 1245 | foreach ($buffer as $buffer_line) { |
1246 | - $line = json_decode($buffer_line,true); |
|
1247 | - if (isset($line['time'])) { |
|
1246 | + $line = json_decode($buffer_line,true); |
|
1247 | + if (isset($line['time'])) { |
|
1248 | 1248 | $data = array(); |
1249 | 1249 | $data['altitude'] = $line['alt']; // altitude |
1250 | 1250 | $data['latitude'] = $line['lat']; // lat |
@@ -1256,94 +1256,94 @@ discard block |
||
1256 | 1256 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1257 | 1257 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1258 | 1258 | unset($data); |
1259 | - } |
|
1259 | + } |
|
1260 | 1260 | } |
1261 | 1261 | if ($globalDebug) echo 'No more data...'."\n"; |
1262 | 1262 | unset($buffer); |
1263 | - } |
|
1264 | - $last_exec[$id]['last'] = time(); |
|
1263 | + } |
|
1264 | + $last_exec[$id]['last'] = time(); |
|
1265 | 1265 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1266 | 1266 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1267 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1268 | - //$last_exec[$id]['last'] = time(); |
|
1267 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1268 | + //$last_exec[$id]['last'] = time(); |
|
1269 | 1269 | |
1270 | - //$read = array( $sockets[$id] ); |
|
1271 | - $read = $sockets; |
|
1272 | - $write = NULL; |
|
1273 | - $e = NULL; |
|
1274 | - $n = socket_select($read, $write, $e, $timeout); |
|
1275 | - if ($e != NULL) var_dump($e); |
|
1276 | - if ($n > 0) { |
|
1270 | + //$read = array( $sockets[$id] ); |
|
1271 | + $read = $sockets; |
|
1272 | + $write = NULL; |
|
1273 | + $e = NULL; |
|
1274 | + $n = socket_select($read, $write, $e, $timeout); |
|
1275 | + if ($e != NULL) var_dump($e); |
|
1276 | + if ($n > 0) { |
|
1277 | 1277 | $reset = 0; |
1278 | 1278 | foreach ($read as $nb => $r) { |
1279 | - //$value = $formats[$nb]; |
|
1280 | - $format = $globalSources[$nb]['format']; |
|
1281 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1279 | + //$value = $formats[$nb]; |
|
1280 | + $format = $globalSources[$nb]['format']; |
|
1281 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1282 | 1282 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1283 | - } elseif ($format == 'vrstcp') { |
|
1283 | + } elseif ($format == 'vrstcp') { |
|
1284 | 1284 | $buffer = @socket_read($r, 6000); |
1285 | - } else { |
|
1285 | + } else { |
|
1286 | 1286 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1287 | - } |
|
1288 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1289 | - //echo $buffer."\n"; |
|
1290 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1291 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1292 | - $error = false; |
|
1293 | - //$SI::del(); |
|
1294 | - if ($format == 'vrstcp') { |
|
1287 | + } |
|
1288 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1289 | + //echo $buffer."\n"; |
|
1290 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1291 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1292 | + $error = false; |
|
1293 | + //$SI::del(); |
|
1294 | + if ($format == 'vrstcp') { |
|
1295 | 1295 | $buffer = explode('},{',$buffer); |
1296 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1297 | - // SBS format is CSV format |
|
1298 | - if ($buffer !== FALSE && $buffer != '') { |
|
1296 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1297 | + // SBS format is CSV format |
|
1298 | + if ($buffer !== FALSE && $buffer != '') { |
|
1299 | 1299 | $tt[$format] = 0; |
1300 | 1300 | if ($format == 'acarssbs3') { |
1301 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1302 | - $ACARS->add(trim($buffer)); |
|
1303 | - $ACARS->deleteLiveAcarsData(); |
|
1301 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1302 | + $ACARS->add(trim($buffer)); |
|
1303 | + $ACARS->deleteLiveAcarsData(); |
|
1304 | 1304 | } elseif ($format == 'raw') { |
1305 | - // AVR format |
|
1306 | - $data = $SBS->parse($buffer); |
|
1307 | - if (is_array($data)) { |
|
1305 | + // AVR format |
|
1306 | + $data = $SBS->parse($buffer); |
|
1307 | + if (is_array($data)) { |
|
1308 | 1308 | $data['datetime'] = date('Y-m-d H:i:s'); |
1309 | 1309 | $data['format_source'] = 'raw'; |
1310 | 1310 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1311 | 1311 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1312 | 1312 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1313 | 1313 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1314 | - } |
|
1314 | + } |
|
1315 | 1315 | } elseif ($format == 'ais') { |
1316 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1317 | - $data = array(); |
|
1318 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1319 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1320 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1321 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1322 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1323 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1324 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1325 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1326 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1327 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1328 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1329 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1330 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1331 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1332 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1333 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1316 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1317 | + $data = array(); |
|
1318 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1319 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1320 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1321 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1322 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1323 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1324 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1325 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1326 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1327 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1328 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1329 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1330 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1331 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1332 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1333 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1334 | 1334 | |
1335 | - if (isset($ais_data['timestamp'])) { |
|
1335 | + if (isset($ais_data['timestamp'])) { |
|
1336 | 1336 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1337 | - } else { |
|
1337 | + } else { |
|
1338 | 1338 | $data['datetime'] = date('Y-m-d H:i:s'); |
1339 | - } |
|
1340 | - $data['format_source'] = 'aisnmea'; |
|
1341 | - $data['id_source'] = $id_source; |
|
1342 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1343 | - unset($data); |
|
1344 | - } elseif ($format == 'flightgearsp') { |
|
1345 | - //echo $buffer."\n"; |
|
1346 | - if (strlen($buffer) > 5) { |
|
1339 | + } |
|
1340 | + $data['format_source'] = 'aisnmea'; |
|
1341 | + $data['id_source'] = $id_source; |
|
1342 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1343 | + unset($data); |
|
1344 | + } elseif ($format == 'flightgearsp') { |
|
1345 | + //echo $buffer."\n"; |
|
1346 | + if (strlen($buffer) > 5) { |
|
1347 | 1347 | $line = explode(',',$buffer); |
1348 | 1348 | $data = array(); |
1349 | 1349 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1360,38 +1360,38 @@ discard block |
||
1360 | 1360 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1361 | 1361 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1362 | 1362 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1363 | - } |
|
1364 | - } elseif ($format == 'acars') { |
|
1365 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1366 | - $ACARS->add(trim($buffer)); |
|
1367 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1368 | - $ACARS->deleteLiveAcarsData(); |
|
1363 | + } |
|
1364 | + } elseif ($format == 'acars') { |
|
1365 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1366 | + $ACARS->add(trim($buffer)); |
|
1367 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1368 | + $ACARS->deleteLiveAcarsData(); |
|
1369 | 1369 | } elseif ($format == 'flightgearmp') { |
1370 | - if (substr($buffer,0,1) != '#') { |
|
1370 | + if (substr($buffer,0,1) != '#') { |
|
1371 | 1371 | $data = array(); |
1372 | 1372 | //echo $buffer."\n"; |
1373 | 1373 | $line = explode(' ',$buffer); |
1374 | 1374 | if (count($line) == 11) { |
1375 | - $userserver = explode('@',$line[0]); |
|
1376 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1377 | - $data['ident'] = $userserver[0]; |
|
1378 | - $data['registration'] = $userserver[0]; |
|
1379 | - $data['latitude'] = $line[4]; |
|
1380 | - $data['longitude'] = $line[5]; |
|
1381 | - $data['altitude'] = $line[6]; |
|
1382 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1383 | - $aircraft_type = $line[10]; |
|
1384 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1385 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1386 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1387 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1375 | + $userserver = explode('@',$line[0]); |
|
1376 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1377 | + $data['ident'] = $userserver[0]; |
|
1378 | + $data['registration'] = $userserver[0]; |
|
1379 | + $data['latitude'] = $line[4]; |
|
1380 | + $data['longitude'] = $line[5]; |
|
1381 | + $data['altitude'] = $line[6]; |
|
1382 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1383 | + $aircraft_type = $line[10]; |
|
1384 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1385 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1386 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1387 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1388 | + } |
|
1388 | 1389 | } |
1389 | - } |
|
1390 | 1390 | } elseif ($format == 'beast') { |
1391 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1392 | - die; |
|
1391 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1392 | + die; |
|
1393 | 1393 | } elseif ($format == 'vrstcp') { |
1394 | - foreach($buffer as $all_data) { |
|
1394 | + foreach($buffer as $all_data) { |
|
1395 | 1395 | $line = json_decode('{'.$all_data.'}',true); |
1396 | 1396 | $data = array(); |
1397 | 1397 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1411,148 +1411,148 @@ discard block |
||
1411 | 1411 | */ |
1412 | 1412 | $data['datetime'] = date('Y-m-d H:i:s'); |
1413 | 1413 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1414 | - $data['format_source'] = 'vrstcp'; |
|
1414 | + $data['format_source'] = 'vrstcp'; |
|
1415 | 1415 | $data['id_source'] = $id_source; |
1416 | 1416 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1417 | 1417 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1418 | 1418 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1419 | 1419 | unset($data); |
1420 | - } |
|
1420 | + } |
|
1421 | 1421 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1422 | - $line = explode("\t", $buffer); |
|
1423 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1422 | + $line = explode("\t", $buffer); |
|
1423 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1424 | 1424 | $key = $line[$k]; |
1425 | - $lined[$key] = $line[$k+1]; |
|
1426 | - } |
|
1427 | - if (count($lined) > 3) { |
|
1428 | - $data['hex'] = $lined['hexid']; |
|
1429 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1430 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1431 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1432 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1433 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1434 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1435 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1436 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1437 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1438 | - $data['id_source'] = $id_source; |
|
1439 | - $data['format_source'] = 'tsv'; |
|
1440 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1441 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1425 | + $lined[$key] = $line[$k+1]; |
|
1426 | + } |
|
1427 | + if (count($lined) > 3) { |
|
1428 | + $data['hex'] = $lined['hexid']; |
|
1429 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1430 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1431 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1432 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1433 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1434 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1435 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1436 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1437 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1438 | + $data['id_source'] = $id_source; |
|
1439 | + $data['format_source'] = 'tsv'; |
|
1440 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1441 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1442 | 1442 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1443 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1444 | - unset($lined); |
|
1445 | - unset($data); |
|
1446 | - } else $error = true; |
|
1443 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1444 | + unset($lined); |
|
1445 | + unset($data); |
|
1446 | + } else $error = true; |
|
1447 | 1447 | } elseif ($format == 'aprs' && $use_aprs) { |
1448 | - if ($aprs_connect == 0) { |
|
1448 | + if ($aprs_connect == 0) { |
|
1449 | 1449 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1450 | 1450 | $aprs_connect = 1; |
1451 | - } |
|
1451 | + } |
|
1452 | 1452 | |
1453 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1453 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1454 | 1454 | $aprs_last_tx = time(); |
1455 | 1455 | $data_aprs = "# Keep alive"; |
1456 | 1456 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1457 | - } |
|
1457 | + } |
|
1458 | 1458 | |
1459 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1460 | - //echo 'APRS data : '.$buffer."\n"; |
|
1461 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1462 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1463 | - //echo $buffer."\n"; |
|
1464 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1459 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1460 | + //echo 'APRS data : '.$buffer."\n"; |
|
1461 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1462 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1463 | + //echo $buffer."\n"; |
|
1464 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1465 | 1465 | $line = $APRS->parse($buffer); |
1466 | 1466 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1467 | 1467 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1468 | - $aprs_last_tx = time(); |
|
1469 | - $data = array(); |
|
1470 | - //print_r($line); |
|
1471 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1472 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1473 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1474 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1475 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1476 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1477 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1478 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1479 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1480 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1481 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1482 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1483 | - $data['latitude'] = $line['latitude']; |
|
1484 | - $data['longitude'] = $line['longitude']; |
|
1485 | - //$data['verticalrate'] = $line[16]; |
|
1486 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1487 | - //else $data['speed'] = 0; |
|
1488 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1489 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1490 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1491 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1492 | - //else $data['heading'] = 0; |
|
1493 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1494 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1495 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1496 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1497 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1498 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1499 | - $data['id_source'] = $id_source; |
|
1500 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1501 | - else $data['format_source'] = 'aprs'; |
|
1502 | - $data['source_name'] = $line['source']; |
|
1503 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1504 | - else $data['source_type'] = 'flarm'; |
|
1505 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1506 | - $currentdate = date('Y-m-d H:i:s'); |
|
1507 | - $aprsdate = strtotime($data['datetime']); |
|
1508 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1509 | - // Accept data if time <= system time + 20s |
|
1510 | - //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'])))) { |
|
1511 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1468 | + $aprs_last_tx = time(); |
|
1469 | + $data = array(); |
|
1470 | + //print_r($line); |
|
1471 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1472 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1473 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1474 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1475 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1476 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1477 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1478 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1479 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1480 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1481 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1482 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1483 | + $data['latitude'] = $line['latitude']; |
|
1484 | + $data['longitude'] = $line['longitude']; |
|
1485 | + //$data['verticalrate'] = $line[16]; |
|
1486 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1487 | + //else $data['speed'] = 0; |
|
1488 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1489 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1490 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1491 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1492 | + //else $data['heading'] = 0; |
|
1493 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1494 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1495 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1496 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1497 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1498 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1499 | + $data['id_source'] = $id_source; |
|
1500 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1501 | + else $data['format_source'] = 'aprs'; |
|
1502 | + $data['source_name'] = $line['source']; |
|
1503 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1504 | + else $data['source_type'] = 'flarm'; |
|
1505 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1506 | + $currentdate = date('Y-m-d H:i:s'); |
|
1507 | + $aprsdate = strtotime($data['datetime']); |
|
1508 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1509 | + // Accept data if time <= system time + 20s |
|
1510 | + //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'])))) { |
|
1511 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1512 | 1512 | $send = $SI->add($data); |
1513 | - } elseif ($data['source_type'] == 'ais') { |
|
1513 | + } elseif ($data['source_type'] == 'ais') { |
|
1514 | 1514 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1515 | - } elseif (isset($line['stealth'])) { |
|
1515 | + } elseif (isset($line['stealth'])) { |
|
1516 | 1516 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1517 | 1517 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1518 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1519 | - //$line['symbol'] == 'Balloon' || |
|
1520 | - $line['symbol'] == 'Glider' || |
|
1521 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1522 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1523 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1524 | - $send = $SI->add($data); |
|
1525 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1526 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1527 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1528 | - $send = $MI->add($data); |
|
1529 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1530 | - $line['symbol'] == 'Car' || |
|
1531 | - $line['symbol'] == 'Ambulance' || |
|
1532 | - $line['symbol'] == 'Van' || |
|
1533 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1534 | - $line['symbol'] == 'Motorcycle' || |
|
1535 | - $line['symbol'] == 'Tractor' || |
|
1536 | - $line['symbol'] == 'Police' || |
|
1537 | - $line['symbol'] == 'Bike' || |
|
1538 | - $line['symbol'] == 'Jogger' || |
|
1539 | - $line['symbol'] == 'Horse' || |
|
1540 | - $line['symbol'] == 'Bus' || |
|
1541 | - $line['symbol'] == 'Jeep' || |
|
1542 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1543 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1544 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1545 | - $line['symbol'] == 'Firetruck' || |
|
1546 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1547 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1548 | - $line['symbol'] == 'SUV' || |
|
1549 | - $line['symbol'] == 'Snowmobile' || |
|
1550 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1551 | - //} 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') { |
|
1518 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1519 | + //$line['symbol'] == 'Balloon' || |
|
1520 | + $line['symbol'] == 'Glider' || |
|
1521 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1522 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1523 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1524 | + $send = $SI->add($data); |
|
1525 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1526 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1527 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1528 | + $send = $MI->add($data); |
|
1529 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1530 | + $line['symbol'] == 'Car' || |
|
1531 | + $line['symbol'] == 'Ambulance' || |
|
1532 | + $line['symbol'] == 'Van' || |
|
1533 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1534 | + $line['symbol'] == 'Motorcycle' || |
|
1535 | + $line['symbol'] == 'Tractor' || |
|
1536 | + $line['symbol'] == 'Police' || |
|
1537 | + $line['symbol'] == 'Bike' || |
|
1538 | + $line['symbol'] == 'Jogger' || |
|
1539 | + $line['symbol'] == 'Horse' || |
|
1540 | + $line['symbol'] == 'Bus' || |
|
1541 | + $line['symbol'] == 'Jeep' || |
|
1542 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1543 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1544 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1545 | + $line['symbol'] == 'Firetruck' || |
|
1546 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1547 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1548 | + $line['symbol'] == 'SUV' || |
|
1549 | + $line['symbol'] == 'Snowmobile' || |
|
1550 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1551 | + //} 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') { |
|
1552 | 1552 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $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') { |
1553 | 1553 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1554 | 1554 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1555 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1555 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1556 | 1556 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1557 | 1557 | $Source->deleteOldLocationByType('gs'); |
1558 | 1558 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1560,7 +1560,7 @@ discard block |
||
1560 | 1560 | } else { |
1561 | 1561 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1562 | 1562 | } |
1563 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1563 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1564 | 1564 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1565 | 1565 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1566 | 1566 | $Source->deleteOldLocationByType('wx'); |
@@ -1570,7 +1570,7 @@ discard block |
||
1570 | 1570 | } else { |
1571 | 1571 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1572 | 1572 | } |
1573 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1573 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1574 | 1574 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1575 | 1575 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1576 | 1576 | $Source->deleteOldLocationByType('lightning'); |
@@ -1579,11 +1579,11 @@ discard block |
||
1579 | 1579 | } else { |
1580 | 1580 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1581 | 1581 | } |
1582 | - } elseif ($globalDebug) { |
|
1583 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1584 | - print_r($line); |
|
1585 | - } |
|
1586 | - unset($data); |
|
1582 | + } elseif ($globalDebug) { |
|
1583 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1584 | + print_r($line); |
|
1585 | + } |
|
1586 | + unset($data); |
|
1587 | 1587 | } |
1588 | 1588 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1589 | 1589 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1602,12 +1602,12 @@ discard block |
||
1602 | 1602 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1603 | 1603 | $globalSources[$nb]['last_weather_clean'] = time(); |
1604 | 1604 | } |
1605 | - } |
|
1605 | + } |
|
1606 | 1606 | } else { |
1607 | - $line = explode(',', $buffer); |
|
1608 | - if (count($line) > 20) { |
|
1609 | - $data['hex'] = $line[4]; |
|
1610 | - /* |
|
1607 | + $line = explode(',', $buffer); |
|
1608 | + if (count($line) > 20) { |
|
1609 | + $data['hex'] = $line[4]; |
|
1610 | + /* |
|
1611 | 1611 | $data['datetime'] = $line[6].' '.$line[7]; |
1612 | 1612 | date_default_timezone_set($globalTimezone); |
1613 | 1613 | $datetime = new DateTime($data['datetime']); |
@@ -1615,30 +1615,30 @@ discard block |
||
1615 | 1615 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1616 | 1616 | date_default_timezone_set('UTC'); |
1617 | 1617 | */ |
1618 | - // Force datetime to current UTC datetime |
|
1619 | - date_default_timezone_set('UTC'); |
|
1620 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1621 | - $data['ident'] = trim($line[10]); |
|
1622 | - $data['latitude'] = $line[14]; |
|
1623 | - $data['longitude'] = $line[15]; |
|
1624 | - $data['verticalrate'] = $line[16]; |
|
1625 | - $data['emergency'] = $line[20]; |
|
1626 | - $data['speed'] = $line[12]; |
|
1627 | - $data['squawk'] = $line[17]; |
|
1628 | - $data['altitude'] = $line[11]; |
|
1629 | - $data['heading'] = $line[13]; |
|
1630 | - $data['ground'] = $line[21]; |
|
1631 | - $data['emergency'] = $line[19]; |
|
1632 | - $data['format_source'] = 'sbs'; |
|
1618 | + // Force datetime to current UTC datetime |
|
1619 | + date_default_timezone_set('UTC'); |
|
1620 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1621 | + $data['ident'] = trim($line[10]); |
|
1622 | + $data['latitude'] = $line[14]; |
|
1623 | + $data['longitude'] = $line[15]; |
|
1624 | + $data['verticalrate'] = $line[16]; |
|
1625 | + $data['emergency'] = $line[20]; |
|
1626 | + $data['speed'] = $line[12]; |
|
1627 | + $data['squawk'] = $line[17]; |
|
1628 | + $data['altitude'] = $line[11]; |
|
1629 | + $data['heading'] = $line[13]; |
|
1630 | + $data['ground'] = $line[21]; |
|
1631 | + $data['emergency'] = $line[19]; |
|
1632 | + $data['format_source'] = 'sbs'; |
|
1633 | 1633 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1634 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1634 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1635 | 1635 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1636 | - $data['id_source'] = $id_source; |
|
1637 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1638 | - else $error = true; |
|
1639 | - unset($data); |
|
1640 | - } else $error = true; |
|
1641 | - if ($error) { |
|
1636 | + $data['id_source'] = $id_source; |
|
1637 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1638 | + else $error = true; |
|
1639 | + unset($data); |
|
1640 | + } else $error = true; |
|
1641 | + if ($error) { |
|
1642 | 1642 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1643 | 1643 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1644 | 1644 | } else { |
@@ -1654,13 +1654,13 @@ discard block |
||
1654 | 1654 | connect_all($sourceer); |
1655 | 1655 | $sourceer = array(); |
1656 | 1656 | } |
1657 | - } |
|
1657 | + } |
|
1658 | 1658 | } |
1659 | 1659 | // Sleep for xxx microseconds |
1660 | 1660 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1661 | - } else { |
|
1661 | + } else { |
|
1662 | 1662 | if ($format == 'flightgearmp') { |
1663 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1663 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1664 | 1664 | //@socket_close($r); |
1665 | 1665 | sleep($globalMinFetch); |
1666 | 1666 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1669,9 +1669,9 @@ discard block |
||
1669 | 1669 | break; |
1670 | 1670 | |
1671 | 1671 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1672 | - if (isset($tt[$format])) $tt[$format]++; |
|
1673 | - else $tt[$format] = 0; |
|
1674 | - if ($tt[$format] > 30) { |
|
1672 | + if (isset($tt[$format])) $tt[$format]++; |
|
1673 | + else $tt[$format] = 0; |
|
1674 | + if ($tt[$format] > 30) { |
|
1675 | 1675 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1676 | 1676 | //@socket_close($r); |
1677 | 1677 | sleep(2); |
@@ -1682,23 +1682,23 @@ discard block |
||
1682 | 1682 | //connect_all($globalSources); |
1683 | 1683 | $tt[$format]=0; |
1684 | 1684 | break; |
1685 | - } |
|
1685 | + } |
|
1686 | + } |
|
1686 | 1687 | } |
1687 | - } |
|
1688 | 1688 | } |
1689 | - } else { |
|
1689 | + } else { |
|
1690 | 1690 | $error = socket_strerror(socket_last_error()); |
1691 | 1691 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1692 | 1692 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1693 | 1693 | if (isset($globalDebug)) echo "Restarting...\n"; |
1694 | 1694 | // Restart the script if possible |
1695 | 1695 | if (is_array($sockets)) { |
1696 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1696 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1697 | 1697 | |
1698 | - foreach ($sockets as $sock) { |
|
1698 | + foreach ($sockets as $sock) { |
|
1699 | 1699 | @socket_shutdown($sock,2); |
1700 | 1700 | @socket_close($sock); |
1701 | - } |
|
1701 | + } |
|
1702 | 1702 | |
1703 | 1703 | } |
1704 | 1704 | if ($globalDebug) echo "Waiting..."; |
@@ -1713,15 +1713,15 @@ discard block |
||
1713 | 1713 | if ($globalDebug) echo "Restart all connections..."; |
1714 | 1714 | connect_all($globalSources); |
1715 | 1715 | } |
1716 | - } |
|
1716 | + } |
|
1717 | 1717 | } |
1718 | 1718 | if ($globalDaemon === false) { |
1719 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1720 | - if (isset($SI)) $SI->checkAll(); |
|
1721 | - if (isset($TI)) $TI->checkAll(); |
|
1722 | - if (isset($MI)) $MI->checkAll(); |
|
1719 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1720 | + if (isset($SI)) $SI->checkAll(); |
|
1721 | + if (isset($TI)) $TI->checkAll(); |
|
1722 | + if (isset($MI)) $MI->checkAll(); |
|
1723 | + } |
|
1723 | 1724 | } |
1724 | - } |
|
1725 | 1725 | } |
1726 | 1726 | |
1727 | 1727 | ?> |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | } |
20 | 20 | } |
21 | 21 | /** |
22 | - * Change IATA to ICAO value for ident |
|
23 | - * |
|
24 | - * @param String $ident ident |
|
25 | - * @return String the icao |
|
26 | - */ |
|
22 | + * Change IATA to ICAO value for ident |
|
23 | + * |
|
24 | + * @param String $ident ident |
|
25 | + * @return String the icao |
|
26 | + */ |
|
27 | 27 | public function ident2icao($ident) { |
28 | 28 | if (substr($ident,0,2) == 'AF') { |
29 | 29 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Deletes all info in the live table |
|
43 | - * |
|
44 | - * @return String success or false |
|
45 | - * |
|
46 | - */ |
|
42 | + * Deletes all info in the live table |
|
43 | + * |
|
44 | + * @return String success or false |
|
45 | + * |
|
46 | + */ |
|
47 | 47 | public function deleteLiveAcarsData() |
48 | 48 | { |
49 | 49 | global $globalDBdriver; |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * Deletes all info in the archive table |
|
67 | - * |
|
68 | - * @return String success or false |
|
69 | - * |
|
70 | - */ |
|
66 | + * Deletes all info in the archive table |
|
67 | + * |
|
68 | + * @return String success or false |
|
69 | + * |
|
70 | + */ |
|
71 | 71 | public function deleteArchiveAcarsData() |
72 | 72 | { |
73 | 73 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | |
90 | 90 | /** |
91 | - * Parse ACARS data |
|
92 | - * |
|
93 | - * @param String ACARS data in acarsdec data |
|
94 | - * |
|
95 | - */ |
|
91 | + * Parse ACARS data |
|
92 | + * |
|
93 | + * @param String ACARS data in acarsdec data |
|
94 | + * |
|
95 | + */ |
|
96 | 96 | public function parse($data) { |
97 | 97 | global $globalDebug, $globalACARSArchive; |
98 | 98 | //$Image = new Image($this->db); |
@@ -722,11 +722,11 @@ discard block |
||
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
725 | - * Add ACARS data |
|
726 | - * |
|
727 | - * @param String ACARS data in acarsdec data |
|
728 | - * |
|
729 | - */ |
|
725 | + * Add ACARS data |
|
726 | + * |
|
727 | + * @param String ACARS data in acarsdec data |
|
728 | + * |
|
729 | + */ |
|
730 | 730 | function add($data) { |
731 | 731 | global $globalDebug, $globalACARSArchive; |
732 | 732 | $Image = new Image($this->db); |
@@ -773,15 +773,15 @@ discard block |
||
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
776 | - * Add Live ACARS data in DB |
|
777 | - * |
|
778 | - * @param String $ident ident |
|
779 | - * @param String $registration Registration of the aircraft |
|
780 | - * @param String $label Label of the ACARS message |
|
781 | - * @param String $block_id Block id of the ACARS message |
|
782 | - * @param String $msg_no Number of the ACARS message |
|
783 | - * @param String $message ACARS message |
|
784 | - */ |
|
776 | + * Add Live ACARS data in DB |
|
777 | + * |
|
778 | + * @param String $ident ident |
|
779 | + * @param String $registration Registration of the aircraft |
|
780 | + * @param String $label Label of the ACARS message |
|
781 | + * @param String $block_id Block id of the ACARS message |
|
782 | + * @param String $msg_no Number of the ACARS message |
|
783 | + * @param String $message ACARS message |
|
784 | + */ |
|
785 | 785 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
786 | 786 | global $globalDebug; |
787 | 787 | date_default_timezone_set('UTC'); |
@@ -817,15 +817,15 @@ discard block |
||
817 | 817 | } |
818 | 818 | |
819 | 819 | /** |
820 | - * Add Archive ACARS data in DB |
|
821 | - * |
|
822 | - * @param String $ident ident |
|
823 | - * @param String $registration Registration of the aircraft |
|
824 | - * @param String $label Label of the ACARS message |
|
825 | - * @param String $block_id Block id of the ACARS message |
|
826 | - * @param String $msg_no Number of the ACARS message |
|
827 | - * @param String $message ACARS message |
|
828 | - */ |
|
820 | + * Add Archive ACARS data in DB |
|
821 | + * |
|
822 | + * @param String $ident ident |
|
823 | + * @param String $registration Registration of the aircraft |
|
824 | + * @param String $label Label of the ACARS message |
|
825 | + * @param String $block_id Block id of the ACARS message |
|
826 | + * @param String $msg_no Number of the ACARS message |
|
827 | + * @param String $message ACARS message |
|
828 | + */ |
|
829 | 829 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
830 | 830 | global $globalDebug; |
831 | 831 | date_default_timezone_set('UTC'); |
@@ -856,11 +856,11 @@ discard block |
||
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
859 | - * Get Message title from label from DB |
|
860 | - * |
|
861 | - * @param String $label |
|
862 | - * @return String Return ACARS title |
|
863 | - */ |
|
859 | + * Get Message title from label from DB |
|
860 | + * |
|
861 | + * @param String $label |
|
862 | + * @return String Return ACARS title |
|
863 | + */ |
|
864 | 864 | public function getTitlefromLabel($label) { |
865 | 865 | $Connection = new Connection($this->db); |
866 | 866 | $this->db = $Connection->db; |
@@ -879,10 +879,10 @@ discard block |
||
879 | 879 | } |
880 | 880 | |
881 | 881 | /** |
882 | - * List all Message title & label from DB |
|
883 | - * |
|
884 | - * @return Array Return ACARS data in array |
|
885 | - */ |
|
882 | + * List all Message title & label from DB |
|
883 | + * |
|
884 | + * @return Array Return ACARS data in array |
|
885 | + */ |
|
886 | 886 | public function getAllTitleLabel() { |
887 | 887 | $query = "SELECT * FROM acars_label ORDER BY title"; |
888 | 888 | $query_values = array(); |
@@ -899,11 +899,11 @@ discard block |
||
899 | 899 | } |
900 | 900 | |
901 | 901 | /** |
902 | - * Get Live ACARS data from DB |
|
903 | - * |
|
904 | - * @param String $ident |
|
905 | - * @return Array Return ACARS data in array |
|
906 | - */ |
|
902 | + * Get Live ACARS data from DB |
|
903 | + * |
|
904 | + * @param String $ident |
|
905 | + * @return Array Return ACARS data in array |
|
906 | + */ |
|
907 | 907 | public function getLiveAcarsData($ident) { |
908 | 908 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
909 | 909 | $query_values = array(':ident' => $ident); |
@@ -920,10 +920,10 @@ discard block |
||
920 | 920 | } |
921 | 921 | |
922 | 922 | /** |
923 | - * Get Latest ACARS data from DB |
|
924 | - * |
|
925 | - * @return Array Return ACARS data in array |
|
926 | - */ |
|
923 | + * Get Latest ACARS data from DB |
|
924 | + * |
|
925 | + * @return Array Return ACARS data in array |
|
926 | + */ |
|
927 | 927 | public function getLatestAcarsData($limit = '',$label = '') { |
928 | 928 | global $globalURL, $globalDBdriver; |
929 | 929 | $Image = new Image($this->db); |
@@ -1011,10 +1011,10 @@ discard block |
||
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | /** |
1014 | - * Get Archive ACARS data from DB |
|
1015 | - * |
|
1016 | - * @return Array Return ACARS data in array |
|
1017 | - */ |
|
1014 | + * Get Archive ACARS data from DB |
|
1015 | + * |
|
1016 | + * @return Array Return ACARS data in array |
|
1017 | + */ |
|
1018 | 1018 | public function getArchiveAcarsData($limit = '',$label = '') { |
1019 | 1019 | global $globalURL, $globalDBdriver; |
1020 | 1020 | $Image = new Image($this->db); |
@@ -1102,13 +1102,13 @@ discard block |
||
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | /** |
1105 | - * Add ModeS data to DB |
|
1106 | - * |
|
1107 | - * @param String $ident ident |
|
1108 | - * @param String $registration Registration of the aircraft |
|
1109 | - * @param String $icao |
|
1110 | - * @param String $ICAOTypeCode |
|
1111 | - */ |
|
1105 | + * Add ModeS data to DB |
|
1106 | + * |
|
1107 | + * @param String $ident ident |
|
1108 | + * @param String $registration Registration of the aircraft |
|
1109 | + * @param String $icao |
|
1110 | + * @param String $ICAOTypeCode |
|
1111 | + */ |
|
1112 | 1112 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
1113 | 1113 | global $globalDebug, $globalDBdriver; |
1114 | 1114 | $ident = trim($ident); |
@@ -322,14 +322,14 @@ discard block |
||
322 | 322 | </tr> |
323 | 323 | <!-- |
324 | 324 | <?php |
325 | - if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') { |
|
326 | - require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
327 | - $Connection = new Connection(); |
|
325 | + if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') { |
|
326 | + require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
327 | + $Connection = new Connection(); |
|
328 | 328 | ?> |
329 | 329 | --> |
330 | 330 | <?php |
331 | 331 | if ($Connection->db != NULL) { |
332 | - if ($Connection->tableExists('source_location')) { |
|
332 | + if ($Connection->tableExists('source_location')) { |
|
333 | 333 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
334 | 334 | $Source = new Source(); |
335 | 335 | //$alllocations = $Source->getAllLocationInfo(); |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | |
350 | 350 | <?php |
351 | 351 | } |
352 | - } |
|
352 | + } |
|
353 | + } |
|
353 | 354 | } |
354 | - } |
|
355 | 355 | ?> |
356 | 356 | |
357 | 357 | <tr> |
@@ -461,12 +461,12 @@ discard block |
||
461 | 461 | ?> |
462 | 462 | <tr> |
463 | 463 | <?php |
464 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
464 | + if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
465 | 465 | ?> |
466 | 466 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
467 | 467 | <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
468 | 468 | <?php |
469 | - } else { |
|
469 | + } else { |
|
470 | 470 | $hostport = explode(':',$source['host']); |
471 | 471 | if (isset($hostport[1])) { |
472 | 472 | $host = $hostport[0]; |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | <td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td> |
480 | 480 | <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td> |
481 | 481 | <?php |
482 | - } |
|
482 | + } |
|
483 | 483 | ?> |
484 | 484 | <td> |
485 | 485 | <select name="format[]" id="format"> |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | <br /> |
894 | 894 | <p> |
895 | 895 | <?php |
896 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
896 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
897 | 897 | ?> |
898 | 898 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
899 | 899 | <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
@@ -903,11 +903,11 @@ discard block |
||
903 | 903 | <b>The directory cache is not writable, aircraft icon will not be cached</b> |
904 | 904 | <?php |
905 | 905 | } |
906 | - } else { |
|
906 | + } else { |
|
907 | 907 | ?> |
908 | 908 | <b>PHP GD is not installed, you can't change color of aircraft icon on map</b> |
909 | 909 | <?php |
910 | - } |
|
910 | + } |
|
911 | 911 | ?> |
912 | 912 | </p> |
913 | 913 | <br /> |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | </p> |
932 | 932 | <?php |
933 | 933 | require('../footer.php'); |
934 | - exit; |
|
934 | + exit; |
|
935 | 935 | } |
936 | 936 | // ' |
937 | 937 | $settings = array(); |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | |
1023 | 1023 | $sources = array(); |
1024 | 1024 | foreach ($source_name as $keys => $name) { |
1025 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1026 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1025 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1026 | + else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1027 | 1027 | } |
1028 | 1028 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
1029 | 1029 | |
@@ -1408,14 +1408,14 @@ discard block |
||
1408 | 1408 | |
1409 | 1409 | // Set some defaults values... |
1410 | 1410 | if (!isset($globalAircraftImageSources)) { |
1411 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1412 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1411 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1412 | + $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | if (!isset($globalSchedulesSources)) { |
1416 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1417 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1418 | - } |
|
1416 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1417 | + $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1418 | + } |
|
1419 | 1419 | |
1420 | 1420 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1421 | 1421 | |
@@ -1462,21 +1462,21 @@ discard block |
||
1462 | 1462 | $popi = false; |
1463 | 1463 | $popw = false; |
1464 | 1464 | foreach ($_SESSION['done'] as $done) { |
1465 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1466 | - if ($done == 'Create database') $pop = true; |
|
1467 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1468 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1469 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1465 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1466 | + if ($done == 'Create database') $pop = true; |
|
1467 | + if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1468 | + if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1469 | + if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1470 | 1470 | } |
1471 | 1471 | if ($pop) { |
1472 | - sleep(5); |
|
1473 | - print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1472 | + sleep(5); |
|
1473 | + print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1474 | 1474 | } else if ($popi) { |
1475 | - sleep(5); |
|
1476 | - print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1475 | + sleep(5); |
|
1476 | + print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1477 | 1477 | } else if ($popw) { |
1478 | - sleep(5); |
|
1479 | - print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1478 | + sleep(5); |
|
1479 | + print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1480 | 1480 | } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
1481 | 1481 | print '</div></ul>'; |
1482 | 1482 | print '<div id="error"></div>'; |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | unset($_COOKIE['install']); |
1540 | 1540 | print '<div class="info column"><ul>'; |
1541 | 1541 | foreach ($_SESSION['done'] as $done) { |
1542 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1542 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1543 | 1543 | } |
1544 | 1544 | print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>'; |
1545 | 1545 | print '</ul></div>'; |
@@ -1,49 +1,49 @@ |
||
1 | 1 | #!/usr/bin/php |
2 | 2 | <?php |
3 | - require_once('../require/settings.php'); |
|
4 | - if ($globalInstalled) { |
|
5 | - //echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
6 | - echo "Use install/index.php instead. You really don't want to use this."; |
|
7 | - exit; |
|
8 | - } |
|
9 | - require('class.update_db.php'); |
|
10 | - echo "Populate all tables...\n"; |
|
11 | - update_db::update_all(); |
|
12 | - echo "\nInstall waypoints...(VERY slow!)"; |
|
13 | - update_db::update_waypoints(); |
|
14 | - echo "Done !\n"; |
|
15 | - echo "Install airspace..."; |
|
16 | - update_db::update_airspace(); |
|
17 | - echo "Done !\n"; |
|
18 | - echo "Install countries..."; |
|
19 | - update_db::update_countries(); |
|
20 | - echo "Done !\n"; |
|
21 | - if (isset($globalOwner) && $globalOwner) { |
|
3 | + require_once('../require/settings.php'); |
|
4 | + if ($globalInstalled) { |
|
5 | + //echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
6 | + echo "Use install/index.php instead. You really don't want to use this."; |
|
7 | + exit; |
|
8 | + } |
|
9 | + require('class.update_db.php'); |
|
10 | + echo "Populate all tables...\n"; |
|
11 | + update_db::update_all(); |
|
12 | + echo "\nInstall waypoints...(VERY slow!)"; |
|
13 | + update_db::update_waypoints(); |
|
14 | + echo "Done !\n"; |
|
15 | + echo "Install airspace..."; |
|
16 | + update_db::update_airspace(); |
|
17 | + echo "Done !\n"; |
|
18 | + echo "Install countries..."; |
|
19 | + update_db::update_countries(); |
|
20 | + echo "Done !\n"; |
|
21 | + if (isset($globalOwner) && $globalOwner) { |
|
22 | 22 | echo "Install private owners..."; |
23 | 23 | update_db::update_owner_fam(); |
24 | - echo "Done !\n"; |
|
25 | - } |
|
26 | - /* |
|
24 | + echo "Done !\n"; |
|
25 | + } |
|
26 | + /* |
|
27 | 27 | if (isset($globalIVAO) && $globalIVAO) { |
28 | 28 | echo "Install IVAO airlines and logos..."; |
29 | 29 | update_db::update_IVAO(); |
30 | 30 | echo "Done !\n"; |
31 | 31 | } |
32 | 32 | */ |
33 | - if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
|
33 | + if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
|
34 | 34 | echo "Install NOTAM from notaminfo.com..."; |
35 | - update_db:update_notam(); |
|
36 | - echo "Done !\n"; |
|
37 | - } |
|
38 | - if (isset($globalMap3D) && $globalMap3D) { |
|
35 | + update_db:update_notam(); |
|
36 | + echo "Done !\n"; |
|
37 | + } |
|
38 | + if (isset($globalMap3D) && $globalMap3D) { |
|
39 | 39 | echo "Install 3D models..."; |
40 | 40 | update_db::update_models(); |
41 | 41 | echo "Done !\n"; |
42 | 42 | if (isset($globalMapSatellites) && $globalMapSatellites) { |
43 | - echo "Install Space 3D models..."; |
|
44 | - update_db::update_space_models(); |
|
45 | - echo "Done !\n"; |
|
46 | - } |
|
47 | - } |
|
43 | + echo "Install Space 3D models..."; |
|
44 | + update_db::update_space_models(); |
|
45 | + echo "Done !\n"; |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | 49 | ?> |
50 | 50 | \ No newline at end of file |
@@ -1,31 +1,31 @@ |
||
1 | 1 | #!/usr/bin/php |
2 | 2 | <?php |
3 | - require_once('../require/settings.php'); |
|
4 | - if ($globalInstalled) { |
|
5 | - //echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
6 | - echo "Use install/index.php instead. You really don't want to use this."; |
|
7 | - exit; |
|
8 | - } |
|
9 | - require('class.create_db.php'); |
|
10 | - echo "Create and import all tables..."; |
|
11 | - create_db::import_all_db('../db/'); |
|
12 | - echo "Done !\n"; |
|
3 | + require_once('../require/settings.php'); |
|
4 | + if ($globalInstalled) { |
|
5 | + //echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
6 | + echo "Use install/index.php instead. You really don't want to use this."; |
|
7 | + exit; |
|
8 | + } |
|
9 | + require('class.create_db.php'); |
|
10 | + echo "Create and import all tables..."; |
|
11 | + create_db::import_all_db('../db/'); |
|
12 | + echo "Done !\n"; |
|
13 | 13 | |
14 | - require('class.update_db.php'); |
|
15 | - echo "Populate all tables...\n"; |
|
16 | - update_db::update_all(); |
|
17 | - echo "\nInstall waypoints...(VERY slow!)"; |
|
18 | - update_db::update_waypoints(); |
|
19 | - echo "Done !\n"; |
|
20 | - echo "Install airspace..."; |
|
21 | - update_db::update_airspace(); |
|
22 | - echo "Done !\n"; |
|
23 | - echo 'All is now installed ! Thanks'."\n"; |
|
24 | - if ($globalSBS1) { |
|
25 | - echo 'You need to run cron-sbs.php as a daemon. You can use init script in the install/init directory.'."\n"; |
|
26 | - } |
|
27 | - if ($globalACARS) { |
|
28 | - echo 'You need to run cron-acars.php as a daemon. You can use init script in the install/init directory.'."\n"; |
|
29 | - } |
|
14 | + require('class.update_db.php'); |
|
15 | + echo "Populate all tables...\n"; |
|
16 | + update_db::update_all(); |
|
17 | + echo "\nInstall waypoints...(VERY slow!)"; |
|
18 | + update_db::update_waypoints(); |
|
19 | + echo "Done !\n"; |
|
20 | + echo "Install airspace..."; |
|
21 | + update_db::update_airspace(); |
|
22 | + echo "Done !\n"; |
|
23 | + echo 'All is now installed ! Thanks'."\n"; |
|
24 | + if ($globalSBS1) { |
|
25 | + echo 'You need to run cron-sbs.php as a daemon. You can use init script in the install/init directory.'."\n"; |
|
26 | + } |
|
27 | + if ($globalACARS) { |
|
28 | + echo 'You need to run cron-acars.php as a daemon. You can use init script in the install/init directory.'."\n"; |
|
29 | + } |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 | \ No newline at end of file |