@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | |
13 | - /** |
|
14 | - * Get SQL query part for filter used |
|
15 | - * @param Array $filter the filter |
|
16 | - * @return Array the SQL part |
|
17 | - */ |
|
18 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
13 | + /** |
|
14 | + * Get SQL query part for filter used |
|
15 | + * @param Array $filter the filter |
|
16 | + * @return Array the SQL part |
|
17 | + */ |
|
18 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | 19 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | - if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
21 | + if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
22 | 22 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
23 | 23 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
24 | 24 | } |
25 | - } else { |
|
25 | + } else { |
|
26 | 26 | $filter = $globalStatsFilters[$globalFilterName]; |
27 | - } |
|
27 | + } |
|
28 | 28 | } |
29 | 29 | if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | 32 | if (isset($filter['source']) && !empty($filter['source'])) { |
33 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
33 | + $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
34 | 34 | } |
35 | 35 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
36 | 36 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
37 | 37 | $filter_query = $filter_query_join.$filter_query_where; |
38 | 38 | return $filter_query; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | - public function getAll() { |
|
42 | - $filter_query = $this->getFilter(array()); |
|
43 | - $query = "SELECT * FROM atc".$filter_query; |
|
44 | - $query_values = array(); |
|
45 | - try { |
|
46 | - $sth = $this->db->prepare($query); |
|
47 | - $sth->execute($query_values); |
|
48 | - } catch(PDOException $e) { |
|
49 | - return "error : ".$e->getMessage(); |
|
50 | - } |
|
51 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
52 | - return $all; |
|
53 | - } |
|
41 | + public function getAll() { |
|
42 | + $filter_query = $this->getFilter(array()); |
|
43 | + $query = "SELECT * FROM atc".$filter_query; |
|
44 | + $query_values = array(); |
|
45 | + try { |
|
46 | + $sth = $this->db->prepare($query); |
|
47 | + $sth->execute($query_values); |
|
48 | + } catch(PDOException $e) { |
|
49 | + return "error : ".$e->getMessage(); |
|
50 | + } |
|
51 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
52 | + return $all; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | public function getById($id) { |
56 | - $filter_query = $this->getFilter(array(),true); |
|
57 | - $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
|
58 | - $query_values = array(':id' => $id); |
|
59 | - try { |
|
60 | - $sth = $this->db->prepare($query); |
|
61 | - $sth->execute($query_values); |
|
62 | - } catch(PDOException $e) { |
|
63 | - return "error : ".$e->getMessage(); |
|
64 | - } |
|
65 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
66 | - return $all; |
|
67 | - } |
|
56 | + $filter_query = $this->getFilter(array(),true); |
|
57 | + $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
|
58 | + $query_values = array(':id' => $id); |
|
59 | + try { |
|
60 | + $sth = $this->db->prepare($query); |
|
61 | + $sth->execute($query_values); |
|
62 | + } catch(PDOException $e) { |
|
63 | + return "error : ".$e->getMessage(); |
|
64 | + } |
|
65 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
66 | + return $all; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | public function getByIdent($ident,$format_source = '') { |
70 | 70 | $filter_query = $this->getFilter(array(),true); |
@@ -117,53 +117,53 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - public function deleteById($id) { |
|
121 | - $query = "DELETE FROM atc WHERE atc_id = :id"; |
|
122 | - $query_values = array(':id' => $id); |
|
123 | - try { |
|
124 | - $sth = $this->db->prepare($query); |
|
125 | - $sth->execute($query_values); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error : ".$e->getMessage(); |
|
128 | - } |
|
129 | - } |
|
120 | + public function deleteById($id) { |
|
121 | + $query = "DELETE FROM atc WHERE atc_id = :id"; |
|
122 | + $query_values = array(':id' => $id); |
|
123 | + try { |
|
124 | + $sth = $this->db->prepare($query); |
|
125 | + $sth->execute($query_values); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error : ".$e->getMessage(); |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | - public function deleteByIdent($ident,$format_source) { |
|
132 | - $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
|
133 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
134 | - try { |
|
135 | - $sth = $this->db->prepare($query); |
|
136 | - $sth->execute($query_values); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error : ".$e->getMessage(); |
|
139 | - } |
|
140 | - } |
|
131 | + public function deleteByIdent($ident,$format_source) { |
|
132 | + $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
|
133 | + $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
134 | + try { |
|
135 | + $sth = $this->db->prepare($query); |
|
136 | + $sth->execute($query_values); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error : ".$e->getMessage(); |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | - public function deleteAll() { |
|
143 | - $query = "DELETE FROM atc"; |
|
144 | - $query_values = array(); |
|
145 | - try { |
|
146 | - $sth = $this->db->prepare($query); |
|
147 | - $sth->execute($query_values); |
|
148 | - } catch(PDOException $e) { |
|
149 | - return "error : ".$e->getMessage(); |
|
150 | - } |
|
151 | - } |
|
142 | + public function deleteAll() { |
|
143 | + $query = "DELETE FROM atc"; |
|
144 | + $query_values = array(); |
|
145 | + try { |
|
146 | + $sth = $this->db->prepare($query); |
|
147 | + $sth->execute($query_values); |
|
148 | + } catch(PDOException $e) { |
|
149 | + return "error : ".$e->getMessage(); |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | 153 | public function deleteOldATC() { |
154 | - global $globalDBdriver; |
|
155 | - if ($globalDBdriver == 'mysql') { |
|
156 | - $query = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen"; |
|
157 | - } else { |
|
158 | - $query = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR' >= atc.atc_lastseen"; |
|
159 | - } |
|
160 | - try { |
|
161 | - $sth = $this->db->prepare($query); |
|
162 | - $sth->execute(); |
|
163 | - } catch(PDOException $e) { |
|
164 | - return "error"; |
|
165 | - } |
|
166 | - return "success"; |
|
167 | - } |
|
154 | + global $globalDBdriver; |
|
155 | + if ($globalDBdriver == 'mysql') { |
|
156 | + $query = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen"; |
|
157 | + } else { |
|
158 | + $query = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR' >= atc.atc_lastseen"; |
|
159 | + } |
|
160 | + try { |
|
161 | + $sth = $this->db->prepare($query); |
|
162 | + $sth->execute(); |
|
163 | + } catch(PDOException $e) { |
|
164 | + return "error"; |
|
165 | + } |
|
166 | + return "success"; |
|
167 | + } |
|
168 | 168 | } |
169 | 169 | ?> |
170 | 170 | \ No newline at end of file |
@@ -720,12 +720,12 @@ |
||
720 | 720 | update_airportsLayer(); |
721 | 721 | } |
722 | 722 | <?php |
723 | - if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
723 | + if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
724 | 724 | ?> |
725 | 725 | update_atcLayer(); |
726 | 726 | setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
727 | 727 | <?php |
728 | - } |
|
728 | + } |
|
729 | 729 | ?> |
730 | 730 | |
731 | 731 | function iconColor(color) { |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
17 | 17 | if (isset($globalMarine) && $globalMarine) { |
18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,42 +24,42 @@ discard block |
||
24 | 24 | // Check if schema is at latest version |
25 | 25 | $Connection = new Connection(); |
26 | 26 | if ($Connection->latest() === false) { |
27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | - exit(); |
|
27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | + exit(); |
|
29 | 29 | } |
30 | 30 | if (PHP_SAPI != 'cli') { |
31 | - echo "This script MUST be called from console, not a web browser."; |
|
31 | + echo "This script MUST be called from console, not a web browser."; |
|
32 | 32 | // exit(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This is to be compatible with old version of settings.php |
36 | 36 | if (!isset($globalSources)) { |
37 | - if (isset($globalSBS1Hosts)) { |
|
38 | - //$hosts = $globalSBS1Hosts; |
|
39 | - foreach ($globalSBS1Hosts as $host) { |
|
40 | - $globalSources[] = array('host' => $host); |
|
41 | - } |
|
42 | - } else { |
|
43 | - if (!isset($globalSBS1Host)) { |
|
44 | - echo '$globalSources MUST be defined !'; |
|
45 | - die; |
|
37 | + if (isset($globalSBS1Hosts)) { |
|
38 | + //$hosts = $globalSBS1Hosts; |
|
39 | + foreach ($globalSBS1Hosts as $host) { |
|
40 | + $globalSources[] = array('host' => $host); |
|
41 | + } |
|
42 | + } else { |
|
43 | + if (!isset($globalSBS1Host)) { |
|
44 | + echo '$globalSources MUST be defined !'; |
|
45 | + die; |
|
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
56 | - $globalSources = array(); |
|
57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | - else $globalSources[] = array('host' => $options['s']); |
|
56 | + $globalSources = array(); |
|
57 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + else $globalSources[] = array('host' => $options['s']); |
|
59 | 59 | } elseif (isset($options['source'])) { |
60 | - $globalSources = array(); |
|
61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | - else $globalSources[] = array('host' => $options['source']); |
|
60 | + $globalSources = array(); |
|
61 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + else $globalSources[] = array('host' => $options['source']); |
|
63 | 63 | } |
64 | 64 | if (isset($options['aprsserverhost'])) { |
65 | 65 | $globalServerAPRS = TRUE; |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
75 | 75 | else $id_source = 1; |
76 | 76 | if (isset($globalServer) && $globalServer) { |
77 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | - $SI=new SpotterServer(); |
|
77 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | + $SI=new SpotterServer(); |
|
79 | 79 | /* |
80 | 80 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
81 | 81 | $SI = new adsb2aprs(); |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | } else $SI=new SpotterImport($Connection->db); |
85 | 85 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
86 | 86 | if (isset($globalMarine) && $globalMarine) { |
87 | - $AIS = new AIS(); |
|
88 | - $MI = new MarineImport($Connection->db); |
|
87 | + $AIS = new AIS(); |
|
88 | + $MI = new MarineImport($Connection->db); |
|
89 | 89 | } |
90 | 90 | //$APRS=new APRS($Connection->db); |
91 | 91 | $SBS=new SBS(); |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | //$servertz = system('date +%Z'); |
96 | 96 | // signal handler - playing nice with sockets and dump1090 |
97 | 97 | if (function_exists('pcntl_fork')) { |
98 | - pcntl_signal(SIGINT, function() { |
|
99 | - global $sockets; |
|
100 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | - die("Bye!\n"); |
|
102 | - }); |
|
103 | - pcntl_signal_dispatch(); |
|
98 | + pcntl_signal(SIGINT, function() { |
|
99 | + global $sockets; |
|
100 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | + die("Bye!\n"); |
|
102 | + }); |
|
103 | + pcntl_signal_dispatch(); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // let's try and connect |
@@ -110,36 +110,36 @@ discard block |
||
110 | 110 | $reset = 0; |
111 | 111 | |
112 | 112 | function connect_all($hosts) { |
113 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | - $reset++; |
|
116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | - foreach ($hosts as $id => $value) { |
|
113 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | + $reset++; |
|
116 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | + foreach ($hosts as $id => $value) { |
|
118 | 118 | $host = $value['host']; |
119 | 119 | $globalSources[$id]['last_exec'] = 0; |
120 | 120 | // Here we check type of source(s) |
121 | 121 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
122 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | - //$formats[$id] = 'deltadbtxt'; |
|
124 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | - //$last_exec['deltadbtxt'] = 0; |
|
126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | - //$formats[$id] = 'vatsimtxt'; |
|
129 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | - //$last_exec['vatsimtxt'] = 0; |
|
131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | - //$formats[$id] = 'aircraftlistjson'; |
|
134 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | - //$last_exec['aircraftlistjson'] = 0; |
|
136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | - } else if (preg_match('/opensky/i',$host)) { |
|
138 | - //$formats[$id] = 'aircraftlistjson'; |
|
139 | - $globalSources[$id]['format'] = 'opensky'; |
|
140 | - //$last_exec['aircraftlistjson'] = 0; |
|
141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | - /* |
|
122 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + //$formats[$id] = 'deltadbtxt'; |
|
124 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | + //$last_exec['deltadbtxt'] = 0; |
|
126 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | + //$formats[$id] = 'vatsimtxt'; |
|
129 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | + //$last_exec['vatsimtxt'] = 0; |
|
131 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | + //$formats[$id] = 'aircraftlistjson'; |
|
134 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | + //$last_exec['aircraftlistjson'] = 0; |
|
136 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | + } else if (preg_match('/opensky/i',$host)) { |
|
138 | + //$formats[$id] = 'aircraftlistjson'; |
|
139 | + $globalSources[$id]['format'] = 'opensky'; |
|
140 | + //$last_exec['aircraftlistjson'] = 0; |
|
141 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | + /* |
|
143 | 143 | // Disabled for now, site change source format |
144 | 144 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
145 | 145 | //$formats[$id] = 'radarvirtueljson'; |
@@ -151,115 +151,115 @@ discard block |
||
151 | 151 | exit(0); |
152 | 152 | } |
153 | 153 | */ |
154 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
155 | - //$formats[$id] = 'planeupdatefaa'; |
|
156 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
157 | - //$last_exec['planeupdatefaa'] = 0; |
|
158 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
159 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
160 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
161 | - exit(0); |
|
162 | - } |
|
163 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
164 | - //$formats[$id] = 'phpvmacars'; |
|
165 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
166 | - //$last_exec['phpvmacars'] = 0; |
|
167 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
168 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
169 | - //$formats[$id] = 'phpvmacars'; |
|
170 | - $globalSources[$id]['format'] = 'vam'; |
|
171 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
172 | - } else if (preg_match('/whazzup/i',$host)) { |
|
173 | - //$formats[$id] = 'whazzup'; |
|
174 | - $globalSources[$id]['format'] = 'whazzup'; |
|
175 | - //$last_exec['whazzup'] = 0; |
|
176 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
177 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
178 | - //$formats[$id] = 'pirepsjson'; |
|
179 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
180 | - //$last_exec['pirepsjson'] = 0; |
|
181 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
182 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
183 | - //$formats[$id] = 'fr24json'; |
|
184 | - $globalSources[$id]['format'] = 'fr24json'; |
|
185 | - //$last_exec['fr24json'] = 0; |
|
186 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
187 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
188 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
189 | - exit(0); |
|
190 | - } |
|
191 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
192 | - //$formats[$id] = 'fr24json'; |
|
193 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
194 | - //$last_exec['fr24json'] = 0; |
|
195 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
196 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
197 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
198 | - exit(0); |
|
199 | - } |
|
200 | - //} else if (preg_match('/10001/',$host)) { |
|
201 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
202 | - //$formats[$id] = 'tsv'; |
|
203 | - $globalSources[$id]['format'] = 'tsv'; |
|
204 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
205 | - } |
|
206 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
207 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
208 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
209 | - if ($idf !== false) { |
|
210 | - $httpfeeds[$id] = $idf; |
|
211 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | - } |
|
213 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
214 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
215 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
216 | - $hostport = explode(':',$host); |
|
217 | - if (isset($hostport[1])) { |
|
154 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
155 | + //$formats[$id] = 'planeupdatefaa'; |
|
156 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
157 | + //$last_exec['planeupdatefaa'] = 0; |
|
158 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
159 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
160 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
161 | + exit(0); |
|
162 | + } |
|
163 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
164 | + //$formats[$id] = 'phpvmacars'; |
|
165 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
166 | + //$last_exec['phpvmacars'] = 0; |
|
167 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
168 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
169 | + //$formats[$id] = 'phpvmacars'; |
|
170 | + $globalSources[$id]['format'] = 'vam'; |
|
171 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
172 | + } else if (preg_match('/whazzup/i',$host)) { |
|
173 | + //$formats[$id] = 'whazzup'; |
|
174 | + $globalSources[$id]['format'] = 'whazzup'; |
|
175 | + //$last_exec['whazzup'] = 0; |
|
176 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
177 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
178 | + //$formats[$id] = 'pirepsjson'; |
|
179 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
180 | + //$last_exec['pirepsjson'] = 0; |
|
181 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
182 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
183 | + //$formats[$id] = 'fr24json'; |
|
184 | + $globalSources[$id]['format'] = 'fr24json'; |
|
185 | + //$last_exec['fr24json'] = 0; |
|
186 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
187 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
188 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
189 | + exit(0); |
|
190 | + } |
|
191 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
192 | + //$formats[$id] = 'fr24json'; |
|
193 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
194 | + //$last_exec['fr24json'] = 0; |
|
195 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
196 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
197 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
198 | + exit(0); |
|
199 | + } |
|
200 | + //} else if (preg_match('/10001/',$host)) { |
|
201 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
202 | + //$formats[$id] = 'tsv'; |
|
203 | + $globalSources[$id]['format'] = 'tsv'; |
|
204 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
205 | + } |
|
206 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
207 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
208 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
209 | + if ($idf !== false) { |
|
210 | + $httpfeeds[$id] = $idf; |
|
211 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | + } |
|
213 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
214 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
215 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
216 | + $hostport = explode(':',$host); |
|
217 | + if (isset($hostport[1])) { |
|
218 | 218 | $port = $hostport[1]; |
219 | 219 | $hostn = $hostport[0]; |
220 | - } else { |
|
220 | + } else { |
|
221 | 221 | $port = $globalSources[$id]['port']; |
222 | 222 | $hostn = $globalSources[$id]['host']; |
223 | - } |
|
224 | - $Common = new Common(); |
|
225 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
226 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
227 | - } else { |
|
228 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
229 | - } |
|
230 | - if ($s) { |
|
231 | - $sockets[$id] = $s; |
|
232 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
233 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
223 | + } |
|
224 | + $Common = new Common(); |
|
225 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
226 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
227 | + } else { |
|
228 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
229 | + } |
|
230 | + if ($s) { |
|
231 | + $sockets[$id] = $s; |
|
232 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
233 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
234 | 234 | //$formats[$id] = 'aprs'; |
235 | 235 | $globalSources[$id]['format'] = 'aprs'; |
236 | 236 | //$aprs_connect = 0; |
237 | 237 | //$use_aprs = true; |
238 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
238 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
239 | 239 | $globalSources[$id]['format'] = 'vrstcp'; |
240 | - } elseif ($port == '10001') { |
|
241 | - //$formats[$id] = 'tsv'; |
|
242 | - $globalSources[$id]['format'] = 'tsv'; |
|
243 | - } elseif ($port == '30002') { |
|
244 | - //$formats[$id] = 'raw'; |
|
245 | - $globalSources[$id]['format'] = 'raw'; |
|
246 | - } elseif ($port == '5001') { |
|
247 | - //$formats[$id] = 'raw'; |
|
248 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
249 | - } elseif ($port == '30005') { |
|
240 | + } elseif ($port == '10001') { |
|
241 | + //$formats[$id] = 'tsv'; |
|
242 | + $globalSources[$id]['format'] = 'tsv'; |
|
243 | + } elseif ($port == '30002') { |
|
244 | + //$formats[$id] = 'raw'; |
|
245 | + $globalSources[$id]['format'] = 'raw'; |
|
246 | + } elseif ($port == '5001') { |
|
247 | + //$formats[$id] = 'raw'; |
|
248 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
249 | + } elseif ($port == '30005') { |
|
250 | 250 | // Not yet supported |
251 | - //$formats[$id] = 'beast'; |
|
252 | - $globalSources[$id]['format'] = 'beast'; |
|
253 | - //} else $formats[$id] = 'sbs'; |
|
254 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
255 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
251 | + //$formats[$id] = 'beast'; |
|
252 | + $globalSources[$id]['format'] = 'beast'; |
|
253 | + //} else $formats[$id] = 'sbs'; |
|
254 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
255 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
256 | 256 | } |
257 | 257 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
258 | - } else { |
|
258 | + } else { |
|
259 | 259 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
260 | - } |
|
261 | - } |
|
262 | - } |
|
260 | + } |
|
261 | + } |
|
262 | + } |
|
263 | 263 | } |
264 | 264 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
265 | 265 | |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | //connect_all($globalSources); |
283 | 283 | |
284 | 284 | if (isset($globalProxy) && $globalProxy) { |
285 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
285 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
286 | 286 | } else { |
287 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
287 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // APRS Configuration |
@@ -293,18 +293,18 @@ discard block |
||
293 | 293 | die; |
294 | 294 | } |
295 | 295 | foreach ($globalSources as $key => $source) { |
296 | - if (!isset($source['format'])) { |
|
297 | - $globalSources[$key]['format'] = 'auto'; |
|
298 | - } |
|
296 | + if (!isset($source['format'])) { |
|
297 | + $globalSources[$key]['format'] = 'auto'; |
|
298 | + } |
|
299 | 299 | } |
300 | 300 | connect_all($globalSources); |
301 | 301 | foreach ($globalSources as $key => $source) { |
302 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
302 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
303 | 303 | $aprs_connect = 0; |
304 | 304 | $use_aprs = true; |
305 | 305 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
306 | 306 | break; |
307 | - } |
|
307 | + } |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | if ($use_aprs) { |
@@ -345,116 +345,116 @@ discard block |
||
345 | 345 | |
346 | 346 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
347 | 347 | while ($i > 0) { |
348 | - if (!$globalDaemon) $i = $endtime-time(); |
|
349 | - // Delete old ATC |
|
350 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
348 | + if (!$globalDaemon) $i = $endtime-time(); |
|
349 | + // Delete old ATC |
|
350 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
351 | 351 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
352 | - $ATC->deleteOldATC(); |
|
353 | - } |
|
352 | + $ATC->deleteOldATC(); |
|
353 | + } |
|
354 | 354 | |
355 | - //if (count($last_exec) > 0) { |
|
356 | - if (count($last_exec) == count($globalSources)) { |
|
355 | + //if (count($last_exec) > 0) { |
|
356 | + if (count($last_exec) == count($globalSources)) { |
|
357 | 357 | $max = $globalMinFetch; |
358 | 358 | foreach ($last_exec as $last) { |
359 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
359 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
360 | 360 | } |
361 | 361 | if ($max != $globalMinFetch) { |
362 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
363 | - sleep($globalMinFetch-$max+2); |
|
362 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
363 | + sleep($globalMinFetch-$max+2); |
|
364 | + } |
|
364 | 365 | } |
365 | - } |
|
366 | 366 | |
367 | 367 | |
368 | - //foreach ($formats as $id => $value) { |
|
369 | - foreach ($globalSources as $id => $value) { |
|
368 | + //foreach ($formats as $id => $value) { |
|
369 | + foreach ($globalSources as $id => $value) { |
|
370 | 370 | date_default_timezone_set('UTC'); |
371 | 371 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
372 | 372 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
373 | - //$buffer = $Common->getData($hosts[$id]); |
|
374 | - $buffer = $Common->getData($value['host']); |
|
375 | - if ($buffer != '') $reset = 0; |
|
376 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
377 | - $buffer = explode('\n',$buffer); |
|
378 | - foreach ($buffer as $line) { |
|
379 | - if ($line != '' && count($line) > 7) { |
|
380 | - $line = explode(',', $line); |
|
381 | - $data = array(); |
|
382 | - $data['hex'] = $line[1]; // hex |
|
383 | - $data['ident'] = $line[2]; // ident |
|
384 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
385 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
386 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
387 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
388 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
389 | - $data['verticalrate'] = ''; // vertical rate |
|
390 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
391 | - $data['emergency'] = ''; // emergency |
|
392 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
393 | - $data['format_source'] = 'deltadbtxt'; |
|
394 | - $data['id_source'] = $id_source; |
|
395 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
396 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
397 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
398 | - $SI->add($data); |
|
399 | - unset($data); |
|
400 | - } |
|
401 | - } |
|
402 | - $last_exec[$id]['last'] = time(); |
|
373 | + //$buffer = $Common->getData($hosts[$id]); |
|
374 | + $buffer = $Common->getData($value['host']); |
|
375 | + if ($buffer != '') $reset = 0; |
|
376 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
377 | + $buffer = explode('\n',$buffer); |
|
378 | + foreach ($buffer as $line) { |
|
379 | + if ($line != '' && count($line) > 7) { |
|
380 | + $line = explode(',', $line); |
|
381 | + $data = array(); |
|
382 | + $data['hex'] = $line[1]; // hex |
|
383 | + $data['ident'] = $line[2]; // ident |
|
384 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
385 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
386 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
387 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
388 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
389 | + $data['verticalrate'] = ''; // vertical rate |
|
390 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
391 | + $data['emergency'] = ''; // emergency |
|
392 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
393 | + $data['format_source'] = 'deltadbtxt'; |
|
394 | + $data['id_source'] = $id_source; |
|
395 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
396 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
397 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
398 | + $SI->add($data); |
|
399 | + unset($data); |
|
400 | + } |
|
401 | + } |
|
402 | + $last_exec[$id]['last'] = time(); |
|
403 | 403 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
404 | - date_default_timezone_set('CET'); |
|
405 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
406 | - date_default_timezone_set('UTC'); |
|
407 | - if ($buffer != '') $reset = 0; |
|
408 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
409 | - $buffer = explode('\n',$buffer); |
|
410 | - foreach ($buffer as $line) { |
|
404 | + date_default_timezone_set('CET'); |
|
405 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
406 | + date_default_timezone_set('UTC'); |
|
407 | + if ($buffer != '') $reset = 0; |
|
408 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
409 | + $buffer = explode('\n',$buffer); |
|
410 | + foreach ($buffer as $line) { |
|
411 | 411 | if ($line != '') { |
412 | - echo "'".$line."'\n"; |
|
413 | - $add = false; |
|
414 | - $ais_data = $AIS->parse_line(trim($line)); |
|
415 | - $data = array(); |
|
416 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
417 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
418 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
419 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
420 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
421 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
422 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
423 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
424 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
425 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
426 | - if (isset($ais_data['timestamp'])) { |
|
412 | + echo "'".$line."'\n"; |
|
413 | + $add = false; |
|
414 | + $ais_data = $AIS->parse_line(trim($line)); |
|
415 | + $data = array(); |
|
416 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
417 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
418 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
419 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
420 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
421 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
422 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
423 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
424 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
425 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
426 | + if (isset($ais_data['timestamp'])) { |
|
427 | 427 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
428 | 428 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
429 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
430 | - $add = true; |
|
429 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
430 | + $add = true; |
|
431 | 431 | } |
432 | - } else { |
|
432 | + } else { |
|
433 | 433 | $data['datetime'] = date('Y-m-d H:i:s'); |
434 | 434 | $add = true; |
435 | - } |
|
436 | - $data['format_source'] = 'aisnmeatxt'; |
|
437 | - $data['id_source'] = $id_source; |
|
438 | - //print_r($data); |
|
439 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
440 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
441 | - unset($data); |
|
435 | + } |
|
436 | + $data['format_source'] = 'aisnmeatxt'; |
|
437 | + $data['id_source'] = $id_source; |
|
438 | + //print_r($data); |
|
439 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
440 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
441 | + unset($data); |
|
442 | 442 | } |
443 | - } |
|
444 | - $last_exec[$id]['last'] = time(); |
|
443 | + } |
|
444 | + $last_exec[$id]['last'] = time(); |
|
445 | 445 | } elseif ($value['format'] == 'aisnmeahttp') { |
446 | - $arr = $httpfeeds; |
|
447 | - $w = $e = null; |
|
446 | + $arr = $httpfeeds; |
|
447 | + $w = $e = null; |
|
448 | 448 | |
449 | - if (isset($arr[$id])) { |
|
449 | + if (isset($arr[$id])) { |
|
450 | 450 | $nn = stream_select($arr,$w,$e,$timeout); |
451 | 451 | if ($nn > 0) { |
452 | - foreach ($httpfeeds as $feed) { |
|
452 | + foreach ($httpfeeds as $feed) { |
|
453 | 453 | $buffer = stream_get_line($feed,2000,"\n"); |
454 | 454 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
455 | 455 | $buffer = explode('\n',$buffer); |
456 | 456 | foreach ($buffer as $line) { |
457 | - if ($line != '') { |
|
457 | + if ($line != '') { |
|
458 | 458 | $ais_data = $AIS->parse_line(trim($line)); |
459 | 459 | $data = array(); |
460 | 460 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -472,96 +472,96 @@ discard block |
||
472 | 472 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
473 | 473 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
474 | 474 | if (isset($ais_data['timestamp'])) { |
475 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
475 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
476 | 476 | } else { |
477 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
477 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
478 | 478 | } |
479 | 479 | $data['format_source'] = 'aisnmeahttp'; |
480 | 480 | $data['id_source'] = $id_source; |
481 | 481 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
482 | 482 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
483 | 483 | unset($data); |
484 | - } |
|
484 | + } |
|
485 | + } |
|
485 | 486 | } |
486 | - } |
|
487 | 487 | } else { |
488 | - $format = $value['format']; |
|
489 | - if (isset($tt[$format])) $tt[$format]++; |
|
490 | - else $tt[$format] = 0; |
|
491 | - if ($tt[$format] > 30) { |
|
488 | + $format = $value['format']; |
|
489 | + if (isset($tt[$format])) $tt[$format]++; |
|
490 | + else $tt[$format] = 0; |
|
491 | + if ($tt[$format] > 30) { |
|
492 | 492 | if ($globalDebug) echo 'Reconnect...'."\n"; |
493 | 493 | sleep(2); |
494 | 494 | $sourceeen[] = $value; |
495 | 495 | connect_all($sourceeen); |
496 | 496 | $sourceeen = array(); |
497 | - } |
|
497 | + } |
|
498 | + } |
|
498 | 499 | } |
499 | - } |
|
500 | 500 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
501 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
502 | - if ($buffer != '') { |
|
501 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
502 | + if ($buffer != '') { |
|
503 | 503 | //echo $buffer; |
504 | 504 | $all_data = json_decode($buffer,true); |
505 | 505 | //print_r($all_data); |
506 | 506 | if (isset($all_data[0]['DATA'])) { |
507 | - foreach ($all_data[0]['DATA'] as $line) { |
|
507 | + foreach ($all_data[0]['DATA'] as $line) { |
|
508 | 508 | if ($line != '') { |
509 | - $data = array(); |
|
510 | - $data['ident'] = $line['NAME']; |
|
511 | - $data['mmsi'] = $line['MMSI']; |
|
512 | - $data['speed'] = $line['SOG']; |
|
513 | - $data['heading'] = $line['COG']; |
|
514 | - $data['latitude'] = $line['LAT']; |
|
515 | - $data['longitude'] = $line['LNG']; |
|
516 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
517 | - $data['imo'] = $line['IMO']; |
|
518 | - //$data['arrival_code'] = $ais_data['destination']; |
|
519 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
520 | - $data['format_source'] = 'myshiptracking'; |
|
521 | - $data['id_source'] = $id_source; |
|
522 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
523 | - $MI->add($data); |
|
524 | - unset($data); |
|
509 | + $data = array(); |
|
510 | + $data['ident'] = $line['NAME']; |
|
511 | + $data['mmsi'] = $line['MMSI']; |
|
512 | + $data['speed'] = $line['SOG']; |
|
513 | + $data['heading'] = $line['COG']; |
|
514 | + $data['latitude'] = $line['LAT']; |
|
515 | + $data['longitude'] = $line['LNG']; |
|
516 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
517 | + $data['imo'] = $line['IMO']; |
|
518 | + //$data['arrival_code'] = $ais_data['destination']; |
|
519 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
520 | + $data['format_source'] = 'myshiptracking'; |
|
521 | + $data['id_source'] = $id_source; |
|
522 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
523 | + $MI->add($data); |
|
524 | + unset($data); |
|
525 | + } |
|
525 | 526 | } |
526 | - } |
|
527 | 527 | } |
528 | - } |
|
529 | - $last_exec[$id]['last'] = time(); |
|
528 | + } |
|
529 | + $last_exec[$id]['last'] = time(); |
|
530 | 530 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
531 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
532 | - if ($buffer != '') { |
|
531 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
532 | + if ($buffer != '') { |
|
533 | 533 | $all_data = json_decode($buffer,true); |
534 | 534 | if (isset($all_data[0]['mmsi'])) { |
535 | - foreach ($all_data as $line) { |
|
535 | + foreach ($all_data as $line) { |
|
536 | 536 | if ($line != '') { |
537 | - $data = array(); |
|
538 | - $data['ident'] = $line['shipname']; |
|
539 | - $data['callsign'] = $line['callsign']; |
|
540 | - $data['mmsi'] = $line['mmsi']; |
|
541 | - $data['speed'] = $line['sog']; |
|
542 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
543 | - $data['latitude'] = $line['latitude']; |
|
544 | - $data['longitude'] = $line['longitude']; |
|
545 | - $data['type_id'] = $line['shiptype']; |
|
546 | - $data['arrival_code'] = $line['destination']; |
|
547 | - $data['datetime'] = $line['time']; |
|
548 | - $data['format_source'] = 'boatbeaconapp'; |
|
549 | - $data['id_source'] = $id_source; |
|
550 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
551 | - $MI->add($data); |
|
552 | - unset($data); |
|
537 | + $data = array(); |
|
538 | + $data['ident'] = $line['shipname']; |
|
539 | + $data['callsign'] = $line['callsign']; |
|
540 | + $data['mmsi'] = $line['mmsi']; |
|
541 | + $data['speed'] = $line['sog']; |
|
542 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
543 | + $data['latitude'] = $line['latitude']; |
|
544 | + $data['longitude'] = $line['longitude']; |
|
545 | + $data['type_id'] = $line['shiptype']; |
|
546 | + $data['arrival_code'] = $line['destination']; |
|
547 | + $data['datetime'] = $line['time']; |
|
548 | + $data['format_source'] = 'boatbeaconapp'; |
|
549 | + $data['id_source'] = $id_source; |
|
550 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
551 | + $MI->add($data); |
|
552 | + unset($data); |
|
553 | + } |
|
553 | 554 | } |
554 | - } |
|
555 | 555 | } |
556 | 556 | |
557 | - } |
|
558 | - $last_exec[$id]['last'] = time(); |
|
557 | + } |
|
558 | + $last_exec[$id]['last'] = time(); |
|
559 | 559 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
560 | - $buffer = $Common->getData($value['host']); |
|
561 | - if ($buffer != '') { |
|
560 | + $buffer = $Common->getData($value['host']); |
|
561 | + if ($buffer != '') { |
|
562 | 562 | $all_data = json_decode($buffer,true); |
563 | 563 | if (isset($all_data['features'][0]['id'])) { |
564 | - foreach ($all_data['features'] as $line) { |
|
564 | + foreach ($all_data['features'] as $line) { |
|
565 | 565 | $data = array(); |
566 | 566 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
567 | 567 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -580,59 +580,59 @@ discard block |
||
580 | 580 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
581 | 581 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
582 | 582 | unset($data); |
583 | - } |
|
583 | + } |
|
584 | 584 | } |
585 | 585 | |
586 | - } |
|
587 | - $last_exec[$id]['last'] = time(); |
|
586 | + } |
|
587 | + $last_exec[$id]['last'] = time(); |
|
588 | 588 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
589 | - echo 'download...'; |
|
590 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
591 | - echo 'done !'."\n"; |
|
592 | - if ($buffer != '') $reset = 0; |
|
593 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
594 | - $buffer = explode('\n',$buffer); |
|
595 | - foreach ($buffer as $line) { |
|
589 | + echo 'download...'; |
|
590 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
591 | + echo 'done !'."\n"; |
|
592 | + if ($buffer != '') $reset = 0; |
|
593 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
594 | + $buffer = explode('\n',$buffer); |
|
595 | + foreach ($buffer as $line) { |
|
596 | 596 | if ($line != '') { |
597 | - $data = array(); |
|
598 | - $data['mmsi'] = (int)substr($line,0,9); |
|
599 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
600 | - //$data['status'] = substr($line,21,2); |
|
601 | - //$data['type'] = substr($line,24,3); |
|
602 | - $data['latitude'] = substr($line,29,9); |
|
603 | - $data['longitude'] = substr($line,41,9); |
|
604 | - $data['speed'] = round(substr($line,51,5)); |
|
605 | - //$data['course'] = substr($line,57,5); |
|
606 | - $data['heading'] = round(substr($line,63,3)); |
|
607 | - //$data['draft'] = substr($line,67,4); |
|
608 | - //$data['length'] = substr($line,72,3); |
|
609 | - //$data['beam'] = substr($line,76,2); |
|
610 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
611 | - //$data['callsign'] = trim(substr($line,100,7); |
|
612 | - //$data['dest'] = substr($line,108,20); |
|
613 | - //$data['etaDate'] = substr($line,129,5); |
|
614 | - //$data['etaTime'] = substr($line,135,5); |
|
615 | - $data['format_source'] = 'shipplotter'; |
|
616 | - $data['id_source'] = $id_source; |
|
617 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
618 | - //print_r($data); |
|
619 | - echo 'Add...'."\n"; |
|
620 | - $MI->add($data); |
|
621 | - unset($data); |
|
597 | + $data = array(); |
|
598 | + $data['mmsi'] = (int)substr($line,0,9); |
|
599 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
600 | + //$data['status'] = substr($line,21,2); |
|
601 | + //$data['type'] = substr($line,24,3); |
|
602 | + $data['latitude'] = substr($line,29,9); |
|
603 | + $data['longitude'] = substr($line,41,9); |
|
604 | + $data['speed'] = round(substr($line,51,5)); |
|
605 | + //$data['course'] = substr($line,57,5); |
|
606 | + $data['heading'] = round(substr($line,63,3)); |
|
607 | + //$data['draft'] = substr($line,67,4); |
|
608 | + //$data['length'] = substr($line,72,3); |
|
609 | + //$data['beam'] = substr($line,76,2); |
|
610 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
611 | + //$data['callsign'] = trim(substr($line,100,7); |
|
612 | + //$data['dest'] = substr($line,108,20); |
|
613 | + //$data['etaDate'] = substr($line,129,5); |
|
614 | + //$data['etaTime'] = substr($line,135,5); |
|
615 | + $data['format_source'] = 'shipplotter'; |
|
616 | + $data['id_source'] = $id_source; |
|
617 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
618 | + //print_r($data); |
|
619 | + echo 'Add...'."\n"; |
|
620 | + $MI->add($data); |
|
621 | + unset($data); |
|
622 | 622 | } |
623 | - } |
|
624 | - $last_exec[$id]['last'] = time(); |
|
623 | + } |
|
624 | + $last_exec[$id]['last'] = time(); |
|
625 | 625 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
626 | 626 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
627 | - //$buffer = $Common->getData($hosts[$id]); |
|
628 | - $buffer = $Common->getData($value['host']); |
|
629 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
630 | - $buffer = explode('\n',$buffer); |
|
631 | - $reset = 0; |
|
632 | - foreach ($buffer as $line) { |
|
633 | - if ($line != '') { |
|
634 | - $line = explode(':', $line); |
|
635 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
627 | + //$buffer = $Common->getData($hosts[$id]); |
|
628 | + $buffer = $Common->getData($value['host']); |
|
629 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
630 | + $buffer = explode('\n',$buffer); |
|
631 | + $reset = 0; |
|
632 | + foreach ($buffer as $line) { |
|
633 | + if ($line != '') { |
|
634 | + $line = explode(':', $line); |
|
635 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
636 | 636 | $data = array(); |
637 | 637 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
638 | 638 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -645,37 +645,37 @@ discard block |
||
645 | 645 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
646 | 646 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
647 | 647 | $data['latitude'] = $line[5]; // lat |
648 | - $data['longitude'] = $line[6]; // long |
|
649 | - $data['verticalrate'] = ''; // vertical rate |
|
650 | - $data['squawk'] = ''; // squawk |
|
651 | - $data['emergency'] = ''; // emergency |
|
652 | - $data['waypoints'] = $line[30]; |
|
648 | + $data['longitude'] = $line[6]; // long |
|
649 | + $data['verticalrate'] = ''; // vertical rate |
|
650 | + $data['squawk'] = ''; // squawk |
|
651 | + $data['emergency'] = ''; // emergency |
|
652 | + $data['waypoints'] = $line[30]; |
|
653 | 653 | $data['datetime'] = date('Y-m-d H:i:s'); |
654 | 654 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
655 | 655 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
656 | - $data['departure_airport_icao'] = $line[11]; |
|
657 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
658 | - $data['arrival_airport_icao'] = $line[13]; |
|
656 | + $data['departure_airport_icao'] = $line[11]; |
|
657 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
658 | + $data['arrival_airport_icao'] = $line[13]; |
|
659 | 659 | $data['frequency'] = $line[4]; |
660 | 660 | $data['type'] = $line[18]; |
661 | 661 | $data['range'] = $line[19]; |
662 | 662 | if (isset($line[35])) $data['info'] = $line[35]; |
663 | - $data['id_source'] = $id_source; |
|
664 | - //$data['arrival_airport_time'] = ; |
|
665 | - if ($line[9] != '') { |
|
666 | - $aircraft_data = explode('/',$line[9]); |
|
667 | - if (isset($aircraft_data[1])) { |
|
668 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
669 | - } |
|
670 | - } |
|
671 | - /* |
|
663 | + $data['id_source'] = $id_source; |
|
664 | + //$data['arrival_airport_time'] = ; |
|
665 | + if ($line[9] != '') { |
|
666 | + $aircraft_data = explode('/',$line[9]); |
|
667 | + if (isset($aircraft_data[1])) { |
|
668 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
669 | + } |
|
670 | + } |
|
671 | + /* |
|
672 | 672 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
673 | 673 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
674 | 674 | */ |
675 | - $data['format_source'] = $value['format']; |
|
675 | + $data['format_source'] = $value['format']; |
|
676 | 676 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
677 | 677 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
678 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
678 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
679 | 679 | elseif ($line[3] == 'ATC') { |
680 | 680 | //print_r($data); |
681 | 681 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -696,255 +696,255 @@ discard block |
||
696 | 696 | 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']); |
697 | 697 | } |
698 | 698 | } |
699 | - unset($data); |
|
700 | - } |
|
701 | - } |
|
702 | - } |
|
703 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
704 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
705 | - $last_exec[$id]['last'] = time(); |
|
706 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
707 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
708 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
709 | - if ($buffer != '') { |
|
710 | - $all_data = json_decode($buffer,true); |
|
711 | - if (isset($all_data['acList'])) { |
|
699 | + unset($data); |
|
700 | + } |
|
701 | + } |
|
702 | + } |
|
703 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
704 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
705 | + $last_exec[$id]['last'] = time(); |
|
706 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
707 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
708 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
709 | + if ($buffer != '') { |
|
710 | + $all_data = json_decode($buffer,true); |
|
711 | + if (isset($all_data['acList'])) { |
|
712 | 712 | $reset = 0; |
713 | 713 | foreach ($all_data['acList'] as $line) { |
714 | - $data = array(); |
|
715 | - $data['hex'] = $line['Icao']; // hex |
|
716 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
717 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
718 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
719 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
720 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
721 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
722 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
723 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
724 | - $data['emergency'] = ''; // emergency |
|
725 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
714 | + $data = array(); |
|
715 | + $data['hex'] = $line['Icao']; // hex |
|
716 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
717 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
718 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
719 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
720 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
721 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
722 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
723 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
724 | + $data['emergency'] = ''; // emergency |
|
725 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
726 | 726 | |
727 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
728 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
727 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
728 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
729 | 729 | |
730 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
731 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
732 | - $data['format_source'] = 'aircraftlistjson'; |
|
733 | - $data['id_source'] = $id_source; |
|
734 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
735 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
736 | - if (isset($data['latitude'])) $SI->add($data); |
|
737 | - unset($data); |
|
730 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
731 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
732 | + $data['format_source'] = 'aircraftlistjson'; |
|
733 | + $data['id_source'] = $id_source; |
|
734 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
735 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
736 | + if (isset($data['latitude'])) $SI->add($data); |
|
737 | + unset($data); |
|
738 | 738 | } |
739 | - } elseif (is_array($all_data)) { |
|
739 | + } elseif (is_array($all_data)) { |
|
740 | 740 | $reset = 0; |
741 | 741 | foreach ($all_data as $line) { |
742 | - $data = array(); |
|
743 | - $data['hex'] = $line['hex']; // hex |
|
744 | - $data['ident'] = $line['flight']; // ident |
|
745 | - $data['altitude'] = $line['altitude']; // altitude |
|
746 | - $data['speed'] = $line['speed']; // speed |
|
747 | - $data['heading'] = $line['track']; // heading |
|
748 | - $data['latitude'] = $line['lat']; // lat |
|
749 | - $data['longitude'] = $line['lon']; // long |
|
750 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
751 | - $data['squawk'] = $line['squawk']; // squawk |
|
752 | - $data['emergency'] = ''; // emergency |
|
753 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
754 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
755 | - $data['format_source'] = 'aircraftlistjson'; |
|
756 | - $data['id_source'] = $id_source; |
|
757 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
758 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
759 | - $SI->add($data); |
|
760 | - unset($data); |
|
742 | + $data = array(); |
|
743 | + $data['hex'] = $line['hex']; // hex |
|
744 | + $data['ident'] = $line['flight']; // ident |
|
745 | + $data['altitude'] = $line['altitude']; // altitude |
|
746 | + $data['speed'] = $line['speed']; // speed |
|
747 | + $data['heading'] = $line['track']; // heading |
|
748 | + $data['latitude'] = $line['lat']; // lat |
|
749 | + $data['longitude'] = $line['lon']; // long |
|
750 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
751 | + $data['squawk'] = $line['squawk']; // squawk |
|
752 | + $data['emergency'] = ''; // emergency |
|
753 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
754 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
755 | + $data['format_source'] = 'aircraftlistjson'; |
|
756 | + $data['id_source'] = $id_source; |
|
757 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
758 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
759 | + $SI->add($data); |
|
760 | + unset($data); |
|
761 | + } |
|
762 | + } |
|
761 | 763 | } |
762 | - } |
|
763 | - } |
|
764 | - //$last_exec['aircraftlistjson'] = time(); |
|
765 | - $last_exec[$id]['last'] = time(); |
|
766 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
767 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
768 | - $buffer = $Common->getData($value['host']); |
|
769 | - $all_data = json_decode($buffer,true); |
|
770 | - if (isset($all_data['planes'])) { |
|
764 | + //$last_exec['aircraftlistjson'] = time(); |
|
765 | + $last_exec[$id]['last'] = time(); |
|
766 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
767 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
768 | + $buffer = $Common->getData($value['host']); |
|
769 | + $all_data = json_decode($buffer,true); |
|
770 | + if (isset($all_data['planes'])) { |
|
771 | 771 | $reset = 0; |
772 | 772 | foreach ($all_data['planes'] as $key => $line) { |
773 | - $data = array(); |
|
774 | - $data['hex'] = $key; // hex |
|
775 | - $data['ident'] = $line[3]; // ident |
|
776 | - $data['altitude'] = $line[6]; // altitude |
|
777 | - $data['speed'] = $line[8]; // speed |
|
778 | - $data['heading'] = $line[7]; // heading |
|
779 | - $data['latitude'] = $line[4]; // lat |
|
780 | - $data['longitude'] = $line[5]; // long |
|
781 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
782 | - $data['squawk'] = $line[10]; // squawk |
|
783 | - $data['emergency'] = ''; // emergency |
|
784 | - $data['registration'] = $line[2]; |
|
785 | - $data['aircraft_icao'] = $line[0]; |
|
786 | - $deparr = explode('-',$line[1]); |
|
787 | - if (count($deparr) == 2) { |
|
773 | + $data = array(); |
|
774 | + $data['hex'] = $key; // hex |
|
775 | + $data['ident'] = $line[3]; // ident |
|
776 | + $data['altitude'] = $line[6]; // altitude |
|
777 | + $data['speed'] = $line[8]; // speed |
|
778 | + $data['heading'] = $line[7]; // heading |
|
779 | + $data['latitude'] = $line[4]; // lat |
|
780 | + $data['longitude'] = $line[5]; // long |
|
781 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
782 | + $data['squawk'] = $line[10]; // squawk |
|
783 | + $data['emergency'] = ''; // emergency |
|
784 | + $data['registration'] = $line[2]; |
|
785 | + $data['aircraft_icao'] = $line[0]; |
|
786 | + $deparr = explode('-',$line[1]); |
|
787 | + if (count($deparr) == 2) { |
|
788 | 788 | $data['departure_airport_icao'] = $deparr[0]; |
789 | 789 | $data['arrival_airport_icao'] = $deparr[1]; |
790 | - } |
|
791 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
792 | - $data['format_source'] = 'planeupdatefaa'; |
|
793 | - $data['id_source'] = $id_source; |
|
794 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
795 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
796 | - $SI->add($data); |
|
797 | - unset($data); |
|
790 | + } |
|
791 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
792 | + $data['format_source'] = 'planeupdatefaa'; |
|
793 | + $data['id_source'] = $id_source; |
|
794 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
795 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
796 | + $SI->add($data); |
|
797 | + unset($data); |
|
798 | + } |
|
798 | 799 | } |
799 | - } |
|
800 | - //$last_exec['planeupdatefaa'] = time(); |
|
801 | - $last_exec[$id]['last'] = time(); |
|
802 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
803 | - $buffer = $Common->getData($value['host']); |
|
804 | - $all_data = json_decode($buffer,true); |
|
805 | - if (isset($all_data['states'])) { |
|
800 | + //$last_exec['planeupdatefaa'] = time(); |
|
801 | + $last_exec[$id]['last'] = time(); |
|
802 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
803 | + $buffer = $Common->getData($value['host']); |
|
804 | + $all_data = json_decode($buffer,true); |
|
805 | + if (isset($all_data['states'])) { |
|
806 | 806 | $reset = 0; |
807 | 807 | foreach ($all_data['states'] as $key => $line) { |
808 | - $data = array(); |
|
809 | - $data['hex'] = $line[0]; // hex |
|
810 | - $data['ident'] = trim($line[1]); // ident |
|
811 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
812 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
813 | - $data['heading'] = round($line[10]); // heading |
|
814 | - $data['latitude'] = $line[6]; // lat |
|
815 | - $data['longitude'] = $line[5]; // long |
|
816 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
817 | - //$data['squawk'] = $line[10]; // squawk |
|
818 | - //$data['emergency'] = ''; // emergency |
|
819 | - //$data['registration'] = $line[2]; |
|
820 | - //$data['aircraft_icao'] = $line[0]; |
|
821 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
822 | - $data['format_source'] = 'opensky'; |
|
823 | - $data['id_source'] = $id_source; |
|
824 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
825 | - $SI->add($data); |
|
826 | - unset($data); |
|
808 | + $data = array(); |
|
809 | + $data['hex'] = $line[0]; // hex |
|
810 | + $data['ident'] = trim($line[1]); // ident |
|
811 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
812 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
813 | + $data['heading'] = round($line[10]); // heading |
|
814 | + $data['latitude'] = $line[6]; // lat |
|
815 | + $data['longitude'] = $line[5]; // long |
|
816 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
817 | + //$data['squawk'] = $line[10]; // squawk |
|
818 | + //$data['emergency'] = ''; // emergency |
|
819 | + //$data['registration'] = $line[2]; |
|
820 | + //$data['aircraft_icao'] = $line[0]; |
|
821 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
822 | + $data['format_source'] = 'opensky'; |
|
823 | + $data['id_source'] = $id_source; |
|
824 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
825 | + $SI->add($data); |
|
826 | + unset($data); |
|
827 | 827 | } |
828 | - } |
|
829 | - //$last_exec['planeupdatefaa'] = time(); |
|
830 | - $last_exec[$id]['last'] = time(); |
|
831 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
832 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
833 | - //$buffer = $Common->getData($hosts[$id]); |
|
834 | - $buffer = $Common->getData($value['host']); |
|
835 | - $all_data = json_decode($buffer,true); |
|
836 | - if (!empty($all_data)) $reset = 0; |
|
837 | - foreach ($all_data as $key => $line) { |
|
828 | + } |
|
829 | + //$last_exec['planeupdatefaa'] = time(); |
|
830 | + $last_exec[$id]['last'] = time(); |
|
831 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
832 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
833 | + //$buffer = $Common->getData($hosts[$id]); |
|
834 | + $buffer = $Common->getData($value['host']); |
|
835 | + $all_data = json_decode($buffer,true); |
|
836 | + if (!empty($all_data)) $reset = 0; |
|
837 | + foreach ($all_data as $key => $line) { |
|
838 | 838 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
839 | - $data = array(); |
|
840 | - $data['hex'] = $line[0]; |
|
841 | - $data['ident'] = $line[16]; //$line[13] |
|
842 | - $data['altitude'] = $line[4]; // altitude |
|
843 | - $data['speed'] = $line[5]; // speed |
|
844 | - $data['heading'] = $line[3]; // heading |
|
845 | - $data['latitude'] = $line[1]; // lat |
|
846 | - $data['longitude'] = $line[2]; // long |
|
847 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
848 | - $data['squawk'] = $line[6]; // squawk |
|
849 | - $data['aircraft_icao'] = $line[8]; |
|
850 | - $data['registration'] = $line[9]; |
|
851 | - $data['departure_airport_iata'] = $line[11]; |
|
852 | - $data['arrival_airport_iata'] = $line[12]; |
|
853 | - $data['emergency'] = ''; // emergency |
|
854 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
855 | - $data['format_source'] = 'fr24json'; |
|
856 | - $data['id_source'] = $id_source; |
|
857 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
858 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
859 | - $SI->add($data); |
|
860 | - unset($data); |
|
839 | + $data = array(); |
|
840 | + $data['hex'] = $line[0]; |
|
841 | + $data['ident'] = $line[16]; //$line[13] |
|
842 | + $data['altitude'] = $line[4]; // altitude |
|
843 | + $data['speed'] = $line[5]; // speed |
|
844 | + $data['heading'] = $line[3]; // heading |
|
845 | + $data['latitude'] = $line[1]; // lat |
|
846 | + $data['longitude'] = $line[2]; // long |
|
847 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
848 | + $data['squawk'] = $line[6]; // squawk |
|
849 | + $data['aircraft_icao'] = $line[8]; |
|
850 | + $data['registration'] = $line[9]; |
|
851 | + $data['departure_airport_iata'] = $line[11]; |
|
852 | + $data['arrival_airport_iata'] = $line[12]; |
|
853 | + $data['emergency'] = ''; // emergency |
|
854 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
855 | + $data['format_source'] = 'fr24json'; |
|
856 | + $data['id_source'] = $id_source; |
|
857 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
858 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
859 | + $SI->add($data); |
|
860 | + unset($data); |
|
861 | + } |
|
861 | 862 | } |
862 | - } |
|
863 | - //$last_exec['fr24json'] = time(); |
|
864 | - $last_exec[$id]['last'] = time(); |
|
865 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
866 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
867 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
868 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
869 | - //echo $buffer; |
|
870 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
871 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
872 | - $all_data = json_decode($buffer,true); |
|
873 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
863 | + //$last_exec['fr24json'] = time(); |
|
864 | + $last_exec[$id]['last'] = time(); |
|
865 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
866 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
867 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
868 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
869 | + //echo $buffer; |
|
870 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
871 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
872 | + $all_data = json_decode($buffer,true); |
|
873 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
874 | 874 | die(json_last_error_msg()); |
875 | - } |
|
876 | - if (isset($all_data['mrkrs'])) { |
|
875 | + } |
|
876 | + if (isset($all_data['mrkrs'])) { |
|
877 | 877 | $reset = 0; |
878 | 878 | foreach ($all_data['mrkrs'] as $key => $line) { |
879 | - if (isset($line['inf'])) { |
|
879 | + if (isset($line['inf'])) { |
|
880 | 880 | $data = array(); |
881 | 881 | $data['hex'] = $line['inf']['ia']; |
882 | 882 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
883 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
884 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
885 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
886 | - $data['latitude'] = $line['pt'][0]; // lat |
|
887 | - $data['longitude'] = $line['pt'][1]; // long |
|
888 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
889 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
890 | - //$data['aircraft_icao'] = $line[8]; |
|
891 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
883 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
884 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
885 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
886 | + $data['latitude'] = $line['pt'][0]; // lat |
|
887 | + $data['longitude'] = $line['pt'][1]; // long |
|
888 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
889 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
890 | + //$data['aircraft_icao'] = $line[8]; |
|
891 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
892 | 892 | //$data['departure_airport_iata'] = $line[11]; |
893 | 893 | //$data['arrival_airport_iata'] = $line[12]; |
894 | - //$data['emergency'] = ''; // emergency |
|
894 | + //$data['emergency'] = ''; // emergency |
|
895 | 895 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
896 | - $data['format_source'] = 'radarvirtueljson'; |
|
897 | - $data['id_source'] = $id_source; |
|
896 | + $data['format_source'] = 'radarvirtueljson'; |
|
897 | + $data['id_source'] = $id_source; |
|
898 | 898 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
899 | 899 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
900 | 900 | $SI->add($data); |
901 | 901 | unset($data); |
902 | - } |
|
902 | + } |
|
903 | 903 | } |
904 | - } |
|
905 | - //$last_exec['radarvirtueljson'] = time(); |
|
906 | - $last_exec[$id]['last'] = time(); |
|
907 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
908 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
909 | - //$buffer = $Common->getData($hosts[$id]); |
|
910 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
911 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
904 | + } |
|
905 | + //$last_exec['radarvirtueljson'] = time(); |
|
906 | + $last_exec[$id]['last'] = time(); |
|
907 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
908 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
909 | + //$buffer = $Common->getData($hosts[$id]); |
|
910 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
911 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
912 | 912 | |
913 | - if (isset($all_data['pireps'])) { |
|
913 | + if (isset($all_data['pireps'])) { |
|
914 | 914 | $reset = 0; |
915 | - foreach ($all_data['pireps'] as $line) { |
|
916 | - $data = array(); |
|
917 | - $data['id'] = $line['id']; |
|
918 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
919 | - $data['ident'] = $line['callsign']; // ident |
|
920 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
921 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
922 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
923 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
924 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
925 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
926 | - $data['latitude'] = $line['lat']; // lat |
|
927 | - $data['longitude'] = $line['lon']; // long |
|
928 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
929 | - //$data['squawk'] = $line['squawk']; // squawk |
|
930 | - //$data['emergency'] = ''; // emergency |
|
931 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
932 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
933 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
934 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
935 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
936 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
937 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
938 | - else $data['info'] = ''; |
|
939 | - $data['format_source'] = 'pireps'; |
|
940 | - $data['id_source'] = $id_source; |
|
941 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
942 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
943 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
944 | - if ($line['icon'] == 'plane') { |
|
915 | + foreach ($all_data['pireps'] as $line) { |
|
916 | + $data = array(); |
|
917 | + $data['id'] = $line['id']; |
|
918 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
919 | + $data['ident'] = $line['callsign']; // ident |
|
920 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
921 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
922 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
923 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
924 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
925 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
926 | + $data['latitude'] = $line['lat']; // lat |
|
927 | + $data['longitude'] = $line['lon']; // long |
|
928 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
929 | + //$data['squawk'] = $line['squawk']; // squawk |
|
930 | + //$data['emergency'] = ''; // emergency |
|
931 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
932 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
933 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
934 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
935 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
936 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
937 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
938 | + else $data['info'] = ''; |
|
939 | + $data['format_source'] = 'pireps'; |
|
940 | + $data['id_source'] = $id_source; |
|
941 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
942 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
943 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
944 | + if ($line['icon'] == 'plane') { |
|
945 | 945 | $SI->add($data); |
946 | - // print_r($data); |
|
947 | - } elseif ($line['icon'] == 'ct') { |
|
946 | + // print_r($data); |
|
947 | + } elseif ($line['icon'] == 'ct') { |
|
948 | 948 | $data['info'] = str_replace('^§','<br />',$data['info']); |
949 | 949 | $data['info'] = str_replace('&sect;','',$data['info']); |
950 | 950 | $typec = substr($data['ident'],-3); |
@@ -959,199 +959,199 @@ discard block |
||
959 | 959 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
960 | 960 | else $data['type'] = 'Observer'; |
961 | 961 | 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']); |
962 | - } |
|
963 | - unset($data); |
|
962 | + } |
|
963 | + unset($data); |
|
964 | 964 | } |
965 | - } |
|
966 | - //$last_exec['pirepsjson'] = time(); |
|
967 | - $last_exec[$id]['last'] = time(); |
|
968 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
969 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
970 | - //$buffer = $Common->getData($hosts[$id]); |
|
971 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
972 | - $buffer = $Common->getData($value['host']); |
|
973 | - $all_data = json_decode($buffer,true); |
|
974 | - if ($buffer != '' && is_array($all_data)) { |
|
965 | + } |
|
966 | + //$last_exec['pirepsjson'] = time(); |
|
967 | + $last_exec[$id]['last'] = time(); |
|
968 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
969 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
970 | + //$buffer = $Common->getData($hosts[$id]); |
|
971 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
972 | + $buffer = $Common->getData($value['host']); |
|
973 | + $all_data = json_decode($buffer,true); |
|
974 | + if ($buffer != '' && is_array($all_data)) { |
|
975 | 975 | $reset = 0; |
976 | 976 | foreach ($all_data as $line) { |
977 | - $data = array(); |
|
978 | - //$data['id'] = $line['id']; // id not usable |
|
979 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
980 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
981 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
982 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
983 | - $data['ident'] = $line['flightnum']; // ident |
|
984 | - $data['altitude'] = $line['alt']; // altitude |
|
985 | - $data['speed'] = $line['gs']; // speed |
|
986 | - $data['heading'] = $line['heading']; // heading |
|
987 | - $data['latitude'] = $line['lat']; // lat |
|
988 | - $data['longitude'] = $line['lng']; // long |
|
989 | - $data['verticalrate'] = ''; // verticale rate |
|
990 | - $data['squawk'] = ''; // squawk |
|
991 | - $data['emergency'] = ''; // emergency |
|
992 | - //$data['datetime'] = $line['lastupdate']; |
|
993 | - $data['last_update'] = $line['lastupdate']; |
|
994 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
995 | - $data['departure_airport_icao'] = $line['depicao']; |
|
996 | - $data['departure_airport_time'] = $line['deptime']; |
|
997 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
998 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
999 | - $data['registration'] = $line['aircraft']; |
|
1000 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1001 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1002 | - if (isset($line['aircraftname'])) { |
|
977 | + $data = array(); |
|
978 | + //$data['id'] = $line['id']; // id not usable |
|
979 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
980 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
981 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
982 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
983 | + $data['ident'] = $line['flightnum']; // ident |
|
984 | + $data['altitude'] = $line['alt']; // altitude |
|
985 | + $data['speed'] = $line['gs']; // speed |
|
986 | + $data['heading'] = $line['heading']; // heading |
|
987 | + $data['latitude'] = $line['lat']; // lat |
|
988 | + $data['longitude'] = $line['lng']; // long |
|
989 | + $data['verticalrate'] = ''; // verticale rate |
|
990 | + $data['squawk'] = ''; // squawk |
|
991 | + $data['emergency'] = ''; // emergency |
|
992 | + //$data['datetime'] = $line['lastupdate']; |
|
993 | + $data['last_update'] = $line['lastupdate']; |
|
994 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
995 | + $data['departure_airport_icao'] = $line['depicao']; |
|
996 | + $data['departure_airport_time'] = $line['deptime']; |
|
997 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
998 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
999 | + $data['registration'] = $line['aircraft']; |
|
1000 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1001 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1002 | + if (isset($line['aircraftname'])) { |
|
1003 | 1003 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1004 | 1004 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1005 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1006 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1007 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1008 | - else { |
|
1009 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1010 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1011 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1012 | - } |
|
1013 | - } |
|
1014 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1015 | - $data['id_source'] = $id_source; |
|
1016 | - $data['format_source'] = 'phpvmacars'; |
|
1017 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1018 | - $SI->add($data); |
|
1019 | - unset($data); |
|
1005 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1006 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1007 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1008 | + else { |
|
1009 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1010 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1011 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1012 | + } |
|
1013 | + } |
|
1014 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1015 | + $data['id_source'] = $id_source; |
|
1016 | + $data['format_source'] = 'phpvmacars'; |
|
1017 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1018 | + $SI->add($data); |
|
1019 | + unset($data); |
|
1020 | 1020 | } |
1021 | 1021 | if ($globalDebug) echo 'No more data...'."\n"; |
1022 | 1022 | unset($buffer); |
1023 | 1023 | unset($all_data); |
1024 | - } |
|
1025 | - //$last_exec['phpvmacars'] = time(); |
|
1026 | - $last_exec[$id]['last'] = time(); |
|
1027 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1028 | - //$buffer = $Common->getData($hosts[$id]); |
|
1029 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1030 | - $buffer = $Common->getData($value['host']); |
|
1031 | - $all_data = json_decode($buffer,true); |
|
1032 | - if ($buffer != '' && is_array($all_data)) { |
|
1024 | + } |
|
1025 | + //$last_exec['phpvmacars'] = time(); |
|
1026 | + $last_exec[$id]['last'] = time(); |
|
1027 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1028 | + //$buffer = $Common->getData($hosts[$id]); |
|
1029 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1030 | + $buffer = $Common->getData($value['host']); |
|
1031 | + $all_data = json_decode($buffer,true); |
|
1032 | + if ($buffer != '' && is_array($all_data)) { |
|
1033 | 1033 | $reset = 0; |
1034 | 1034 | foreach ($all_data as $line) { |
1035 | - $data = array(); |
|
1036 | - //$data['id'] = $line['id']; // id not usable |
|
1037 | - $data['id'] = trim($line['flight_id']); |
|
1038 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1039 | - $data['pilot_name'] = $line['pilot_name']; |
|
1040 | - $data['pilot_id'] = $line['pilot_id']; |
|
1041 | - $data['ident'] = trim($line['callsign']); // ident |
|
1042 | - $data['altitude'] = $line['altitude']; // altitude |
|
1043 | - $data['speed'] = $line['gs']; // speed |
|
1044 | - $data['heading'] = $line['heading']; // heading |
|
1045 | - $data['latitude'] = $line['latitude']; // lat |
|
1046 | - $data['longitude'] = $line['longitude']; // long |
|
1047 | - $data['verticalrate'] = ''; // verticale rate |
|
1048 | - $data['squawk'] = ''; // squawk |
|
1049 | - $data['emergency'] = ''; // emergency |
|
1050 | - //$data['datetime'] = $line['lastupdate']; |
|
1051 | - $data['last_update'] = $line['last_update']; |
|
1052 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1053 | - $data['departure_airport_icao'] = $line['departure']; |
|
1054 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1055 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1056 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1057 | - //$data['registration'] = $line['aircraft']; |
|
1058 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1059 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1060 | - $data['id_source'] = $id_source; |
|
1061 | - $data['format_source'] = 'vam'; |
|
1062 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1063 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1064 | - $SI->add($data); |
|
1065 | - unset($data); |
|
1035 | + $data = array(); |
|
1036 | + //$data['id'] = $line['id']; // id not usable |
|
1037 | + $data['id'] = trim($line['flight_id']); |
|
1038 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1039 | + $data['pilot_name'] = $line['pilot_name']; |
|
1040 | + $data['pilot_id'] = $line['pilot_id']; |
|
1041 | + $data['ident'] = trim($line['callsign']); // ident |
|
1042 | + $data['altitude'] = $line['altitude']; // altitude |
|
1043 | + $data['speed'] = $line['gs']; // speed |
|
1044 | + $data['heading'] = $line['heading']; // heading |
|
1045 | + $data['latitude'] = $line['latitude']; // lat |
|
1046 | + $data['longitude'] = $line['longitude']; // long |
|
1047 | + $data['verticalrate'] = ''; // verticale rate |
|
1048 | + $data['squawk'] = ''; // squawk |
|
1049 | + $data['emergency'] = ''; // emergency |
|
1050 | + //$data['datetime'] = $line['lastupdate']; |
|
1051 | + $data['last_update'] = $line['last_update']; |
|
1052 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1053 | + $data['departure_airport_icao'] = $line['departure']; |
|
1054 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1055 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1056 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1057 | + //$data['registration'] = $line['aircraft']; |
|
1058 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1059 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1060 | + $data['id_source'] = $id_source; |
|
1061 | + $data['format_source'] = 'vam'; |
|
1062 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1063 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1064 | + $SI->add($data); |
|
1065 | + unset($data); |
|
1066 | 1066 | } |
1067 | 1067 | if ($globalDebug) echo 'No more data...'."\n"; |
1068 | 1068 | unset($buffer); |
1069 | 1069 | unset($all_data); |
1070 | - } |
|
1071 | - //$last_exec['phpvmacars'] = time(); |
|
1072 | - $last_exec[$id]['last'] = time(); |
|
1070 | + } |
|
1071 | + //$last_exec['phpvmacars'] = time(); |
|
1072 | + $last_exec[$id]['last'] = time(); |
|
1073 | 1073 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1074 | 1074 | } 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') { |
1075 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1076 | - //$last_exec[$id]['last'] = time(); |
|
1075 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1076 | + //$last_exec[$id]['last'] = time(); |
|
1077 | 1077 | |
1078 | - //$read = array( $sockets[$id] ); |
|
1079 | - $read = $sockets; |
|
1080 | - $write = NULL; |
|
1081 | - $e = NULL; |
|
1082 | - $n = socket_select($read, $write, $e, $timeout); |
|
1083 | - if ($e != NULL) var_dump($e); |
|
1084 | - if ($n > 0) { |
|
1078 | + //$read = array( $sockets[$id] ); |
|
1079 | + $read = $sockets; |
|
1080 | + $write = NULL; |
|
1081 | + $e = NULL; |
|
1082 | + $n = socket_select($read, $write, $e, $timeout); |
|
1083 | + if ($e != NULL) var_dump($e); |
|
1084 | + if ($n > 0) { |
|
1085 | 1085 | $reset = 0; |
1086 | 1086 | foreach ($read as $nb => $r) { |
1087 | - //$value = $formats[$nb]; |
|
1088 | - $format = $globalSources[$nb]['format']; |
|
1089 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1087 | + //$value = $formats[$nb]; |
|
1088 | + $format = $globalSources[$nb]['format']; |
|
1089 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1090 | 1090 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1091 | - } elseif ($format == 'vrstcp') { |
|
1091 | + } elseif ($format == 'vrstcp') { |
|
1092 | 1092 | $buffer = @socket_read($r, 6000); |
1093 | - } else { |
|
1093 | + } else { |
|
1094 | 1094 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1095 | - } |
|
1096 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1097 | - //echo $buffer."\n"; |
|
1098 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1099 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1100 | - $error = false; |
|
1101 | - //$SI::del(); |
|
1102 | - if ($format == 'vrstcp') { |
|
1095 | + } |
|
1096 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1097 | + //echo $buffer."\n"; |
|
1098 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1099 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1100 | + $error = false; |
|
1101 | + //$SI::del(); |
|
1102 | + if ($format == 'vrstcp') { |
|
1103 | 1103 | $buffer = explode('},{',$buffer); |
1104 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1105 | - // SBS format is CSV format |
|
1106 | - if ($buffer !== FALSE && $buffer != '') { |
|
1104 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1105 | + // SBS format is CSV format |
|
1106 | + if ($buffer !== FALSE && $buffer != '') { |
|
1107 | 1107 | $tt[$format] = 0; |
1108 | 1108 | if ($format == 'acarssbs3') { |
1109 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1110 | - $ACARS->add(trim($buffer)); |
|
1111 | - $ACARS->deleteLiveAcarsData(); |
|
1109 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1110 | + $ACARS->add(trim($buffer)); |
|
1111 | + $ACARS->deleteLiveAcarsData(); |
|
1112 | 1112 | } elseif ($format == 'raw') { |
1113 | - // AVR format |
|
1114 | - $data = $SBS->parse($buffer); |
|
1115 | - if (is_array($data)) { |
|
1113 | + // AVR format |
|
1114 | + $data = $SBS->parse($buffer); |
|
1115 | + if (is_array($data)) { |
|
1116 | 1116 | $data['datetime'] = date('Y-m-d H:i:s'); |
1117 | 1117 | $data['format_source'] = 'raw'; |
1118 | 1118 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1119 | 1119 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1120 | 1120 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1121 | 1121 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1122 | - } |
|
1122 | + } |
|
1123 | 1123 | } elseif ($format == 'ais') { |
1124 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1125 | - $data = array(); |
|
1126 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1127 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1128 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1129 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1130 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1131 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1132 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1133 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1134 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1135 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1136 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1137 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1138 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1139 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1140 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1141 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1124 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1125 | + $data = array(); |
|
1126 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1127 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1128 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1129 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1130 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1131 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1132 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1133 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1134 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1135 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1136 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1137 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1138 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1139 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1140 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1141 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1142 | 1142 | |
1143 | - if (isset($ais_data['timestamp'])) { |
|
1143 | + if (isset($ais_data['timestamp'])) { |
|
1144 | 1144 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1145 | - } else { |
|
1145 | + } else { |
|
1146 | 1146 | $data['datetime'] = date('Y-m-d H:i:s'); |
1147 | - } |
|
1148 | - $data['format_source'] = 'aisnmea'; |
|
1149 | - $data['id_source'] = $id_source; |
|
1150 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1151 | - unset($data); |
|
1152 | - } elseif ($format == 'flightgearsp') { |
|
1153 | - //echo $buffer."\n"; |
|
1154 | - if (strlen($buffer) > 5) { |
|
1147 | + } |
|
1148 | + $data['format_source'] = 'aisnmea'; |
|
1149 | + $data['id_source'] = $id_source; |
|
1150 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1151 | + unset($data); |
|
1152 | + } elseif ($format == 'flightgearsp') { |
|
1153 | + //echo $buffer."\n"; |
|
1154 | + if (strlen($buffer) > 5) { |
|
1155 | 1155 | $line = explode(',',$buffer); |
1156 | 1156 | $data = array(); |
1157 | 1157 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1168,38 +1168,38 @@ discard block |
||
1168 | 1168 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1169 | 1169 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1170 | 1170 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1171 | - } |
|
1172 | - } elseif ($format == 'acars') { |
|
1173 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1174 | - $ACARS->add(trim($buffer)); |
|
1175 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1176 | - $ACARS->deleteLiveAcarsData(); |
|
1171 | + } |
|
1172 | + } elseif ($format == 'acars') { |
|
1173 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1174 | + $ACARS->add(trim($buffer)); |
|
1175 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1176 | + $ACARS->deleteLiveAcarsData(); |
|
1177 | 1177 | } elseif ($format == 'flightgearmp') { |
1178 | - if (substr($buffer,0,1) != '#') { |
|
1178 | + if (substr($buffer,0,1) != '#') { |
|
1179 | 1179 | $data = array(); |
1180 | 1180 | //echo $buffer."\n"; |
1181 | 1181 | $line = explode(' ',$buffer); |
1182 | 1182 | if (count($line) == 11) { |
1183 | - $userserver = explode('@',$line[0]); |
|
1184 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1185 | - $data['ident'] = $userserver[0]; |
|
1186 | - $data['registration'] = $userserver[0]; |
|
1187 | - $data['latitude'] = $line[4]; |
|
1188 | - $data['longitude'] = $line[5]; |
|
1189 | - $data['altitude'] = $line[6]; |
|
1190 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1191 | - $aircraft_type = $line[10]; |
|
1192 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1193 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1194 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1195 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1183 | + $userserver = explode('@',$line[0]); |
|
1184 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1185 | + $data['ident'] = $userserver[0]; |
|
1186 | + $data['registration'] = $userserver[0]; |
|
1187 | + $data['latitude'] = $line[4]; |
|
1188 | + $data['longitude'] = $line[5]; |
|
1189 | + $data['altitude'] = $line[6]; |
|
1190 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1191 | + $aircraft_type = $line[10]; |
|
1192 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1193 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1194 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1195 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1196 | + } |
|
1196 | 1197 | } |
1197 | - } |
|
1198 | 1198 | } elseif ($format == 'beast') { |
1199 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1200 | - die; |
|
1199 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1200 | + die; |
|
1201 | 1201 | } elseif ($format == 'vrstcp') { |
1202 | - foreach($buffer as $all_data) { |
|
1202 | + foreach($buffer as $all_data) { |
|
1203 | 1203 | $line = json_decode('{'.$all_data.'}',true); |
1204 | 1204 | $data = array(); |
1205 | 1205 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1219,113 +1219,113 @@ discard block |
||
1219 | 1219 | */ |
1220 | 1220 | $data['datetime'] = date('Y-m-d H:i:s'); |
1221 | 1221 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1222 | - $data['format_source'] = 'vrstcp'; |
|
1222 | + $data['format_source'] = 'vrstcp'; |
|
1223 | 1223 | $data['id_source'] = $id_source; |
1224 | 1224 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1225 | 1225 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1226 | 1226 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1227 | 1227 | unset($data); |
1228 | - } |
|
1228 | + } |
|
1229 | 1229 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1230 | - $line = explode("\t", $buffer); |
|
1231 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1230 | + $line = explode("\t", $buffer); |
|
1231 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1232 | 1232 | $key = $line[$k]; |
1233 | - $lined[$key] = $line[$k+1]; |
|
1234 | - } |
|
1235 | - if (count($lined) > 3) { |
|
1236 | - $data['hex'] = $lined['hexid']; |
|
1237 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1238 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1239 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1240 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1241 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1242 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1243 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1244 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1245 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1246 | - $data['id_source'] = $id_source; |
|
1247 | - $data['format_source'] = 'tsv'; |
|
1248 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1249 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1233 | + $lined[$key] = $line[$k+1]; |
|
1234 | + } |
|
1235 | + if (count($lined) > 3) { |
|
1236 | + $data['hex'] = $lined['hexid']; |
|
1237 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1238 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1239 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1240 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1241 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1242 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1243 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1244 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1245 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1246 | + $data['id_source'] = $id_source; |
|
1247 | + $data['format_source'] = 'tsv'; |
|
1248 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1249 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1250 | 1250 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1251 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1252 | - unset($lined); |
|
1253 | - unset($data); |
|
1254 | - } else $error = true; |
|
1251 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1252 | + unset($lined); |
|
1253 | + unset($data); |
|
1254 | + } else $error = true; |
|
1255 | 1255 | } elseif ($format == 'aprs' && $use_aprs) { |
1256 | - if ($aprs_connect == 0) { |
|
1256 | + if ($aprs_connect == 0) { |
|
1257 | 1257 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1258 | 1258 | $aprs_connect = 1; |
1259 | - } |
|
1259 | + } |
|
1260 | 1260 | |
1261 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1261 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1262 | 1262 | $aprs_last_tx = time(); |
1263 | 1263 | $data_aprs = "# Keep alive"; |
1264 | 1264 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1265 | - } |
|
1265 | + } |
|
1266 | 1266 | |
1267 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1268 | - //echo 'APRS data : '.$buffer."\n"; |
|
1269 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1270 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1271 | - //echo $buffer."\n"; |
|
1272 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1267 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1268 | + //echo 'APRS data : '.$buffer."\n"; |
|
1269 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1270 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1271 | + //echo $buffer."\n"; |
|
1272 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1273 | 1273 | $line = $APRS->parse($buffer); |
1274 | 1274 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1275 | 1275 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1276 | - $aprs_last_tx = time(); |
|
1277 | - $data = array(); |
|
1278 | - //print_r($line); |
|
1279 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1280 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1281 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1282 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1283 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1284 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1285 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1286 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1287 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1288 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1289 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1290 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1291 | - $data['latitude'] = $line['latitude']; |
|
1292 | - $data['longitude'] = $line['longitude']; |
|
1293 | - //$data['verticalrate'] = $line[16]; |
|
1294 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1295 | - else $data['speed'] = 0; |
|
1296 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1297 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1298 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1299 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1300 | - //else $data['heading'] = 0; |
|
1301 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1302 | - if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1303 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1304 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1305 | - $data['id_source'] = $id_source; |
|
1306 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1307 | - else $data['format_source'] = 'aprs'; |
|
1308 | - $data['source_name'] = $line['source']; |
|
1309 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1310 | - else $data['source_type'] = 'flarm'; |
|
1311 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1312 | - $currentdate = date('Y-m-d H:i:s'); |
|
1313 | - $aprsdate = strtotime($data['datetime']); |
|
1314 | - // Accept data if time <= system time + 20s |
|
1315 | - //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'])))) { |
|
1316 | - 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'])))) { |
|
1276 | + $aprs_last_tx = time(); |
|
1277 | + $data = array(); |
|
1278 | + //print_r($line); |
|
1279 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1280 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1281 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1282 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1283 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1284 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1285 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1286 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1287 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1288 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1289 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1290 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1291 | + $data['latitude'] = $line['latitude']; |
|
1292 | + $data['longitude'] = $line['longitude']; |
|
1293 | + //$data['verticalrate'] = $line[16]; |
|
1294 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1295 | + else $data['speed'] = 0; |
|
1296 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1297 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1298 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1299 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1300 | + //else $data['heading'] = 0; |
|
1301 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1302 | + if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1303 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1304 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1305 | + $data['id_source'] = $id_source; |
|
1306 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1307 | + else $data['format_source'] = 'aprs'; |
|
1308 | + $data['source_name'] = $line['source']; |
|
1309 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1310 | + else $data['source_type'] = 'flarm'; |
|
1311 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1312 | + $currentdate = date('Y-m-d H:i:s'); |
|
1313 | + $aprsdate = strtotime($data['datetime']); |
|
1314 | + // Accept data if time <= system time + 20s |
|
1315 | + //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'])))) { |
|
1316 | + 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'])))) { |
|
1317 | 1317 | $send = $SI->add($data); |
1318 | - } elseif ($data['source_type'] == 'ais') { |
|
1318 | + } elseif ($data['source_type'] == 'ais') { |
|
1319 | 1319 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1320 | - } elseif (isset($line['stealth'])) { |
|
1320 | + } elseif (isset($line['stealth'])) { |
|
1321 | 1321 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1322 | 1322 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1323 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1324 | - } 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') { |
|
1323 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1324 | + } 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') { |
|
1325 | 1325 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1326 | 1326 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1327 | - } |
|
1328 | - unset($data); |
|
1327 | + } |
|
1328 | + unset($data); |
|
1329 | 1329 | } |
1330 | 1330 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1331 | 1331 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1335,12 +1335,12 @@ discard block |
||
1335 | 1335 | } |
1336 | 1336 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1337 | 1337 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1338 | - } |
|
1338 | + } |
|
1339 | 1339 | } else { |
1340 | - $line = explode(',', $buffer); |
|
1341 | - if (count($line) > 20) { |
|
1342 | - $data['hex'] = $line[4]; |
|
1343 | - /* |
|
1340 | + $line = explode(',', $buffer); |
|
1341 | + if (count($line) > 20) { |
|
1342 | + $data['hex'] = $line[4]; |
|
1343 | + /* |
|
1344 | 1344 | $data['datetime'] = $line[6].' '.$line[7]; |
1345 | 1345 | date_default_timezone_set($globalTimezone); |
1346 | 1346 | $datetime = new DateTime($data['datetime']); |
@@ -1348,30 +1348,30 @@ discard block |
||
1348 | 1348 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1349 | 1349 | date_default_timezone_set('UTC'); |
1350 | 1350 | */ |
1351 | - // Force datetime to current UTC datetime |
|
1352 | - date_default_timezone_set('UTC'); |
|
1353 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1354 | - $data['ident'] = trim($line[10]); |
|
1355 | - $data['latitude'] = $line[14]; |
|
1356 | - $data['longitude'] = $line[15]; |
|
1357 | - $data['verticalrate'] = $line[16]; |
|
1358 | - $data['emergency'] = $line[20]; |
|
1359 | - $data['speed'] = $line[12]; |
|
1360 | - $data['squawk'] = $line[17]; |
|
1361 | - $data['altitude'] = $line[11]; |
|
1362 | - $data['heading'] = $line[13]; |
|
1363 | - $data['ground'] = $line[21]; |
|
1364 | - $data['emergency'] = $line[19]; |
|
1365 | - $data['format_source'] = 'sbs'; |
|
1351 | + // Force datetime to current UTC datetime |
|
1352 | + date_default_timezone_set('UTC'); |
|
1353 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1354 | + $data['ident'] = trim($line[10]); |
|
1355 | + $data['latitude'] = $line[14]; |
|
1356 | + $data['longitude'] = $line[15]; |
|
1357 | + $data['verticalrate'] = $line[16]; |
|
1358 | + $data['emergency'] = $line[20]; |
|
1359 | + $data['speed'] = $line[12]; |
|
1360 | + $data['squawk'] = $line[17]; |
|
1361 | + $data['altitude'] = $line[11]; |
|
1362 | + $data['heading'] = $line[13]; |
|
1363 | + $data['ground'] = $line[21]; |
|
1364 | + $data['emergency'] = $line[19]; |
|
1365 | + $data['format_source'] = 'sbs'; |
|
1366 | 1366 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1367 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1367 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1368 | 1368 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1369 | - $data['id_source'] = $id_source; |
|
1370 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1371 | - else $error = true; |
|
1372 | - unset($data); |
|
1373 | - } else $error = true; |
|
1374 | - if ($error) { |
|
1369 | + $data['id_source'] = $id_source; |
|
1370 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1371 | + else $error = true; |
|
1372 | + unset($data); |
|
1373 | + } else $error = true; |
|
1374 | + if ($error) { |
|
1375 | 1375 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1376 | 1376 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1377 | 1377 | } else { |
@@ -1387,13 +1387,13 @@ discard block |
||
1387 | 1387 | connect_all($sourceer); |
1388 | 1388 | $sourceer = array(); |
1389 | 1389 | } |
1390 | - } |
|
1390 | + } |
|
1391 | 1391 | } |
1392 | 1392 | // Sleep for xxx microseconds |
1393 | 1393 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1394 | - } else { |
|
1394 | + } else { |
|
1395 | 1395 | if ($format == 'flightgearmp') { |
1396 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1396 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1397 | 1397 | //@socket_close($r); |
1398 | 1398 | sleep($globalMinFetch); |
1399 | 1399 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1402,9 +1402,9 @@ discard block |
||
1402 | 1402 | break; |
1403 | 1403 | |
1404 | 1404 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1405 | - if (isset($tt[$format])) $tt[$format]++; |
|
1406 | - else $tt[$format] = 0; |
|
1407 | - if ($tt[$format] > 30) { |
|
1405 | + if (isset($tt[$format])) $tt[$format]++; |
|
1406 | + else $tt[$format] = 0; |
|
1407 | + if ($tt[$format] > 30) { |
|
1408 | 1408 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1409 | 1409 | //@socket_close($r); |
1410 | 1410 | sleep(2); |
@@ -1415,23 +1415,23 @@ discard block |
||
1415 | 1415 | //connect_all($globalSources); |
1416 | 1416 | $tt[$format]=0; |
1417 | 1417 | break; |
1418 | - } |
|
1418 | + } |
|
1419 | + } |
|
1419 | 1420 | } |
1420 | - } |
|
1421 | 1421 | } |
1422 | - } else { |
|
1422 | + } else { |
|
1423 | 1423 | $error = socket_strerror(socket_last_error()); |
1424 | 1424 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1425 | 1425 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1426 | 1426 | if (isset($globalDebug)) echo "Restarting...\n"; |
1427 | 1427 | // Restart the script if possible |
1428 | 1428 | if (is_array($sockets)) { |
1429 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1429 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1430 | 1430 | |
1431 | - foreach ($sockets as $sock) { |
|
1431 | + foreach ($sockets as $sock) { |
|
1432 | 1432 | @socket_shutdown($sock,2); |
1433 | 1433 | @socket_close($sock); |
1434 | - } |
|
1434 | + } |
|
1435 | 1435 | |
1436 | 1436 | } |
1437 | 1437 | if ($globalDebug) echo "Waiting..."; |
@@ -1446,13 +1446,13 @@ discard block |
||
1446 | 1446 | if ($globalDebug) echo "Restart all connections..."; |
1447 | 1447 | connect_all($globalSources); |
1448 | 1448 | } |
1449 | - } |
|
1449 | + } |
|
1450 | 1450 | } |
1451 | 1451 | if ($globalDaemon === false) { |
1452 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1453 | - $SI->checkAll(); |
|
1452 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1453 | + $SI->checkAll(); |
|
1454 | + } |
|
1454 | 1455 | } |
1455 | - } |
|
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | ?> |
@@ -40,15 +40,15 @@ |
||
40 | 40 | //print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
41 | 41 | print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>'; |
42 | 42 | if ($spotter_item['atc_range'] > 0) { |
43 | - print '<div><span>'._("Range").'</span>'; |
|
44 | - print $spotter_item['atc_range']; |
|
45 | - print '</div>'; |
|
43 | + print '<div><span>'._("Range").'</span>'; |
|
44 | + print $spotter_item['atc_range']; |
|
45 | + print '</div>'; |
|
46 | 46 | } |
47 | 47 | print '</div>'; |
48 | 48 | if ($spotter_item['info'] != '') { |
49 | - print '<div class="notamtext"><span>'._("Info").'</span>'; |
|
50 | - print $spotter_item['info']; |
|
51 | - print '</div>'; |
|
49 | + print '<div class="notamtext"><span>'._("Info").'</span>'; |
|
50 | + print $spotter_item['info']; |
|
51 | + print '</div>'; |
|
52 | 52 | } |
53 | 53 | print '</div>'; |
54 | 54 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | date_default_timezone_set('UTC'); |
25 | 25 | //waypoint plotting |
26 | 26 | $output .= '{"type": "Feature",'; |
27 | - $output .= '"properties": {'; |
|
27 | + $output .= '"properties": {'; |
|
28 | 28 | $output .= '"ref": "'.$spotter_item['atc_id'].'",'; |
29 | 29 | $output .= '"ident": "'.$spotter_item['ident'].'",'; |
30 | 30 | $output .= '"frequency": "'.$spotter_item['frequency'].'",'; |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | } else { |
51 | 51 | $output .= '"icon": "images/atc.png"'; |
52 | 52 | } |
53 | - $output .= '},'; |
|
54 | - $output .= '"geometry": {'; |
|
53 | + $output .= '},'; |
|
54 | + $output .= '"geometry": {'; |
|
55 | 55 | $output .= '"type": "Point",'; |
56 | 56 | $output .= '"coordinates": ['; |
57 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
57 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
58 | 58 | $output .= ']'; |
59 | - $output .= '}'; |
|
59 | + $output .= '}'; |
|
60 | 60 | $output .= '},'; |
61 | 61 | $radius = $spotter_item['atc_range']*100; |
62 | 62 | if ($radius > 0) { |
63 | 63 | $output .= '{"type": "Feature",'; |
64 | - $output .= '"properties": {'; |
|
64 | + $output .= '"properties": {'; |
|
65 | 65 | $output .= '"ref": "'.$spotter_item['atc_id'].'",'; |
66 | 66 | $output .= '"ident": "'.$spotter_item['ident'].'",'; |
67 | 67 | $output .= '"frequency": "'.$spotter_item['frequency'].'",'; |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | } else { |
88 | 88 | $output .= '"atccolor": "#888219"'; |
89 | 89 | } |
90 | - $output .= '},'; |
|
91 | - $output .= '"geometry": {'; |
|
90 | + $output .= '},'; |
|
91 | + $output .= '"geometry": {'; |
|
92 | 92 | $output .= '"type": "Point",'; |
93 | 93 | $output .= '"coordinates": ['; |
94 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
94 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
95 | 95 | $output .= ']'; |
96 | - $output .= '}'; |
|
96 | + $output .= '}'; |
|
97 | 97 | $output .= '},'; |
98 | 98 | } |
99 | 99 | } |