@@ -15,22 +15,22 @@ discard block |
||
15 | 15 | * @param Array $filter the filter |
16 | 16 | * @return Array the SQL part |
17 | 17 | */ |
18 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
18 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
19 | 19 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
22 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
23 | 23 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
24 | 24 | } |
25 | 25 | } else { |
26 | 26 | $filter = $globalStatsFilters[$globalFilterName]; |
27 | 27 | } |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | 32 | if (isset($filter['source']) && !empty($filter['source'])) { |
33 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
33 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
34 | 34 | } |
35 | 35 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
36 | 36 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | try { |
46 | 46 | $sth = $this->db->prepare($query); |
47 | 47 | $sth->execute($query_values); |
48 | - } catch(PDOException $e) { |
|
48 | + } catch (PDOException $e) { |
|
49 | 49 | return "error : ".$e->getMessage(); |
50 | 50 | } |
51 | 51 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -53,66 +53,66 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | public function getById($id) { |
56 | - $filter_query = $this->getFilter(array(),true); |
|
56 | + $filter_query = $this->getFilter(array(), true); |
|
57 | 57 | $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
58 | 58 | $query_values = array(':id' => $id); |
59 | 59 | try { |
60 | 60 | $sth = $this->db->prepare($query); |
61 | 61 | $sth->execute($query_values); |
62 | - } catch(PDOException $e) { |
|
62 | + } catch (PDOException $e) { |
|
63 | 63 | return "error : ".$e->getMessage(); |
64 | 64 | } |
65 | 65 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
66 | 66 | return $all; |
67 | 67 | } |
68 | 68 | |
69 | - public function getByIdent($ident,$format_source = '') { |
|
70 | - $filter_query = $this->getFilter(array(),true); |
|
69 | + public function getByIdent($ident, $format_source = '') { |
|
70 | + $filter_query = $this->getFilter(array(), true); |
|
71 | 71 | if ($format_source == '') { |
72 | 72 | $query = "SELECT * FROM atc".$filter_query." ident = :ident"; |
73 | 73 | $query_values = array(':ident' => $ident); |
74 | 74 | } else { |
75 | 75 | $query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source"; |
76 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
76 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
77 | 77 | } |
78 | 78 | try { |
79 | 79 | $sth = $this->db->prepare($query); |
80 | 80 | $sth->execute($query_values); |
81 | - } catch(PDOException $e) { |
|
81 | + } catch (PDOException $e) { |
|
82 | 82 | return "error : ".$e->getMessage(); |
83 | 83 | } |
84 | 84 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
85 | 85 | return $all; |
86 | 86 | } |
87 | 87 | |
88 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
89 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
90 | - $info = str_replace('^','<br />',$info); |
|
91 | - $info = str_replace('&sect;','',$info); |
|
92 | - $info = str_replace('"','',$info); |
|
88 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
89 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
90 | + $info = str_replace('^', '<br />', $info); |
|
91 | + $info = str_replace('&sect;', '', $info); |
|
92 | + $info = str_replace('"', '', $info); |
|
93 | 93 | if ($type == '') $type = NULL; |
94 | 94 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
95 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
95 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
96 | 96 | try { |
97 | 97 | $sth = $this->db->prepare($query); |
98 | 98 | $sth->execute($query_values); |
99 | - } catch(PDOException $e) { |
|
99 | + } catch (PDOException $e) { |
|
100 | 100 | return "error : ".$e->getMessage(); |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
105 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
106 | - $info = str_replace('^','<br />',$info); |
|
107 | - $info = str_replace('&sect;','',$info); |
|
108 | - $info = str_replace('"','',$info); |
|
104 | + public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
105 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
106 | + $info = str_replace('^', '<br />', $info); |
|
107 | + $info = str_replace('&sect;', '', $info); |
|
108 | + $info = str_replace('"', '', $info); |
|
109 | 109 | if ($type == '') $type = NULL; |
110 | 110 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
111 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
111 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
112 | 112 | try { |
113 | 113 | $sth = $this->db->prepare($query); |
114 | 114 | $sth->execute($query_values); |
115 | - } catch(PDOException $e) { |
|
115 | + } catch (PDOException $e) { |
|
116 | 116 | return "error : ".$e->getMessage(); |
117 | 117 | } |
118 | 118 | } |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $this->db->prepare($query); |
125 | 125 | $sth->execute($query_values); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error : ".$e->getMessage(); |
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | - public function deleteByIdent($ident,$format_source) { |
|
131 | + public function deleteByIdent($ident, $format_source) { |
|
132 | 132 | $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
133 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
133 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
134 | 134 | try { |
135 | 135 | $sth = $this->db->prepare($query); |
136 | 136 | $sth->execute($query_values); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error : ".$e->getMessage(); |
139 | 139 | } |
140 | 140 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | try { |
146 | 146 | $sth = $this->db->prepare($query); |
147 | 147 | $sth->execute($query_values); |
148 | - } catch(PDOException $e) { |
|
148 | + } catch (PDOException $e) { |
|
149 | 149 | return "error : ".$e->getMessage(); |
150 | 150 | } |
151 | 151 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | try { |
161 | 161 | $sth = $this->db->prepare($query); |
162 | 162 | $sth->execute(); |
163 | - } catch(PDOException $e) { |
|
163 | + } catch (PDOException $e) { |
|
164 | 164 | return "error"; |
165 | 165 | } |
166 | 166 | return "success"; |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | die; |
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
48 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
|
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 | 56 | $globalSources = array(); |
57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
57 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
58 | 58 | else $globalSources[] = array('host' => $options['s']); |
59 | 59 | } elseif (isset($options['source'])) { |
60 | 60 | $globalSources = array(); |
61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
61 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
62 | 62 | else $globalSources[] = array('host' => $options['source']); |
63 | 63 | } |
64 | 64 | if (isset($options['aprsserverhost'])) { |
@@ -75,27 +75,27 @@ discard block |
||
75 | 75 | else $id_source = 1; |
76 | 76 | if (isset($globalServer) && $globalServer) { |
77 | 77 | if ($globalDebug) echo "Using Server Mode\n"; |
78 | - $SI=new SpotterServer(); |
|
78 | + $SI = new SpotterServer(); |
|
79 | 79 | /* |
80 | 80 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
81 | 81 | $SI = new adsb2aprs(); |
82 | 82 | $SI->connect(); |
83 | 83 | */ |
84 | -} else $SI=new SpotterImport($Connection->db); |
|
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 | 87 | $AIS = new AIS(); |
88 | 88 | $MI = new MarineImport($Connection->db); |
89 | 89 | } |
90 | 90 | //$APRS=new APRS($Connection->db); |
91 | -$SBS=new SBS(); |
|
92 | -$ACARS=new ACARS($Connection->db); |
|
93 | -$Common=new Common(); |
|
91 | +$SBS = new SBS(); |
|
92 | +$ACARS = new ACARS($Connection->db); |
|
93 | +$Common = new Common(); |
|
94 | 94 | date_default_timezone_set('UTC'); |
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() { |
|
98 | + pcntl_signal(SIGINT, function() { |
|
99 | 99 | global $sockets; |
100 | 100 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
101 | 101 | die("Bye!\n"); |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | |
112 | 112 | function connect_all($hosts) { |
113 | 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; |
|
114 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
115 | 115 | $reset++; |
116 | 116 | if ($globalDebug) echo 'Connect to all...'."\n"; |
117 | 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 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
122 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
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 | 123 | //$formats[$id] = 'deltadbtxt'; |
124 | 124 | $globalSources[$id]['format'] = 'deltadbtxt'; |
125 | 125 | //$last_exec['deltadbtxt'] = 0; |
126 | 126 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
127 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
127 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
128 | 128 | //$formats[$id] = 'vatsimtxt'; |
129 | 129 | $globalSources[$id]['format'] = 'vatsimtxt'; |
130 | 130 | //$last_exec['vatsimtxt'] = 0; |
131 | 131 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
132 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
132 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
133 | 133 | //$formats[$id] = 'aircraftlistjson'; |
134 | 134 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
135 | 135 | //$last_exec['aircraftlistjson'] = 0; |
136 | 136 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
137 | - } else if (preg_match('/opensky/i',$host)) { |
|
137 | + } else if (preg_match('/opensky/i', $host)) { |
|
138 | 138 | //$formats[$id] = 'aircraftlistjson'; |
139 | 139 | $globalSources[$id]['format'] = 'opensky'; |
140 | 140 | //$last_exec['aircraftlistjson'] = 0; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | exit(0); |
152 | 152 | } |
153 | 153 | */ |
154 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
154 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
155 | 155 | //$formats[$id] = 'planeupdatefaa'; |
156 | 156 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
157 | 157 | //$last_exec['planeupdatefaa'] = 0; |
@@ -160,26 +160,26 @@ discard block |
||
160 | 160 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
161 | 161 | exit(0); |
162 | 162 | } |
163 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
163 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
164 | 164 | //$formats[$id] = 'phpvmacars'; |
165 | 165 | $globalSources[$id]['format'] = 'phpvmacars'; |
166 | 166 | //$last_exec['phpvmacars'] = 0; |
167 | 167 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
168 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
168 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
169 | 169 | //$formats[$id] = 'phpvmacars'; |
170 | 170 | $globalSources[$id]['format'] = 'vam'; |
171 | 171 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
172 | - } else if (preg_match('/whazzup/i',$host)) { |
|
172 | + } else if (preg_match('/whazzup/i', $host)) { |
|
173 | 173 | //$formats[$id] = 'whazzup'; |
174 | 174 | $globalSources[$id]['format'] = 'whazzup'; |
175 | 175 | //$last_exec['whazzup'] = 0; |
176 | 176 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
177 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
177 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
178 | 178 | //$formats[$id] = 'pirepsjson'; |
179 | 179 | $globalSources[$id]['format'] = 'pirepsjson'; |
180 | 180 | //$last_exec['pirepsjson'] = 0; |
181 | 181 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
182 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
182 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
183 | 183 | //$formats[$id] = 'fr24json'; |
184 | 184 | $globalSources[$id]['format'] = 'fr24json'; |
185 | 185 | //$last_exec['fr24json'] = 0; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
189 | 189 | exit(0); |
190 | 190 | } |
191 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
191 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
192 | 192 | //$formats[$id] = 'fr24json'; |
193 | 193 | $globalSources[$id]['format'] = 'myshiptracking'; |
194 | 194 | //$last_exec['fr24json'] = 0; |
@@ -198,22 +198,22 @@ discard block |
||
198 | 198 | exit(0); |
199 | 199 | } |
200 | 200 | //} else if (preg_match('/10001/',$host)) { |
201 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
201 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
202 | 202 | //$formats[$id] = 'tsv'; |
203 | 203 | $globalSources[$id]['format'] = 'tsv'; |
204 | 204 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
205 | 205 | } |
206 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
206 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
207 | 207 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
208 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
208 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
209 | 209 | if ($idf !== false) { |
210 | 210 | $httpfeeds[$id] = $idf; |
211 | 211 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
212 | 212 | } |
213 | 213 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
214 | 214 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
215 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
216 | - $hostport = explode(':',$host); |
|
215 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
216 | + $hostport = explode(':', $host); |
|
217 | 217 | if (isset($hostport[1])) { |
218 | 218 | $port = $hostport[1]; |
219 | 219 | $hostn = $hostport[0]; |
@@ -223,19 +223,19 @@ discard block |
||
223 | 223 | } |
224 | 224 | $Common = new Common(); |
225 | 225 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
226 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
226 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
227 | 227 | } else { |
228 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
228 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
229 | 229 | } |
230 | 230 | if ($s) { |
231 | 231 | $sockets[$id] = $s; |
232 | 232 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
233 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
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 | 240 | } elseif ($port == '10001') { |
241 | 241 | //$formats[$id] = 'tsv'; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
275 | 275 | else $timeout = 20; |
276 | 276 | $errno = ''; |
277 | -$errstr=''; |
|
277 | +$errstr = ''; |
|
278 | 278 | |
279 | 279 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
280 | 280 | /* Initiate connections to all the hosts simultaneously */ |
@@ -282,7 +282,7 @@ 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 | 287 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
288 | 288 | } |
@@ -309,16 +309,16 @@ discard block |
||
309 | 309 | |
310 | 310 | if ($use_aprs) { |
311 | 311 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
312 | - $APRS=new APRS(); |
|
312 | + $APRS = new APRS(); |
|
313 | 313 | $aprs_connect = 0; |
314 | 314 | $aprs_keep = 120; |
315 | 315 | $aprs_last_tx = time(); |
316 | 316 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
317 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
317 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
318 | 318 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
319 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
319 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
320 | 320 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
321 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
321 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
322 | 322 | if ($aprs_full) $aprs_filter = ''; |
323 | 323 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
324 | 324 | else $aprs_pass = '-1'; |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | sleep(1); |
333 | 333 | if ($globalDebug) echo "SCAN MODE \n\n"; |
334 | 334 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
335 | -$endtime = time()+$globalCronEnd; |
|
335 | +$endtime = time() + $globalCronEnd; |
|
336 | 336 | $i = 1; |
337 | 337 | $tt = array(); |
338 | 338 | // Delete all ATC |
339 | 339 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
340 | - $ATC=new ATC($Connection->db); |
|
340 | + $ATC = new ATC($Connection->db); |
|
341 | 341 | } |
342 | 342 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
343 | 343 | $ATC->deleteAll(); |
@@ -345,7 +345,7 @@ 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(); |
|
348 | + if (!$globalDaemon) $i = $endtime - time(); |
|
349 | 349 | // Delete old ATC |
350 | 350 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
351 | 351 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | } |
361 | 361 | if ($max != $globalMinFetch) { |
362 | 362 | if ($globalDebug) echo 'Sleeping...'."\n"; |
363 | - sleep($globalMinFetch-$max+2); |
|
363 | + sleep($globalMinFetch - $max + 2); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | //$buffer = $Common->getData($hosts[$id]); |
374 | 374 | $buffer = $Common->getData($value['host']); |
375 | 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); |
|
376 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
377 | + $buffer = explode('\n', $buffer); |
|
378 | 378 | foreach ($buffer as $line) { |
379 | 379 | if ($line != '' && count($line) > 7) { |
380 | 380 | $line = explode(',', $line); |
@@ -402,11 +402,11 @@ discard block |
||
402 | 402 | $last_exec[$id]['last'] = time(); |
403 | 403 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
404 | 404 | date_default_timezone_set('CET'); |
405 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
405 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
406 | 406 | date_default_timezone_set('UTC'); |
407 | 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); |
|
408 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
409 | + $buffer = explode('\n', $buffer); |
|
410 | 410 | foreach ($buffer as $line) { |
411 | 411 | if ($line != '') { |
412 | 412 | echo "'".$line."'\n"; |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
425 | 425 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
426 | 426 | if (isset($ais_data['timestamp'])) { |
427 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
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 | 429 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
430 | 430 | $add = true; |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | $w = $e = null; |
448 | 448 | |
449 | 449 | if (isset($arr[$id])) { |
450 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
450 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
451 | 451 | if ($nn > 0) { |
452 | 452 | foreach ($httpfeeds as $feed) { |
453 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
454 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
455 | - $buffer = explode('\n',$buffer); |
|
453 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
454 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
455 | + $buffer = explode('\n', $buffer); |
|
456 | 456 | foreach ($buffer as $line) { |
457 | 457 | if ($line != '') { |
458 | 458 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
471 | 471 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
472 | 472 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
473 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
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 | 477 | $data['datetime'] = date('Y-m-d H:i:s'); |
478 | 478 | } |
@@ -498,10 +498,10 @@ discard block |
||
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'); |
|
501 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
502 | 502 | if ($buffer != '') { |
503 | 503 | //echo $buffer; |
504 | - $all_data = json_decode($buffer,true); |
|
504 | + $all_data = json_decode($buffer, true); |
|
505 | 505 | //print_r($all_data); |
506 | 506 | if (isset($all_data[0]['DATA'])) { |
507 | 507 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
517 | 517 | $data['imo'] = $line['IMO']; |
518 | 518 | //$data['arrival_code'] = $ais_data['destination']; |
519 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
519 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
520 | 520 | $data['format_source'] = 'myshiptracking'; |
521 | 521 | $data['id_source'] = $id_source; |
522 | 522 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -528,9 +528,9 @@ discard block |
||
528 | 528 | } |
529 | 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'])); |
|
531 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
532 | 532 | if ($buffer != '') { |
533 | - $all_data = json_decode($buffer,true); |
|
533 | + $all_data = json_decode($buffer, true); |
|
534 | 534 | if (isset($all_data[0]['mmsi'])) { |
535 | 535 | foreach ($all_data as $line) { |
536 | 536 | if ($line != '') { |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
560 | 560 | $buffer = $Common->getData($value['host']); |
561 | 561 | if ($buffer != '') { |
562 | - $all_data = json_decode($buffer,true); |
|
562 | + $all_data = json_decode($buffer, true); |
|
563 | 563 | if (isset($all_data['features'][0]['id'])) { |
564 | 564 | foreach ($all_data['features'] as $line) { |
565 | 565 | $data = array(); |
@@ -587,27 +587,27 @@ discard block |
||
587 | 587 | $last_exec[$id]['last'] = time(); |
588 | 588 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
589 | 589 | echo 'download...'; |
590 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
590 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
591 | 591 | echo 'done !'."\n"; |
592 | 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); |
|
593 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
594 | + $buffer = explode('\n', $buffer); |
|
595 | 595 | foreach ($buffer as $line) { |
596 | 596 | if ($line != '') { |
597 | 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)); |
|
598 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
599 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
600 | 600 | //$data['status'] = substr($line,21,2); |
601 | 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)); |
|
602 | + $data['latitude'] = substr($line, 29, 9); |
|
603 | + $data['longitude'] = substr($line, 41, 9); |
|
604 | + $data['speed'] = round(substr($line, 51, 5)); |
|
605 | 605 | //$data['course'] = substr($line,57,5); |
606 | - $data['heading'] = round(substr($line,63,3)); |
|
606 | + $data['heading'] = round(substr($line, 63, 3)); |
|
607 | 607 | //$data['draft'] = substr($line,67,4); |
608 | 608 | //$data['length'] = substr($line,72,3); |
609 | 609 | //$data['beam'] = substr($line,76,2); |
610 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
610 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
611 | 611 | //$data['callsign'] = trim(substr($line,100,7); |
612 | 612 | //$data['dest'] = substr($line,108,20); |
613 | 613 | //$data['etaDate'] = substr($line,129,5); |
@@ -626,8 +626,8 @@ discard block |
||
626 | 626 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
627 | 627 | //$buffer = $Common->getData($hosts[$id]); |
628 | 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); |
|
629 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
630 | + $buffer = explode('\n', $buffer); |
|
631 | 631 | $reset = 0; |
632 | 632 | foreach ($buffer as $line) { |
633 | 633 | if ($line != '') { |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
639 | 639 | $data['pilot_id'] = $line[1]; |
640 | 640 | $data['pilot_name'] = $line[2]; |
641 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
641 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
642 | 642 | $data['ident'] = $line[0]; // ident |
643 | 643 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
644 | 644 | $data['speed'] = $line[8]; // speed |
@@ -654,7 +654,7 @@ discard block |
||
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 | 656 | $data['departure_airport_icao'] = $line[11]; |
657 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
657 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
658 | 658 | $data['arrival_airport_icao'] = $line[13]; |
659 | 659 | $data['frequency'] = $line[4]; |
660 | 660 | $data['type'] = $line[18]; |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | $data['id_source'] = $id_source; |
664 | 664 | //$data['arrival_airport_time'] = ; |
665 | 665 | if ($line[9] != '') { |
666 | - $aircraft_data = explode('/',$line[9]); |
|
666 | + $aircraft_data = explode('/', $line[9]); |
|
667 | 667 | if (isset($aircraft_data[1])) { |
668 | 668 | $data['aircraft_icao'] = $aircraft_data[1]; |
669 | 669 | } |
@@ -678,9 +678,9 @@ discard block |
||
678 | 678 | if ($line[3] == 'PILOT') $SI->add($data); |
679 | 679 | elseif ($line[3] == 'ATC') { |
680 | 680 | //print_r($data); |
681 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
682 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
683 | - $typec = substr($data['ident'],-3); |
|
681 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
682 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
683 | + $typec = substr($data['ident'], -3); |
|
684 | 684 | if ($typec == 'APP') $data['type'] = 'Approach'; |
685 | 685 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
686 | 686 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
693 | 693 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
694 | 694 | if (isset($ATC)) { |
695 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']); |
|
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']); |
|
695 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($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']); |
|
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 | 699 | unset($data); |
@@ -705,9 +705,9 @@ discard block |
||
705 | 705 | $last_exec[$id]['last'] = time(); |
706 | 706 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
707 | 707 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
708 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
708 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
709 | 709 | if ($buffer != '') { |
710 | - $all_data = json_decode($buffer,true); |
|
710 | + $all_data = json_decode($buffer, true); |
|
711 | 711 | if (isset($all_data['acList'])) { |
712 | 712 | $reset = 0; |
713 | 713 | foreach ($all_data['acList'] as $line) { |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | $data['emergency'] = ''; // emergency |
725 | 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)); |
|
727 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
728 | 728 | else $data['datetime'] = date('Y-m-d H:i:s'); |
729 | 729 | |
730 | 730 | //$data['datetime'] = date('Y-m-d H:i:s'); |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | $data['verticalrate'] = $line['vrt']; // verticale rate |
751 | 751 | $data['squawk'] = $line['squawk']; // squawk |
752 | 752 | $data['emergency'] = ''; // emergency |
753 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
753 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
754 | 754 | else $data['datetime'] = date('Y-m-d H:i:s'); |
755 | 755 | $data['format_source'] = 'aircraftlistjson'; |
756 | 756 | $data['id_source'] = $id_source; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
767 | 767 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
768 | 768 | $buffer = $Common->getData($value['host']); |
769 | - $all_data = json_decode($buffer,true); |
|
769 | + $all_data = json_decode($buffer, true); |
|
770 | 770 | if (isset($all_data['planes'])) { |
771 | 771 | $reset = 0; |
772 | 772 | foreach ($all_data['planes'] as $key => $line) { |
@@ -783,12 +783,12 @@ discard block |
||
783 | 783 | $data['emergency'] = ''; // emergency |
784 | 784 | $data['registration'] = $line[2]; |
785 | 785 | $data['aircraft_icao'] = $line[0]; |
786 | - $deparr = explode('-',$line[1]); |
|
786 | + $deparr = explode('-', $line[1]); |
|
787 | 787 | if (count($deparr) == 2) { |
788 | 788 | $data['departure_airport_icao'] = $deparr[0]; |
789 | 789 | $data['arrival_airport_icao'] = $deparr[1]; |
790 | 790 | } |
791 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
791 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
792 | 792 | $data['format_source'] = 'planeupdatefaa'; |
793 | 793 | $data['id_source'] = $id_source; |
794 | 794 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | $last_exec[$id]['last'] = time(); |
802 | 802 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
803 | 803 | $buffer = $Common->getData($value['host']); |
804 | - $all_data = json_decode($buffer,true); |
|
804 | + $all_data = json_decode($buffer, true); |
|
805 | 805 | if (isset($all_data['states'])) { |
806 | 806 | $reset = 0; |
807 | 807 | foreach ($all_data['states'] as $key => $line) { |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | //$data['emergency'] = ''; // emergency |
819 | 819 | //$data['registration'] = $line[2]; |
820 | 820 | //$data['aircraft_icao'] = $line[0]; |
821 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
821 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
822 | 822 | $data['format_source'] = 'opensky'; |
823 | 823 | $data['id_source'] = $id_source; |
824 | 824 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
833 | 833 | //$buffer = $Common->getData($hosts[$id]); |
834 | 834 | $buffer = $Common->getData($value['host']); |
835 | - $all_data = json_decode($buffer,true); |
|
835 | + $all_data = json_decode($buffer, true); |
|
836 | 836 | if (!empty($all_data)) $reset = 0; |
837 | 837 | foreach ($all_data as $key => $line) { |
838 | 838 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -865,11 +865,11 @@ discard block |
||
865 | 865 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
866 | 866 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
867 | 867 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
868 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
868 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
869 | 869 | //echo $buffer; |
870 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
871 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
872 | - $all_data = json_decode($buffer,true); |
|
870 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
871 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
872 | + $all_data = json_decode($buffer, true); |
|
873 | 873 | if (json_last_error() != JSON_ERROR_NONE) { |
874 | 874 | die(json_last_error_msg()); |
875 | 875 | } |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | //$data['departure_airport_iata'] = $line[11]; |
893 | 893 | //$data['arrival_airport_iata'] = $line[12]; |
894 | 894 | //$data['emergency'] = ''; // emergency |
895 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
895 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
896 | 896 | $data['format_source'] = 'radarvirtueljson'; |
897 | 897 | $data['id_source'] = $id_source; |
898 | 898 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -908,14 +908,14 @@ discard block |
||
908 | 908 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
909 | 909 | //$buffer = $Common->getData($hosts[$id]); |
910 | 910 | $buffer = $Common->getData($value['host'].'?'.time()); |
911 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
911 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
912 | 912 | |
913 | 913 | if (isset($all_data['pireps'])) { |
914 | 914 | $reset = 0; |
915 | 915 | foreach ($all_data['pireps'] as $line) { |
916 | 916 | $data = array(); |
917 | 917 | $data['id'] = $line['id']; |
918 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
918 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
919 | 919 | $data['ident'] = $line['callsign']; // ident |
920 | 920 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
921 | 921 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -945,9 +945,9 @@ discard block |
||
945 | 945 | $SI->add($data); |
946 | 946 | // print_r($data); |
947 | 947 | } elseif ($line['icon'] == 'ct') { |
948 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
949 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
950 | - $typec = substr($data['ident'],-3); |
|
948 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
949 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
950 | + $typec = substr($data['ident'], -3); |
|
951 | 951 | $data['type'] = ''; |
952 | 952 | if ($typec == 'APP') $data['type'] = 'Approach'; |
953 | 953 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
959 | 959 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
960 | 960 | else $data['type'] = 'Observer'; |
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']); |
|
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 | 962 | } |
963 | 963 | unset($data); |
964 | 964 | } |
@@ -970,14 +970,14 @@ discard block |
||
970 | 970 | //$buffer = $Common->getData($hosts[$id]); |
971 | 971 | if ($globalDebug) echo 'Get Data...'."\n"; |
972 | 972 | $buffer = $Common->getData($value['host']); |
973 | - $all_data = json_decode($buffer,true); |
|
973 | + $all_data = json_decode($buffer, true); |
|
974 | 974 | if ($buffer != '' && is_array($all_data)) { |
975 | 975 | $reset = 0; |
976 | 976 | foreach ($all_data as $line) { |
977 | 977 | $data = array(); |
978 | 978 | //$data['id'] = $line['id']; // id not usable |
979 | 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 |
|
980 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
981 | 981 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
982 | 982 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
983 | 983 | $data['ident'] = $line['flightnum']; // ident |
@@ -1001,14 +1001,14 @@ discard block |
||
1001 | 1001 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1002 | 1002 | if (isset($line['aircraftname'])) { |
1003 | 1003 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1004 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1005 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1004 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1005 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1006 | 1006 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1007 | 1007 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1008 | 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']); |
|
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 | 1012 | } |
1013 | 1013 | } |
1014 | 1014 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1028,14 +1028,14 @@ discard block |
||
1028 | 1028 | //$buffer = $Common->getData($hosts[$id]); |
1029 | 1029 | if ($globalDebug) echo 'Get Data...'."\n"; |
1030 | 1030 | $buffer = $Common->getData($value['host']); |
1031 | - $all_data = json_decode($buffer,true); |
|
1031 | + $all_data = json_decode($buffer, true); |
|
1032 | 1032 | if ($buffer != '' && is_array($all_data)) { |
1033 | 1033 | $reset = 0; |
1034 | 1034 | foreach ($all_data as $line) { |
1035 | 1035 | $data = array(); |
1036 | 1036 | //$data['id'] = $line['id']; // id not usable |
1037 | 1037 | $data['id'] = trim($line['flight_id']); |
1038 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1038 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1039 | 1039 | $data['pilot_name'] = $line['pilot_name']; |
1040 | 1040 | $data['pilot_id'] = $line['pilot_id']; |
1041 | 1041 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1087,11 +1087,11 @@ discard block |
||
1087 | 1087 | //$value = $formats[$nb]; |
1088 | 1088 | $format = $globalSources[$nb]['format']; |
1089 | 1089 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1090 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1090 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1091 | 1091 | } elseif ($format == 'vrstcp') { |
1092 | 1092 | $buffer = @socket_read($r, 6000); |
1093 | 1093 | } else { |
1094 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1094 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1095 | 1095 | } |
1096 | 1096 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1097 | 1097 | //echo $buffer."\n"; |
@@ -1100,8 +1100,8 @@ discard block |
||
1100 | 1100 | $error = false; |
1101 | 1101 | //$SI::del(); |
1102 | 1102 | if ($format == 'vrstcp') { |
1103 | - $buffer = explode('},{',$buffer); |
|
1104 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1103 | + $buffer = explode('},{', $buffer); |
|
1104 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1105 | 1105 | // SBS format is CSV format |
1106 | 1106 | if ($buffer !== FALSE && $buffer != '') { |
1107 | 1107 | $tt[$format] = 0; |
@@ -1135,13 +1135,13 @@ discard block |
||
1135 | 1135 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1136 | 1136 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1137 | 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']); |
|
1138 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1139 | 1139 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1140 | 1140 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1141 | 1141 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1142 | 1142 | |
1143 | 1143 | if (isset($ais_data['timestamp'])) { |
1144 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1144 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1145 | 1145 | } else { |
1146 | 1146 | $data['datetime'] = date('Y-m-d H:i:s'); |
1147 | 1147 | } |
@@ -1152,10 +1152,10 @@ discard block |
||
1152 | 1152 | } elseif ($format == 'flightgearsp') { |
1153 | 1153 | //echo $buffer."\n"; |
1154 | 1154 | if (strlen($buffer) > 5) { |
1155 | - $line = explode(',',$buffer); |
|
1155 | + $line = explode(',', $buffer); |
|
1156 | 1156 | $data = array(); |
1157 | 1157 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1158 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1158 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1159 | 1159 | $data['ident'] = $line[6]; |
1160 | 1160 | $data['aircraft_name'] = $line[7]; |
1161 | 1161 | $data['longitude'] = $line[1]; |
@@ -1167,21 +1167,21 @@ discard block |
||
1167 | 1167 | $data['format_source'] = 'flightgearsp'; |
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 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1170 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1171 | 1171 | } |
1172 | 1172 | } elseif ($format == 'acars') { |
1173 | 1173 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1174 | 1174 | $ACARS->add(trim($buffer)); |
1175 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1175 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1176 | 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 | - $line = explode(' ',$buffer); |
|
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 |
|
1183 | + $userserver = explode('@', $line[0]); |
|
1184 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1185 | 1185 | $data['ident'] = $userserver[0]; |
1186 | 1186 | $data['registration'] = $userserver[0]; |
1187 | 1187 | $data['latitude'] = $line[4]; |
@@ -1189,8 +1189,8 @@ discard block |
||
1189 | 1189 | $data['altitude'] = $line[6]; |
1190 | 1190 | $data['datetime'] = date('Y-m-d H:i:s'); |
1191 | 1191 | $aircraft_type = $line[10]; |
1192 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1193 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1192 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1193 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1194 | 1194 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1195 | 1195 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1196 | 1196 | } |
@@ -1199,8 +1199,8 @@ discard block |
||
1199 | 1199 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1200 | 1200 | die; |
1201 | 1201 | } elseif ($format == 'vrstcp') { |
1202 | - foreach($buffer as $all_data) { |
|
1203 | - $line = json_decode('{'.$all_data.'}',true); |
|
1202 | + foreach ($buffer as $all_data) { |
|
1203 | + $line = json_decode('{'.$all_data.'}', true); |
|
1204 | 1204 | $data = array(); |
1205 | 1205 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1206 | 1206 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1226,16 +1226,16 @@ discard block |
||
1226 | 1226 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1227 | 1227 | unset($data); |
1228 | 1228 | } |
1229 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1229 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1230 | 1230 | $line = explode("\t", $buffer); |
1231 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1231 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1232 | 1232 | $key = $line[$k]; |
1233 | - $lined[$key] = $line[$k+1]; |
|
1233 | + $lined[$key] = $line[$k + 1]; |
|
1234 | 1234 | } |
1235 | 1235 | if (count($lined) > 3) { |
1236 | 1236 | $data['hex'] = $lined['hexid']; |
1237 | 1237 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1238 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1238 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1239 | 1239 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1240 | 1240 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1241 | 1241 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1254,22 +1254,22 @@ discard block |
||
1254 | 1254 | } else $error = true; |
1255 | 1255 | } elseif ($format == 'aprs' && $use_aprs) { |
1256 | 1256 | if ($aprs_connect == 0) { |
1257 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
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 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1264 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1268 | 1268 | //echo 'APRS data : '.$buffer."\n"; |
1269 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1270 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1269 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1270 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1271 | 1271 | //echo $buffer."\n"; |
1272 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
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']))) { |
@@ -1284,7 +1284,7 @@ discard block |
||
1284 | 1284 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1285 | 1285 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1286 | 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']); |
|
1287 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1288 | 1288 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1289 | 1289 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1290 | 1290 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1413,7 +1413,7 @@ discard block |
||
1413 | 1413 | connect_all($sourceee); |
1414 | 1414 | $sourceee = array(); |
1415 | 1415 | //connect_all($globalSources); |
1416 | - $tt[$format]=0; |
|
1416 | + $tt[$format] = 0; |
|
1417 | 1417 | break; |
1418 | 1418 | } |
1419 | 1419 | } |
@@ -1422,14 +1422,14 @@ discard block |
||
1422 | 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 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
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 | 1429 | if ($globalDebug) echo "Shutdown all sockets..."; |
1430 | 1430 | |
1431 | 1431 | foreach ($sockets as $sock) { |
1432 | - @socket_shutdown($sock,2); |
|
1432 | + @socket_shutdown($sock, 2); |
|
1433 | 1433 | @socket_close($sock); |
1434 | 1434 | } |
1435 | 1435 |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | $ATC = new ATC(); |
6 | 6 | |
7 | 7 | if (isset($_GET['atcid'])) { |
8 | - $atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT); |
|
9 | - $atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING); |
|
8 | + $atcid = filter_input(INPUT_GET, 'atcid', FILTER_SANITIZE_NUMBER_INT); |
|
9 | + $atcident = filter_input(INPUT_GET, 'atcident', FILTER_SANITIZE_STRING); |
|
10 | 10 | $atc_data = $ATC->getById($atcid); |
11 | 11 | if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident); |
12 | 12 | ?> |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | print '</div>'; |
39 | 39 | |
40 | 40 | //print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
41 | -print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>'; |
|
41 | +print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 3).', '.round($spotter_item['longitude'], 3).'</div>'; |
|
42 | 42 | if ($spotter_item['atc_range'] > 0) { |
43 | 43 | print '<div><span>'._("Range").'</span>'; |
44 | 44 | print $spotter_item['atc_range']; |