@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | try { |
16 | 16 | $sth = $this->db->prepare($query); |
17 | 17 | $sth->execute($query_values); |
18 | - } catch(PDOException $e) { |
|
18 | + } catch (PDOException $e) { |
|
19 | 19 | return "error : ".$e->getMessage(); |
20 | 20 | } |
21 | 21 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | try { |
29 | 29 | $sth = $this->db->prepare($query); |
30 | 30 | $sth->execute($query_values); |
31 | - } catch(PDOException $e) { |
|
31 | + } catch (PDOException $e) { |
|
32 | 32 | return "error : ".$e->getMessage(); |
33 | 33 | } |
34 | 34 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | 35 | return $all; |
36 | 36 | } |
37 | 37 | |
38 | - public function getLocationInfobyNameType($name,$type) { |
|
38 | + public function getLocationInfobyNameType($name, $type) { |
|
39 | 39 | $query = "SELECT * FROM source_location WHERE name = :name AND type = :type"; |
40 | - $query_values = array(':name' => $name,':type' => $type); |
|
40 | + $query_values = array(':name' => $name, ':type' => $type); |
|
41 | 41 | try { |
42 | 42 | $sth = $this->db->prepare($query); |
43 | 43 | $sth->execute($query_values); |
44 | - } catch(PDOException $e) { |
|
44 | + } catch (PDOException $e) { |
|
45 | 45 | return "error : ".$e->getMessage(); |
46 | 46 | } |
47 | 47 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | try { |
55 | 55 | $sth = $this->db->prepare($query); |
56 | 56 | $sth->execute($query_values); |
57 | - } catch(PDOException $e) { |
|
57 | + } catch (PDOException $e) { |
|
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | try { |
68 | 68 | $sth = $this->db->prepare($query); |
69 | 69 | $sth->execute($query_values); |
70 | - } catch(PDOException $e) { |
|
70 | + } catch (PDOException $e) { |
|
71 | 71 | return "error : ".$e->getMessage(); |
72 | 72 | } |
73 | 73 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | try { |
81 | 81 | $sth = $this->db->prepare($query); |
82 | 82 | $sth->execute($query_values); |
83 | - } catch(PDOException $e) { |
|
83 | + } catch (PDOException $e) { |
|
84 | 84 | return "error : ".$e->getMessage(); |
85 | 85 | } |
86 | 86 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -93,56 +93,56 @@ discard block |
||
93 | 93 | try { |
94 | 94 | $sth = $this->db->prepare($query); |
95 | 95 | $sth->execute($query_values); |
96 | - } catch(PDOException $e) { |
|
96 | + } catch (PDOException $e) { |
|
97 | 97 | return "error : ".$e->getMessage(); |
98 | 98 | } |
99 | 99 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
100 | 100 | return $all; |
101 | 101 | } |
102 | 102 | |
103 | - public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
|
103 | + public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
104 | 104 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
105 | 105 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
106 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
106 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
107 | 107 | try { |
108 | 108 | $sth = $this->db->prepare($query); |
109 | 109 | $sth->execute($query_values); |
110 | - } catch(PDOException $e) { |
|
110 | + } catch (PDOException $e) { |
|
111 | 111 | echo "error : ".$e->getMessage(); |
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
|
115 | + public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { |
|
116 | 116 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
117 | 117 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
118 | - $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
118 | + $query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
119 | 119 | try { |
120 | 120 | $sth = $this->db->prepare($query); |
121 | 121 | $sth->execute($query_values); |
122 | - } catch(PDOException $e) { |
|
122 | + } catch (PDOException $e) { |
|
123 | 123 | return "error : ".$e->getMessage(); |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | - public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') { |
|
127 | + public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') { |
|
128 | 128 | $query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source"; |
129 | - $query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description); |
|
129 | + $query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description); |
|
130 | 130 | try { |
131 | 131 | $sth = $this->db->prepare($query); |
132 | 132 | $sth->execute($query_values); |
133 | - } catch(PDOException $e) { |
|
133 | + } catch (PDOException $e) { |
|
134 | 134 | return "error : ".$e->getMessage(); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
|
138 | + public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') { |
|
139 | 139 | if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
140 | 140 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
141 | - $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
|
141 | + $query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); |
|
142 | 142 | try { |
143 | 143 | $sth = $this->db->prepare($query); |
144 | 144 | $sth->execute($query_values); |
145 | - } catch(PDOException $e) { |
|
145 | + } catch (PDOException $e) { |
|
146 | 146 | echo "error : ".$e->getMessage(); |
147 | 147 | } |
148 | 148 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | try { |
154 | 154 | $sth = $this->db->prepare($query); |
155 | 155 | $sth->execute($query_values); |
156 | - } catch(PDOException $e) { |
|
156 | + } catch (PDOException $e) { |
|
157 | 157 | return "error : ".$e->getMessage(); |
158 | 158 | } |
159 | 159 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $this->db->prepare($query); |
166 | 166 | $sth->execute($query_values); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error : ".$e->getMessage(); |
169 | 169 | } |
170 | 170 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | try { |
176 | 176 | $sth = $this->db->prepare($query); |
177 | 177 | $sth->execute($query_values); |
178 | - } catch(PDOException $e) { |
|
178 | + } catch (PDOException $e) { |
|
179 | 179 | return "error : ".$e->getMessage(); |
180 | 180 | } |
181 | 181 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | try { |
186 | 186 | $sth = $this->db->prepare($query); |
187 | 187 | $sth->execute(); |
188 | - } catch(PDOException $e) { |
|
188 | + } catch (PDOException $e) { |
|
189 | 189 | return "error : ".$e->getMessage(); |
190 | 190 | } |
191 | 191 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | try { |
215 | 215 | $sth = $this->db->prepare($query); |
216 | 216 | $sth->execute(array(':type' => $type)); |
217 | - } catch(PDOException $e) { |
|
217 | + } catch (PDOException $e) { |
|
218 | 218 | return "error"; |
219 | 219 | } |
220 | 220 | return "success"; |
@@ -46,20 +46,20 @@ discard block |
||
46 | 46 | die; |
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
49 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
|
53 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); |
|
54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 56 | if (isset($options['s'])) { |
57 | 57 | $globalSources = array(); |
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
59 | 59 | else $globalSources[] = array('host' => $options['s']); |
60 | 60 | } elseif (isset($options['source'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['source']); |
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
@@ -76,28 +76,28 @@ discard block |
||
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | 78 | if ($globalDebug) echo "Using Server Mode\n"; |
79 | - $SI=new SpotterServer(); |
|
79 | + $SI = new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
83 | 83 | $SI->connect(); |
84 | 84 | */ |
85 | -} else $SI=new SpotterImport($Connection->db); |
|
85 | +} else $SI = new SpotterImport($Connection->db); |
|
86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
87 | 87 | if (isset($globalMarine) && $globalMarine) { |
88 | 88 | $AIS = new AIS(); |
89 | 89 | $MI = new MarineImport($Connection->db); |
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | -$SBS=new SBS(); |
|
93 | -$ACARS=new ACARS($Connection->db); |
|
94 | -$Source=new Source($Connection->db); |
|
95 | -$Common=new Common(); |
|
92 | +$SBS = new SBS(); |
|
93 | +$ACARS = new ACARS($Connection->db); |
|
94 | +$Source = new Source($Connection->db); |
|
95 | +$Common = new Common(); |
|
96 | 96 | date_default_timezone_set('UTC'); |
97 | 97 | //$servertz = system('date +%Z'); |
98 | 98 | // signal handler - playing nice with sockets and dump1090 |
99 | 99 | if (function_exists('pcntl_fork')) { |
100 | - pcntl_signal(SIGINT, function() { |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | 101 | global $sockets; |
102 | 102 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
103 | 103 | die("Bye!\n"); |
@@ -113,30 +113,30 @@ discard block |
||
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
115 | 115 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
116 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
117 | 117 | $reset++; |
118 | 118 | if ($globalDebug) echo 'Connect to all...'."\n"; |
119 | 119 | foreach ($hosts as $id => $value) { |
120 | 120 | $host = $value['host']; |
121 | 121 | $globalSources[$id]['last_exec'] = 0; |
122 | 122 | // Here we check type of source(s) |
123 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'deltadbtxt'; |
126 | 126 | $globalSources[$id]['format'] = 'deltadbtxt'; |
127 | 127 | //$last_exec['deltadbtxt'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'vatsimtxt'; |
131 | 131 | $globalSources[$id]['format'] = 'vatsimtxt'; |
132 | 132 | //$last_exec['vatsimtxt'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
134 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'aircraftlistjson'; |
136 | 136 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
137 | 137 | //$last_exec['aircraftlistjson'] = 0; |
138 | 138 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
139 | + } else if (preg_match('/opensky/i', $host)) { |
|
140 | 140 | //$formats[$id] = 'aircraftlistjson'; |
141 | 141 | $globalSources[$id]['format'] = 'opensky'; |
142 | 142 | //$last_exec['aircraftlistjson'] = 0; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
157 | 157 | //$formats[$id] = 'planeupdatefaa'; |
158 | 158 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
159 | 159 | //$last_exec['planeupdatefaa'] = 0; |
@@ -162,32 +162,32 @@ discard block |
||
162 | 162 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
163 | 163 | exit(0); |
164 | 164 | } |
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
166 | 166 | //$formats[$id] = 'phpvmacars'; |
167 | 167 | $globalSources[$id]['format'] = 'phpvmacars'; |
168 | 168 | //$last_exec['phpvmacars'] = 0; |
169 | 169 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
170 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
171 | 171 | //$formats[$id] = 'phpvmacars'; |
172 | 172 | $globalSources[$id]['format'] = 'vam'; |
173 | 173 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
174 | + } else if (preg_match('/whazzup/i', $host)) { |
|
175 | 175 | //$formats[$id] = 'whazzup'; |
176 | 176 | $globalSources[$id]['format'] = 'whazzup'; |
177 | 177 | //$last_exec['whazzup'] = 0; |
178 | 178 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
179 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
179 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
180 | 180 | $globalSources[$id]['format'] = 'blitzortung'; |
181 | 181 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
182 | - } else if (preg_match('/airwhere/i',$host)) { |
|
182 | + } else if (preg_match('/airwhere/i', $host)) { |
|
183 | 183 | $globalSources[$id]['format'] = 'airwhere'; |
184 | 184 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
185 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
185 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
186 | 186 | //$formats[$id] = 'pirepsjson'; |
187 | 187 | $globalSources[$id]['format'] = 'pirepsjson'; |
188 | 188 | //$last_exec['pirepsjson'] = 0; |
189 | 189 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
190 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
190 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
191 | 191 | //$formats[$id] = 'fr24json'; |
192 | 192 | $globalSources[$id]['format'] = 'fr24json'; |
193 | 193 | //$last_exec['fr24json'] = 0; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
197 | 197 | exit(0); |
198 | 198 | } |
199 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
199 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
200 | 200 | //$formats[$id] = 'fr24json'; |
201 | 201 | $globalSources[$id]['format'] = 'myshiptracking'; |
202 | 202 | //$last_exec['fr24json'] = 0; |
@@ -206,22 +206,22 @@ discard block |
||
206 | 206 | exit(0); |
207 | 207 | } |
208 | 208 | //} else if (preg_match('/10001/',$host)) { |
209 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
209 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
210 | 210 | //$formats[$id] = 'tsv'; |
211 | 211 | $globalSources[$id]['format'] = 'tsv'; |
212 | 212 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
213 | 213 | } |
214 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
214 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
215 | 215 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
216 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
216 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
217 | 217 | if ($idf !== false) { |
218 | 218 | $httpfeeds[$id] = $idf; |
219 | 219 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
220 | 220 | } |
221 | 221 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
222 | 222 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
223 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
224 | - $hostport = explode(':',$host); |
|
223 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
224 | + $hostport = explode(':', $host); |
|
225 | 225 | if (isset($hostport[1])) { |
226 | 226 | $port = $hostport[1]; |
227 | 227 | $hostn = $hostport[0]; |
@@ -231,19 +231,19 @@ discard block |
||
231 | 231 | } |
232 | 232 | $Common = new Common(); |
233 | 233 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
234 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
234 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
235 | 235 | } else { |
236 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
236 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
237 | 237 | } |
238 | 238 | if ($s) { |
239 | 239 | $sockets[$id] = $s; |
240 | 240 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
241 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
241 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
242 | 242 | //$formats[$id] = 'aprs'; |
243 | 243 | $globalSources[$id]['format'] = 'aprs'; |
244 | 244 | //$aprs_connect = 0; |
245 | 245 | //$use_aprs = true; |
246 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
246 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
247 | 247 | $globalSources[$id]['format'] = 'vrstcp'; |
248 | 248 | } elseif ($port == '10001') { |
249 | 249 | //$formats[$id] = 'tsv'; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
283 | 283 | else $timeout = 20; |
284 | 284 | $errno = ''; |
285 | -$errstr=''; |
|
285 | +$errstr = ''; |
|
286 | 286 | |
287 | 287 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
288 | 288 | /* Initiate connections to all the hosts simultaneously */ |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | //connect_all($globalSources); |
291 | 291 | |
292 | 292 | if (isset($globalProxy) && $globalProxy) { |
293 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
293 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
294 | 294 | } else { |
295 | 295 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
296 | 296 | } |
@@ -320,16 +320,16 @@ discard block |
||
320 | 320 | |
321 | 321 | if ($use_aprs) { |
322 | 322 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
323 | - $APRS=new APRS(); |
|
323 | + $APRS = new APRS(); |
|
324 | 324 | $aprs_connect = 0; |
325 | 325 | $aprs_keep = 120; |
326 | 326 | $aprs_last_tx = time(); |
327 | 327 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
328 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
328 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
329 | 329 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
330 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
330 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
331 | 331 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
332 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
332 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
333 | 333 | if ($aprs_full) $aprs_filter = ''; |
334 | 334 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
335 | 335 | else $aprs_pass = '-1'; |
@@ -343,12 +343,12 @@ discard block |
||
343 | 343 | sleep(1); |
344 | 344 | if ($globalDebug) echo "SCAN MODE \n\n"; |
345 | 345 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
346 | -$endtime = time()+$globalCronEnd; |
|
346 | +$endtime = time() + $globalCronEnd; |
|
347 | 347 | $i = 1; |
348 | 348 | $tt = array(); |
349 | 349 | // Delete all ATC |
350 | 350 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
351 | - $ATC=new ATC($Connection->db); |
|
351 | + $ATC = new ATC($Connection->db); |
|
352 | 352 | } |
353 | 353 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
354 | 354 | $ATC->deleteAll(); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | |
357 | 357 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
358 | 358 | while ($i > 0) { |
359 | - if (!$globalDaemon) $i = $endtime-time(); |
|
359 | + if (!$globalDaemon) $i = $endtime - time(); |
|
360 | 360 | // Delete old ATC |
361 | 361 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
362 | 362 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | if ($max != $globalMinFetch) { |
372 | 372 | if ($globalDebug) echo 'Sleeping...'."\n"; |
373 | - sleep($globalMinFetch-$max+2); |
|
373 | + sleep($globalMinFetch - $max + 2); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | //$buffer = $Common->getData($hosts[$id]); |
384 | 384 | $buffer = $Common->getData($value['host']); |
385 | 385 | if ($buffer != '') $reset = 0; |
386 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
387 | - $buffer = explode('\n',$buffer); |
|
386 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
387 | + $buffer = explode('\n', $buffer); |
|
388 | 388 | foreach ($buffer as $line) { |
389 | 389 | if ($line != '' && count($line) > 7) { |
390 | 390 | $line = explode(',', $line); |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | $last_exec[$id]['last'] = time(); |
413 | 413 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
414 | 414 | date_default_timezone_set('CET'); |
415 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
415 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
416 | 416 | date_default_timezone_set('UTC'); |
417 | 417 | if ($buffer != '') $reset = 0; |
418 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
419 | - $buffer = explode('\n',$buffer); |
|
418 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
419 | + $buffer = explode('\n', $buffer); |
|
420 | 420 | foreach ($buffer as $line) { |
421 | 421 | if ($line != '') { |
422 | 422 | //echo "'".$line."'\n"; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
435 | 435 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
436 | 436 | if (isset($ais_data['timestamp'])) { |
437 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
437 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
438 | 438 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
439 | 439 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
440 | 440 | $add = true; |
@@ -457,12 +457,12 @@ discard block |
||
457 | 457 | $w = $e = null; |
458 | 458 | |
459 | 459 | if (isset($arr[$id])) { |
460 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
460 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
461 | 461 | if ($nn > 0) { |
462 | 462 | foreach ($httpfeeds as $feed) { |
463 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
464 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
465 | - $buffer = explode('\n',$buffer); |
|
463 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
464 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
465 | + $buffer = explode('\n', $buffer); |
|
466 | 466 | foreach ($buffer as $line) { |
467 | 467 | if ($line != '') { |
468 | 468 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -480,9 +480,9 @@ discard block |
||
480 | 480 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
481 | 481 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
482 | 482 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
483 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
483 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
484 | 484 | if (isset($ais_data['timestamp'])) { |
485 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
485 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
486 | 486 | } else { |
487 | 487 | $data['datetime'] = date('Y-m-d H:i:s'); |
488 | 488 | } |
@@ -508,10 +508,10 @@ discard block |
||
508 | 508 | } |
509 | 509 | } |
510 | 510 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
511 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
511 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
512 | 512 | if ($buffer != '') { |
513 | 513 | //echo $buffer; |
514 | - $all_data = json_decode($buffer,true); |
|
514 | + $all_data = json_decode($buffer, true); |
|
515 | 515 | //print_r($all_data); |
516 | 516 | if (isset($all_data[0]['DATA'])) { |
517 | 517 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
527 | 527 | $data['imo'] = $line['IMO']; |
528 | 528 | //$data['arrival_code'] = $ais_data['destination']; |
529 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
529 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
530 | 530 | $data['format_source'] = 'myshiptracking'; |
531 | 531 | $data['id_source'] = $id_source; |
532 | 532 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | } |
539 | 539 | $last_exec[$id]['last'] = time(); |
540 | 540 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
541 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
541 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
542 | 542 | if ($buffer != '') { |
543 | - $all_data = json_decode($buffer,true); |
|
543 | + $all_data = json_decode($buffer, true); |
|
544 | 544 | if (isset($all_data[0]['mmsi'])) { |
545 | 545 | foreach ($all_data as $line) { |
546 | 546 | if ($line != '') { |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
570 | 570 | $buffer = $Common->getData($value['host']); |
571 | 571 | if ($buffer != '') { |
572 | - $all_data = json_decode($buffer,true); |
|
572 | + $all_data = json_decode($buffer, true); |
|
573 | 573 | if (isset($all_data['features'][0]['id'])) { |
574 | 574 | foreach ($all_data['features'] as $line) { |
575 | 575 | $data = array(); |
@@ -597,27 +597,27 @@ discard block |
||
597 | 597 | $last_exec[$id]['last'] = time(); |
598 | 598 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
599 | 599 | echo 'download...'; |
600 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
600 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
601 | 601 | echo 'done !'."\n"; |
602 | 602 | if ($buffer != '') $reset = 0; |
603 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
604 | - $buffer = explode('\n',$buffer); |
|
603 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
604 | + $buffer = explode('\n', $buffer); |
|
605 | 605 | foreach ($buffer as $line) { |
606 | 606 | if ($line != '') { |
607 | 607 | $data = array(); |
608 | - $data['mmsi'] = (int)substr($line,0,9); |
|
609 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
608 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
609 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
610 | 610 | //$data['status'] = substr($line,21,2); |
611 | 611 | //$data['type'] = substr($line,24,3); |
612 | - $data['latitude'] = substr($line,29,9); |
|
613 | - $data['longitude'] = substr($line,41,9); |
|
614 | - $data['speed'] = round(substr($line,51,5)); |
|
612 | + $data['latitude'] = substr($line, 29, 9); |
|
613 | + $data['longitude'] = substr($line, 41, 9); |
|
614 | + $data['speed'] = round(substr($line, 51, 5)); |
|
615 | 615 | //$data['course'] = substr($line,57,5); |
616 | - $data['heading'] = round(substr($line,63,3)); |
|
616 | + $data['heading'] = round(substr($line, 63, 3)); |
|
617 | 617 | //$data['draft'] = substr($line,67,4); |
618 | 618 | //$data['length'] = substr($line,72,3); |
619 | 619 | //$data['beam'] = substr($line,76,2); |
620 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
620 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
621 | 621 | //$data['callsign'] = trim(substr($line,100,7); |
622 | 622 | //$data['dest'] = substr($line,108,20); |
623 | 623 | //$data['etaDate'] = substr($line,129,5); |
@@ -636,8 +636,8 @@ discard block |
||
636 | 636 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
637 | 637 | //$buffer = $Common->getData($hosts[$id]); |
638 | 638 | $buffer = $Common->getData($value['host']); |
639 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
640 | - $buffer = explode('\n',$buffer); |
|
639 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
640 | + $buffer = explode('\n', $buffer); |
|
641 | 641 | $reset = 0; |
642 | 642 | foreach ($buffer as $line) { |
643 | 643 | if ($line != '') { |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
649 | 649 | $data['pilot_id'] = $line[1]; |
650 | 650 | $data['pilot_name'] = $line[2]; |
651 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
651 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
652 | 652 | $data['ident'] = $line[0]; // ident |
653 | 653 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
654 | 654 | $data['speed'] = $line[8]; // speed |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
665 | 665 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
666 | 666 | $data['departure_airport_icao'] = $line[11]; |
667 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
667 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
668 | 668 | $data['arrival_airport_icao'] = $line[13]; |
669 | 669 | $data['frequency'] = $line[4]; |
670 | 670 | $data['type'] = $line[18]; |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | $data['id_source'] = $id_source; |
674 | 674 | //$data['arrival_airport_time'] = ; |
675 | 675 | if ($line[9] != '') { |
676 | - $aircraft_data = explode('/',$line[9]); |
|
676 | + $aircraft_data = explode('/', $line[9]); |
|
677 | 677 | if (isset($aircraft_data[1])) { |
678 | 678 | $data['aircraft_icao'] = $aircraft_data[1]; |
679 | 679 | } |
@@ -688,9 +688,9 @@ discard block |
||
688 | 688 | if ($line[3] == 'PILOT') $SI->add($data); |
689 | 689 | elseif ($line[3] == 'ATC') { |
690 | 690 | //print_r($data); |
691 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
692 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
693 | - $typec = substr($data['ident'],-3); |
|
691 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
692 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
693 | + $typec = substr($data['ident'], -3); |
|
694 | 694 | if ($typec == 'APP') $data['type'] = 'Approach'; |
695 | 695 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
696 | 696 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -702,8 +702,8 @@ discard block |
||
702 | 702 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
703 | 703 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
704 | 704 | if (isset($ATC)) { |
705 | - 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']); |
|
706 | - 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']); |
|
705 | + 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']); |
|
706 | + 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']); |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | unset($data); |
@@ -714,24 +714,24 @@ discard block |
||
714 | 714 | //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
715 | 715 | $last_exec[$id]['last'] = time(); |
716 | 716 | } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
717 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
717 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
718 | 718 | if ($buffer != '') { |
719 | 719 | $all_data = simplexml_load_string($buffer); |
720 | - foreach($all_data->children() as $childdata) { |
|
720 | + foreach ($all_data->children() as $childdata) { |
|
721 | 721 | $data = array(); |
722 | 722 | $line = $childdata; |
723 | 723 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
724 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
725 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
726 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
727 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
728 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
729 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
730 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
724 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
725 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
726 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
727 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
728 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
729 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
730 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
731 | 731 | $data['altitude_relative'] = 'AMSL'; |
732 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
732 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
733 | 733 | $data['aircraft_icao'] = 'PARAGLIDER'; |
734 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
734 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
735 | 735 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
736 | 736 | $data['format_source'] = $value['format']; |
737 | 737 | $SI->add($data); |
@@ -739,31 +739,31 @@ discard block |
||
739 | 739 | } |
740 | 740 | } |
741 | 741 | $Source->deleteOldLocationByType('gs'); |
742 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
742 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
743 | 743 | if ($buffer != '') { |
744 | 744 | $all_data = simplexml_load_string($buffer); |
745 | - foreach($all_data->children() as $childdata) { |
|
745 | + foreach ($all_data->children() as $childdata) { |
|
746 | 746 | $data = array(); |
747 | 747 | $line = $childdata; |
748 | - $data['id'] = (int)$line['gsID']; |
|
749 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
750 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
751 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
748 | + $data['id'] = (int) $line['gsID']; |
|
749 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
750 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
751 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
752 | 752 | $data['altitude_relative'] = 'AMSL'; |
753 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
753 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
754 | 754 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
755 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
755 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
756 | 756 | } else { |
757 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
757 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
758 | 758 | } |
759 | 759 | unset($data); |
760 | 760 | } |
761 | 761 | } |
762 | 762 | $last_exec[$id]['last'] = time(); |
763 | 763 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
764 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
764 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
765 | 765 | if ($buffer != '') { |
766 | - $all_data = json_decode($buffer,true); |
|
766 | + $all_data = json_decode($buffer, true); |
|
767 | 767 | if (isset($all_data['acList'])) { |
768 | 768 | $reset = 0; |
769 | 769 | foreach ($all_data['acList'] as $line) { |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | $data['emergency'] = ''; // emergency |
781 | 781 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
782 | 782 | |
783 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
783 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
784 | 784 | else $data['datetime'] = date('Y-m-d H:i:s'); |
785 | 785 | |
786 | 786 | //$data['datetime'] = date('Y-m-d H:i:s'); |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | $data['verticalrate'] = $line['vrt']; // verticale rate |
807 | 807 | $data['squawk'] = $line['squawk']; // squawk |
808 | 808 | $data['emergency'] = ''; // emergency |
809 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
809 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
810 | 810 | else $data['datetime'] = date('Y-m-d H:i:s'); |
811 | 811 | $data['format_source'] = 'aircraftlistjson'; |
812 | 812 | $data['id_source'] = $id_source; |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
823 | 823 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
824 | 824 | $buffer = $Common->getData($value['host']); |
825 | - $all_data = json_decode($buffer,true); |
|
825 | + $all_data = json_decode($buffer, true); |
|
826 | 826 | if (isset($all_data['planes'])) { |
827 | 827 | $reset = 0; |
828 | 828 | foreach ($all_data['planes'] as $key => $line) { |
@@ -839,12 +839,12 @@ discard block |
||
839 | 839 | $data['emergency'] = ''; // emergency |
840 | 840 | $data['registration'] = $line[2]; |
841 | 841 | $data['aircraft_icao'] = $line[0]; |
842 | - $deparr = explode('-',$line[1]); |
|
842 | + $deparr = explode('-', $line[1]); |
|
843 | 843 | if (count($deparr) == 2) { |
844 | 844 | $data['departure_airport_icao'] = $deparr[0]; |
845 | 845 | $data['arrival_airport_icao'] = $deparr[1]; |
846 | 846 | } |
847 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
847 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
848 | 848 | $data['format_source'] = 'planeupdatefaa'; |
849 | 849 | $data['id_source'] = $id_source; |
850 | 850 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | $last_exec[$id]['last'] = time(); |
858 | 858 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
859 | 859 | $buffer = $Common->getData($value['host']); |
860 | - $all_data = json_decode($buffer,true); |
|
860 | + $all_data = json_decode($buffer, true); |
|
861 | 861 | if (isset($all_data['states'])) { |
862 | 862 | $reset = 0; |
863 | 863 | foreach ($all_data['states'] as $key => $line) { |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | //$data['emergency'] = ''; // emergency |
875 | 875 | //$data['registration'] = $line[2]; |
876 | 876 | //$data['aircraft_icao'] = $line[0]; |
877 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
877 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
878 | 878 | $data['format_source'] = 'opensky'; |
879 | 879 | $data['id_source'] = $id_source; |
880 | 880 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
889 | 889 | //$buffer = $Common->getData($hosts[$id]); |
890 | 890 | $buffer = $Common->getData($value['host']); |
891 | - $all_data = json_decode($buffer,true); |
|
891 | + $all_data = json_decode($buffer, true); |
|
892 | 892 | if (!empty($all_data)) $reset = 0; |
893 | 893 | foreach ($all_data as $key => $line) { |
894 | 894 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -921,11 +921,11 @@ discard block |
||
921 | 921 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
922 | 922 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
923 | 923 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
924 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
924 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
925 | 925 | //echo $buffer; |
926 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
927 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
928 | - $all_data = json_decode($buffer,true); |
|
926 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
927 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
928 | + $all_data = json_decode($buffer, true); |
|
929 | 929 | if (json_last_error() != JSON_ERROR_NONE) { |
930 | 930 | die(json_last_error_msg()); |
931 | 931 | } |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | //$data['departure_airport_iata'] = $line[11]; |
949 | 949 | //$data['arrival_airport_iata'] = $line[12]; |
950 | 950 | //$data['emergency'] = ''; // emergency |
951 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
951 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
952 | 952 | $data['format_source'] = 'radarvirtueljson'; |
953 | 953 | $data['id_source'] = $id_source; |
954 | 954 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -964,14 +964,14 @@ discard block |
||
964 | 964 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
965 | 965 | //$buffer = $Common->getData($hosts[$id]); |
966 | 966 | $buffer = $Common->getData($value['host'].'?'.time()); |
967 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
967 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
968 | 968 | |
969 | 969 | if (isset($all_data['pireps'])) { |
970 | 970 | $reset = 0; |
971 | 971 | foreach ($all_data['pireps'] as $line) { |
972 | 972 | $data = array(); |
973 | 973 | $data['id'] = $line['id']; |
974 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
974 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
975 | 975 | $data['ident'] = $line['callsign']; // ident |
976 | 976 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
977 | 977 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1001,9 +1001,9 @@ discard block |
||
1001 | 1001 | $SI->add($data); |
1002 | 1002 | // print_r($data); |
1003 | 1003 | } elseif ($line['icon'] == 'ct') { |
1004 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1005 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1006 | - $typec = substr($data['ident'],-3); |
|
1004 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1005 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1006 | + $typec = substr($data['ident'], -3); |
|
1007 | 1007 | $data['type'] = ''; |
1008 | 1008 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1009 | 1009 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1015 | 1015 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1016 | 1016 | else $data['type'] = 'Observer'; |
1017 | - 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']); |
|
1017 | + 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']); |
|
1018 | 1018 | } |
1019 | 1019 | unset($data); |
1020 | 1020 | } |
@@ -1026,14 +1026,14 @@ discard block |
||
1026 | 1026 | //$buffer = $Common->getData($hosts[$id]); |
1027 | 1027 | if ($globalDebug) echo 'Get Data...'."\n"; |
1028 | 1028 | $buffer = $Common->getData($value['host']); |
1029 | - $all_data = json_decode($buffer,true); |
|
1029 | + $all_data = json_decode($buffer, true); |
|
1030 | 1030 | if ($buffer != '' && is_array($all_data)) { |
1031 | 1031 | $reset = 0; |
1032 | 1032 | foreach ($all_data as $line) { |
1033 | 1033 | $data = array(); |
1034 | 1034 | //$data['id'] = $line['id']; // id not usable |
1035 | 1035 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1036 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1036 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1037 | 1037 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1038 | 1038 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1039 | 1039 | $data['ident'] = $line['flightnum']; // ident |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | //$data['datetime'] = $line['lastupdate']; |
1049 | 1049 | //$data['last_update'] = $line['lastupdate']; |
1050 | 1050 | if (isset($value['timezone'])) { |
1051 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1051 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1052 | 1052 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1053 | 1053 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1054 | 1054 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1061,14 +1061,14 @@ discard block |
||
1061 | 1061 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1062 | 1062 | if (isset($line['aircraftname'])) { |
1063 | 1063 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1064 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1065 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1064 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1065 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1066 | 1066 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1067 | 1067 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1068 | 1068 | else { |
1069 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1070 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1071 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1069 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1070 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1071 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1072 | 1072 | } |
1073 | 1073 | } |
1074 | 1074 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1088,14 +1088,14 @@ discard block |
||
1088 | 1088 | //$buffer = $Common->getData($hosts[$id]); |
1089 | 1089 | if ($globalDebug) echo 'Get Data...'."\n"; |
1090 | 1090 | $buffer = $Common->getData($value['host']); |
1091 | - $all_data = json_decode($buffer,true); |
|
1091 | + $all_data = json_decode($buffer, true); |
|
1092 | 1092 | if ($buffer != '' && is_array($all_data)) { |
1093 | 1093 | $reset = 0; |
1094 | 1094 | foreach ($all_data as $line) { |
1095 | 1095 | $data = array(); |
1096 | 1096 | //$data['id'] = $line['id']; // id not usable |
1097 | 1097 | $data['id'] = trim($line['flight_id']); |
1098 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1098 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1099 | 1099 | $data['pilot_name'] = $line['pilot_name']; |
1100 | 1100 | $data['pilot_id'] = $line['pilot_id']; |
1101 | 1101 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1134,24 +1134,24 @@ discard block |
||
1134 | 1134 | //$buffer = $Common->getData($hosts[$id]); |
1135 | 1135 | if ($globalDebug) echo 'Get Data...'."\n"; |
1136 | 1136 | $buffer = $Common->getData($value['host']); |
1137 | - $all_data = json_decode($buffer,true); |
|
1137 | + $all_data = json_decode($buffer, true); |
|
1138 | 1138 | if ($buffer != '') { |
1139 | 1139 | $Source->deleteLocationBySource('blitzortung'); |
1140 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1141 | - $buffer = explode('\n',$buffer); |
|
1140 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1141 | + $buffer = explode('\n', $buffer); |
|
1142 | 1142 | foreach ($buffer as $buffer_line) { |
1143 | - $line = json_decode($buffer_line,true); |
|
1143 | + $line = json_decode($buffer_line, true); |
|
1144 | 1144 | if (isset($line['time'])) { |
1145 | 1145 | $data = array(); |
1146 | 1146 | $data['altitude'] = $line['alt']; // altitude |
1147 | 1147 | $data['latitude'] = $line['lat']; // lat |
1148 | 1148 | $data['longitude'] = $line['lon']; // long |
1149 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1149 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1150 | 1150 | $data['id_source'] = $id_source; |
1151 | 1151 | $data['format_source'] = 'blitzortung'; |
1152 | 1152 | $SI->add($data); |
1153 | 1153 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1154 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1154 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1155 | 1155 | unset($data); |
1156 | 1156 | } |
1157 | 1157 | } |
@@ -1176,11 +1176,11 @@ discard block |
||
1176 | 1176 | //$value = $formats[$nb]; |
1177 | 1177 | $format = $globalSources[$nb]['format']; |
1178 | 1178 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1179 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1179 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1180 | 1180 | } elseif ($format == 'vrstcp') { |
1181 | 1181 | $buffer = @socket_read($r, 6000); |
1182 | 1182 | } else { |
1183 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1183 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1184 | 1184 | } |
1185 | 1185 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1186 | 1186 | //echo $buffer."\n"; |
@@ -1189,8 +1189,8 @@ discard block |
||
1189 | 1189 | $error = false; |
1190 | 1190 | //$SI::del(); |
1191 | 1191 | if ($format == 'vrstcp') { |
1192 | - $buffer = explode('},{',$buffer); |
|
1193 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1192 | + $buffer = explode('},{', $buffer); |
|
1193 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1194 | 1194 | // SBS format is CSV format |
1195 | 1195 | if ($buffer !== FALSE && $buffer != '') { |
1196 | 1196 | $tt[$format] = 0; |
@@ -1224,13 +1224,13 @@ discard block |
||
1224 | 1224 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1225 | 1225 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1226 | 1226 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1227 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1227 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1228 | 1228 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1229 | 1229 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1230 | 1230 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1231 | 1231 | |
1232 | 1232 | if (isset($ais_data['timestamp'])) { |
1233 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1233 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1234 | 1234 | } else { |
1235 | 1235 | $data['datetime'] = date('Y-m-d H:i:s'); |
1236 | 1236 | } |
@@ -1241,10 +1241,10 @@ discard block |
||
1241 | 1241 | } elseif ($format == 'flightgearsp') { |
1242 | 1242 | //echo $buffer."\n"; |
1243 | 1243 | if (strlen($buffer) > 5) { |
1244 | - $line = explode(',',$buffer); |
|
1244 | + $line = explode(',', $buffer); |
|
1245 | 1245 | $data = array(); |
1246 | 1246 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1247 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1247 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1248 | 1248 | $data['ident'] = $line[6]; |
1249 | 1249 | $data['aircraft_name'] = $line[7]; |
1250 | 1250 | $data['longitude'] = $line[1]; |
@@ -1261,16 +1261,16 @@ discard block |
||
1261 | 1261 | } elseif ($format == 'acars') { |
1262 | 1262 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1263 | 1263 | $ACARS->add(trim($buffer)); |
1264 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1264 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1265 | 1265 | $ACARS->deleteLiveAcarsData(); |
1266 | 1266 | } elseif ($format == 'flightgearmp') { |
1267 | - if (substr($buffer,0,1) != '#') { |
|
1267 | + if (substr($buffer, 0, 1) != '#') { |
|
1268 | 1268 | $data = array(); |
1269 | 1269 | //echo $buffer."\n"; |
1270 | - $line = explode(' ',$buffer); |
|
1270 | + $line = explode(' ', $buffer); |
|
1271 | 1271 | if (count($line) == 11) { |
1272 | - $userserver = explode('@',$line[0]); |
|
1273 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1272 | + $userserver = explode('@', $line[0]); |
|
1273 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1274 | 1274 | $data['ident'] = $userserver[0]; |
1275 | 1275 | $data['registration'] = $userserver[0]; |
1276 | 1276 | $data['latitude'] = $line[4]; |
@@ -1278,8 +1278,8 @@ discard block |
||
1278 | 1278 | $data['altitude'] = $line[6]; |
1279 | 1279 | $data['datetime'] = date('Y-m-d H:i:s'); |
1280 | 1280 | $aircraft_type = $line[10]; |
1281 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1282 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1281 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1282 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1283 | 1283 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1284 | 1284 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1285 | 1285 | } |
@@ -1288,8 +1288,8 @@ discard block |
||
1288 | 1288 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1289 | 1289 | die; |
1290 | 1290 | } elseif ($format == 'vrstcp') { |
1291 | - foreach($buffer as $all_data) { |
|
1292 | - $line = json_decode('{'.$all_data.'}',true); |
|
1291 | + foreach ($buffer as $all_data) { |
|
1292 | + $line = json_decode('{'.$all_data.'}', true); |
|
1293 | 1293 | $data = array(); |
1294 | 1294 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1295 | 1295 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1315,16 +1315,16 @@ discard block |
||
1315 | 1315 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1316 | 1316 | unset($data); |
1317 | 1317 | } |
1318 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1318 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1319 | 1319 | $line = explode("\t", $buffer); |
1320 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1320 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1321 | 1321 | $key = $line[$k]; |
1322 | - $lined[$key] = $line[$k+1]; |
|
1322 | + $lined[$key] = $line[$k + 1]; |
|
1323 | 1323 | } |
1324 | 1324 | if (count($lined) > 3) { |
1325 | 1325 | $data['hex'] = $lined['hexid']; |
1326 | 1326 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1327 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1327 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1328 | 1328 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1329 | 1329 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1330 | 1330 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1343,22 +1343,22 @@ discard block |
||
1343 | 1343 | } else $error = true; |
1344 | 1344 | } elseif ($format == 'aprs' && $use_aprs) { |
1345 | 1345 | if ($aprs_connect == 0) { |
1346 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1346 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1347 | 1347 | $aprs_connect = 1; |
1348 | 1348 | } |
1349 | 1349 | |
1350 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1350 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1351 | 1351 | $aprs_last_tx = time(); |
1352 | 1352 | $data_aprs = "# Keep alive"; |
1353 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1353 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1357 | 1357 | //echo 'APRS data : '.$buffer."\n"; |
1358 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1359 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1358 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1359 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1360 | 1360 | //echo $buffer."\n"; |
1361 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1361 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1362 | 1362 | $line = $APRS->parse($buffer); |
1363 | 1363 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1364 | 1364 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1373,7 +1373,7 @@ discard block |
||
1373 | 1373 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1374 | 1374 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1375 | 1375 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1376 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1376 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1377 | 1377 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1378 | 1378 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1379 | 1379 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1452,29 +1452,29 @@ discard block |
||
1452 | 1452 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1453 | 1453 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1454 | 1454 | $Source->deleteOldLocationByType('gs'); |
1455 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1456 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1455 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1456 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1457 | 1457 | } else { |
1458 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1458 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1459 | 1459 | } |
1460 | 1460 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1461 | 1461 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1462 | 1462 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1463 | 1463 | $Source->deleteOldLocationByType('wx'); |
1464 | 1464 | $weather_data = json_encode($line); |
1465 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1466 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1465 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1466 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1467 | 1467 | } else { |
1468 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1468 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1469 | 1469 | } |
1470 | 1470 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
1471 | 1471 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1472 | 1472 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1473 | 1473 | $Source->deleteOldLocationByType('lightning'); |
1474 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1475 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1474 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
1475 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1476 | 1476 | } else { |
1477 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1477 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1478 | 1478 | } |
1479 | 1479 | } elseif ($globalDebug) { |
1480 | 1480 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1483,7 +1483,7 @@ discard block |
||
1483 | 1483 | unset($data); |
1484 | 1484 | } |
1485 | 1485 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1486 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1486 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1487 | 1487 | } |
1488 | 1488 | /* |
1489 | 1489 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | */ |
1493 | 1493 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1494 | 1494 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1495 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1495 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1496 | 1496 | $Source->deleteOldLocationByType('lightning'); |
1497 | 1497 | $Source->deleteOldLocationByType('wx'); |
1498 | 1498 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -1577,7 +1577,7 @@ discard block |
||
1577 | 1577 | connect_all($sourceee); |
1578 | 1578 | $sourceee = array(); |
1579 | 1579 | //connect_all($globalSources); |
1580 | - $tt[$format]=0; |
|
1580 | + $tt[$format] = 0; |
|
1581 | 1581 | break; |
1582 | 1582 | } |
1583 | 1583 | } |
@@ -1586,14 +1586,14 @@ discard block |
||
1586 | 1586 | } else { |
1587 | 1587 | $error = socket_strerror(socket_last_error()); |
1588 | 1588 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1589 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1589 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1590 | 1590 | if (isset($globalDebug)) echo "Restarting...\n"; |
1591 | 1591 | // Restart the script if possible |
1592 | 1592 | if (is_array($sockets)) { |
1593 | 1593 | if ($globalDebug) echo "Shutdown all sockets..."; |
1594 | 1594 | |
1595 | 1595 | foreach ($sockets as $sock) { |
1596 | - @socket_shutdown($sock,2); |
|
1596 | + @socket_shutdown($sock, 2); |
|
1597 | 1597 | @socket_close($sock); |
1598 | 1598 | } |
1599 | 1599 |