@@ -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"; |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,42 +25,42 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->latest() === false) { |
28 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | - exit(); |
|
28 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if (PHP_SAPI != 'cli') { |
32 | - echo "This script MUST be called from console, not a web browser."; |
|
32 | + echo "This script MUST be called from console, not a web browser."; |
|
33 | 33 | // exit(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | // This is to be compatible with old version of settings.php |
37 | 37 | if (!isset($globalSources)) { |
38 | - if (isset($globalSBS1Hosts)) { |
|
39 | - //$hosts = $globalSBS1Hosts; |
|
40 | - foreach ($globalSBS1Hosts as $host) { |
|
41 | - $globalSources[] = array('host' => $host); |
|
42 | - } |
|
43 | - } else { |
|
44 | - if (!isset($globalSBS1Host)) { |
|
45 | - echo '$globalSources MUST be defined !'; |
|
46 | - die; |
|
38 | + if (isset($globalSBS1Hosts)) { |
|
39 | + //$hosts = $globalSBS1Hosts; |
|
40 | + foreach ($globalSBS1Hosts as $host) { |
|
41 | + $globalSources[] = array('host' => $host); |
|
42 | + } |
|
43 | + } else { |
|
44 | + if (!isset($globalSBS1Host)) { |
|
45 | + echo '$globalSources MUST be defined !'; |
|
46 | + die; |
|
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | 49 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
50 | - } |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 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 | - $globalSources = array(); |
|
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | - else $globalSources[] = array('host' => $options['s']); |
|
57 | + $globalSources = array(); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | + else $globalSources[] = array('host' => $options['s']); |
|
60 | 60 | } elseif (isset($options['source'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['source']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['source']); |
|
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
66 | 66 | $globalServerAPRS = TRUE; |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | - $SI=new SpotterServer(); |
|
78 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | + $SI=new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
@@ -85,8 +85,8 @@ discard block |
||
85 | 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 | - $AIS = new AIS(); |
|
89 | - $MI = new MarineImport($Connection->db); |
|
88 | + $AIS = new AIS(); |
|
89 | + $MI = new MarineImport($Connection->db); |
|
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | 92 | $SBS=new SBS(); |
@@ -97,12 +97,12 @@ discard block |
||
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() { |
|
101 | - global $sockets; |
|
102 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | - die("Bye!\n"); |
|
104 | - }); |
|
105 | - pcntl_signal_dispatch(); |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | + global $sockets; |
|
102 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | + die("Bye!\n"); |
|
104 | + }); |
|
105 | + pcntl_signal_dispatch(); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // let's try and connect |
@@ -112,36 +112,36 @@ discard block |
||
112 | 112 | $reset = 0; |
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
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; |
|
117 | - $reset++; |
|
118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
119 | - foreach ($hosts as $id => $value) { |
|
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; |
|
117 | + $reset++; |
|
118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
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 | 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 | - //$formats[$id] = 'deltadbtxt'; |
|
126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | - //$last_exec['deltadbtxt'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | - //$formats[$id] = 'vatsimtxt'; |
|
131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | - //$last_exec['vatsimtxt'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | - //$formats[$id] = 'aircraftlistjson'; |
|
136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | - //$last_exec['aircraftlistjson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
140 | - //$formats[$id] = 'aircraftlistjson'; |
|
141 | - $globalSources[$id]['format'] = 'opensky'; |
|
142 | - //$last_exec['aircraftlistjson'] = 0; |
|
143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | - /* |
|
124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
125 | + //$formats[$id] = 'deltadbtxt'; |
|
126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | + //$last_exec['deltadbtxt'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | + //$formats[$id] = 'vatsimtxt'; |
|
131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | + //$last_exec['vatsimtxt'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | + //$formats[$id] = 'aircraftlistjson'; |
|
136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | + //$last_exec['aircraftlistjson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | + } else if (preg_match('/opensky/i',$host)) { |
|
140 | + //$formats[$id] = 'aircraftlistjson'; |
|
141 | + $globalSources[$id]['format'] = 'opensky'; |
|
142 | + //$last_exec['aircraftlistjson'] = 0; |
|
143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | + /* |
|
145 | 145 | // Disabled for now, site change source format |
146 | 146 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
147 | 147 | //$formats[$id] = 'radarvirtueljson'; |
@@ -153,121 +153,121 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | - //$formats[$id] = 'planeupdatefaa'; |
|
158 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | - //$last_exec['planeupdatefaa'] = 0; |
|
160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | - exit(0); |
|
164 | - } |
|
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | - //$formats[$id] = 'phpvmacars'; |
|
167 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | - //$last_exec['phpvmacars'] = 0; |
|
169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | - //$formats[$id] = 'phpvmacars'; |
|
172 | - $globalSources[$id]['format'] = 'vam'; |
|
173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
175 | - //$formats[$id] = 'whazzup'; |
|
176 | - $globalSources[$id]['format'] = 'whazzup'; |
|
177 | - //$last_exec['whazzup'] = 0; |
|
178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
180 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
181 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
182 | - } else if (preg_match('/airwhere/i',$host)) { |
|
183 | - $globalSources[$id]['format'] = 'airwhere'; |
|
184 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
185 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
186 | - //$formats[$id] = 'pirepsjson'; |
|
187 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
188 | - //$last_exec['pirepsjson'] = 0; |
|
189 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
190 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
191 | - //$formats[$id] = 'fr24json'; |
|
192 | - $globalSources[$id]['format'] = 'fr24json'; |
|
193 | - //$last_exec['fr24json'] = 0; |
|
194 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
195 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
196 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
197 | - exit(0); |
|
198 | - } |
|
199 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
200 | - //$formats[$id] = 'fr24json'; |
|
201 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
202 | - //$last_exec['fr24json'] = 0; |
|
203 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
204 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
205 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
206 | - exit(0); |
|
207 | - } |
|
208 | - //} else if (preg_match('/10001/',$host)) { |
|
209 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
210 | - //$formats[$id] = 'tsv'; |
|
211 | - $globalSources[$id]['format'] = 'tsv'; |
|
212 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
213 | - } |
|
214 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
215 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
216 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
217 | - if ($idf !== false) { |
|
218 | - $httpfeeds[$id] = $idf; |
|
219 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | - } |
|
221 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
222 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
223 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
224 | - $hostport = explode(':',$host); |
|
225 | - if (isset($hostport[1])) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | + //$formats[$id] = 'planeupdatefaa'; |
|
158 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | + //$last_exec['planeupdatefaa'] = 0; |
|
160 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | + exit(0); |
|
164 | + } |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | + //$formats[$id] = 'phpvmacars'; |
|
167 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | + //$last_exec['phpvmacars'] = 0; |
|
169 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | + //$formats[$id] = 'phpvmacars'; |
|
172 | + $globalSources[$id]['format'] = 'vam'; |
|
173 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/whazzup/i',$host)) { |
|
175 | + //$formats[$id] = 'whazzup'; |
|
176 | + $globalSources[$id]['format'] = 'whazzup'; |
|
177 | + //$last_exec['whazzup'] = 0; |
|
178 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
180 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
181 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
182 | + } else if (preg_match('/airwhere/i',$host)) { |
|
183 | + $globalSources[$id]['format'] = 'airwhere'; |
|
184 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
185 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
186 | + //$formats[$id] = 'pirepsjson'; |
|
187 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
188 | + //$last_exec['pirepsjson'] = 0; |
|
189 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
190 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
191 | + //$formats[$id] = 'fr24json'; |
|
192 | + $globalSources[$id]['format'] = 'fr24json'; |
|
193 | + //$last_exec['fr24json'] = 0; |
|
194 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
195 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
196 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
197 | + exit(0); |
|
198 | + } |
|
199 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
200 | + //$formats[$id] = 'fr24json'; |
|
201 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
202 | + //$last_exec['fr24json'] = 0; |
|
203 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
204 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
205 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
206 | + exit(0); |
|
207 | + } |
|
208 | + //} else if (preg_match('/10001/',$host)) { |
|
209 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
210 | + //$formats[$id] = 'tsv'; |
|
211 | + $globalSources[$id]['format'] = 'tsv'; |
|
212 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
213 | + } |
|
214 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
215 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
216 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
217 | + if ($idf !== false) { |
|
218 | + $httpfeeds[$id] = $idf; |
|
219 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | + } |
|
221 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
222 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
223 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
224 | + $hostport = explode(':',$host); |
|
225 | + if (isset($hostport[1])) { |
|
226 | 226 | $port = $hostport[1]; |
227 | 227 | $hostn = $hostport[0]; |
228 | - } else { |
|
228 | + } else { |
|
229 | 229 | $port = $globalSources[$id]['port']; |
230 | 230 | $hostn = $globalSources[$id]['host']; |
231 | - } |
|
232 | - $Common = new Common(); |
|
233 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
234 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
235 | - } else { |
|
236 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
237 | - } |
|
238 | - if ($s) { |
|
239 | - $sockets[$id] = $s; |
|
240 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
241 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
231 | + } |
|
232 | + $Common = new Common(); |
|
233 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
234 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
235 | + } else { |
|
236 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
237 | + } |
|
238 | + if ($s) { |
|
239 | + $sockets[$id] = $s; |
|
240 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
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 | - } elseif ($port == '10001') { |
|
249 | - //$formats[$id] = 'tsv'; |
|
250 | - $globalSources[$id]['format'] = 'tsv'; |
|
251 | - } elseif ($port == '30002') { |
|
252 | - //$formats[$id] = 'raw'; |
|
253 | - $globalSources[$id]['format'] = 'raw'; |
|
254 | - } elseif ($port == '5001') { |
|
255 | - //$formats[$id] = 'raw'; |
|
256 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
257 | - } elseif ($port == '30005') { |
|
248 | + } elseif ($port == '10001') { |
|
249 | + //$formats[$id] = 'tsv'; |
|
250 | + $globalSources[$id]['format'] = 'tsv'; |
|
251 | + } elseif ($port == '30002') { |
|
252 | + //$formats[$id] = 'raw'; |
|
253 | + $globalSources[$id]['format'] = 'raw'; |
|
254 | + } elseif ($port == '5001') { |
|
255 | + //$formats[$id] = 'raw'; |
|
256 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
257 | + } elseif ($port == '30005') { |
|
258 | 258 | // Not yet supported |
259 | - //$formats[$id] = 'beast'; |
|
260 | - $globalSources[$id]['format'] = 'beast'; |
|
261 | - //} else $formats[$id] = 'sbs'; |
|
262 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
263 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
259 | + //$formats[$id] = 'beast'; |
|
260 | + $globalSources[$id]['format'] = 'beast'; |
|
261 | + //} else $formats[$id] = 'sbs'; |
|
262 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
263 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
264 | 264 | } |
265 | 265 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
266 | - } else { |
|
266 | + } else { |
|
267 | 267 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
268 | - } |
|
269 | - } |
|
270 | - } |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | 271 | } |
272 | 272 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
273 | 273 | |
@@ -290,9 +290,9 @@ 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 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
295 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | // APRS Configuration |
@@ -301,21 +301,21 @@ discard block |
||
301 | 301 | die; |
302 | 302 | } |
303 | 303 | foreach ($globalSources as $key => $source) { |
304 | - if (!isset($source['format'])) { |
|
305 | - $globalSources[$key]['format'] = 'auto'; |
|
306 | - } |
|
307 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
308 | - unset($globalSources[$key]); |
|
309 | - } |
|
304 | + if (!isset($source['format'])) { |
|
305 | + $globalSources[$key]['format'] = 'auto'; |
|
306 | + } |
|
307 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
308 | + unset($globalSources[$key]); |
|
309 | + } |
|
310 | 310 | } |
311 | 311 | connect_all($globalSources); |
312 | 312 | foreach ($globalSources as $key => $source) { |
313 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
313 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
314 | 314 | $aprs_connect = 0; |
315 | 315 | $use_aprs = true; |
316 | 316 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
317 | 317 | break; |
318 | - } |
|
318 | + } |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | if ($use_aprs) { |
@@ -356,115 +356,115 @@ 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(); |
|
360 | - // Delete old ATC |
|
361 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
359 | + if (!$globalDaemon) $i = $endtime-time(); |
|
360 | + // Delete old ATC |
|
361 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
362 | 362 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
363 | - $ATC->deleteOldATC(); |
|
364 | - } |
|
363 | + $ATC->deleteOldATC(); |
|
364 | + } |
|
365 | 365 | |
366 | - if (count($last_exec) == count($globalSources)) { |
|
366 | + if (count($last_exec) == count($globalSources)) { |
|
367 | 367 | $max = $globalMinFetch; |
368 | 368 | foreach ($last_exec as $last) { |
369 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
369 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
370 | 370 | } |
371 | 371 | if ($max != $globalMinFetch) { |
372 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
373 | - sleep($globalMinFetch-$max+2); |
|
372 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
373 | + sleep($globalMinFetch-$max+2); |
|
374 | + } |
|
374 | 375 | } |
375 | - } |
|
376 | 376 | |
377 | 377 | |
378 | - //foreach ($formats as $id => $value) { |
|
379 | - foreach ($globalSources as $id => $value) { |
|
378 | + //foreach ($formats as $id => $value) { |
|
379 | + foreach ($globalSources as $id => $value) { |
|
380 | 380 | date_default_timezone_set('UTC'); |
381 | 381 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
382 | 382 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
383 | - //$buffer = $Common->getData($hosts[$id]); |
|
384 | - $buffer = $Common->getData($value['host']); |
|
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); |
|
388 | - foreach ($buffer as $line) { |
|
389 | - if ($line != '' && count($line) > 7) { |
|
390 | - $line = explode(',', $line); |
|
391 | - $data = array(); |
|
392 | - $data['hex'] = $line[1]; // hex |
|
393 | - $data['ident'] = $line[2]; // ident |
|
394 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
395 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
396 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
397 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
398 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
399 | - $data['verticalrate'] = ''; // vertical rate |
|
400 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
401 | - $data['emergency'] = ''; // emergency |
|
402 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
403 | - $data['format_source'] = 'deltadbtxt'; |
|
404 | - $data['id_source'] = $id_source; |
|
405 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
406 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
407 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
408 | - $SI->add($data); |
|
409 | - unset($data); |
|
410 | - } |
|
411 | - } |
|
412 | - $last_exec[$id]['last'] = time(); |
|
383 | + //$buffer = $Common->getData($hosts[$id]); |
|
384 | + $buffer = $Common->getData($value['host']); |
|
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); |
|
388 | + foreach ($buffer as $line) { |
|
389 | + if ($line != '' && count($line) > 7) { |
|
390 | + $line = explode(',', $line); |
|
391 | + $data = array(); |
|
392 | + $data['hex'] = $line[1]; // hex |
|
393 | + $data['ident'] = $line[2]; // ident |
|
394 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
395 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
396 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
397 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
398 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
399 | + $data['verticalrate'] = ''; // vertical rate |
|
400 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
401 | + $data['emergency'] = ''; // emergency |
|
402 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
403 | + $data['format_source'] = 'deltadbtxt'; |
|
404 | + $data['id_source'] = $id_source; |
|
405 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
406 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
407 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
408 | + $SI->add($data); |
|
409 | + unset($data); |
|
410 | + } |
|
411 | + } |
|
412 | + $last_exec[$id]['last'] = time(); |
|
413 | 413 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
414 | - date_default_timezone_set('CET'); |
|
415 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
416 | - date_default_timezone_set('UTC'); |
|
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); |
|
420 | - foreach ($buffer as $line) { |
|
414 | + date_default_timezone_set('CET'); |
|
415 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
416 | + date_default_timezone_set('UTC'); |
|
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); |
|
420 | + foreach ($buffer as $line) { |
|
421 | 421 | if ($line != '') { |
422 | - //echo "'".$line."'\n"; |
|
423 | - $add = false; |
|
424 | - $ais_data = $AIS->parse_line(trim($line)); |
|
425 | - $data = array(); |
|
426 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
427 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
428 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
429 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
430 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
431 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
432 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
433 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
434 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
435 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
436 | - if (isset($ais_data['timestamp'])) { |
|
422 | + //echo "'".$line."'\n"; |
|
423 | + $add = false; |
|
424 | + $ais_data = $AIS->parse_line(trim($line)); |
|
425 | + $data = array(); |
|
426 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
427 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
428 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
429 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
430 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
431 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
432 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
433 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
434 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
435 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
436 | + if (isset($ais_data['timestamp'])) { |
|
437 | 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 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
440 | - $add = true; |
|
439 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
440 | + $add = true; |
|
441 | 441 | } |
442 | - } else { |
|
442 | + } else { |
|
443 | 443 | $data['datetime'] = date('Y-m-d H:i:s'); |
444 | 444 | $add = true; |
445 | - } |
|
446 | - $data['format_source'] = 'aisnmeatxt'; |
|
447 | - $data['id_source'] = $id_source; |
|
448 | - //print_r($data); |
|
449 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
450 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
451 | - unset($data); |
|
445 | + } |
|
446 | + $data['format_source'] = 'aisnmeatxt'; |
|
447 | + $data['id_source'] = $id_source; |
|
448 | + //print_r($data); |
|
449 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
450 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
451 | + unset($data); |
|
452 | 452 | } |
453 | - } |
|
454 | - $last_exec[$id]['last'] = time(); |
|
453 | + } |
|
454 | + $last_exec[$id]['last'] = time(); |
|
455 | 455 | } elseif ($value['format'] == 'aisnmeahttp') { |
456 | - $arr = $httpfeeds; |
|
457 | - $w = $e = null; |
|
456 | + $arr = $httpfeeds; |
|
457 | + $w = $e = null; |
|
458 | 458 | |
459 | - if (isset($arr[$id])) { |
|
459 | + if (isset($arr[$id])) { |
|
460 | 460 | $nn = stream_select($arr,$w,$e,$timeout); |
461 | 461 | if ($nn > 0) { |
462 | - foreach ($httpfeeds as $feed) { |
|
462 | + foreach ($httpfeeds as $feed) { |
|
463 | 463 | $buffer = stream_get_line($feed,2000,"\n"); |
464 | 464 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
465 | 465 | $buffer = explode('\n',$buffer); |
466 | 466 | foreach ($buffer as $line) { |
467 | - if ($line != '') { |
|
467 | + if ($line != '') { |
|
468 | 468 | $ais_data = $AIS->parse_line(trim($line)); |
469 | 469 | $data = array(); |
470 | 470 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -482,96 +482,96 @@ discard block |
||
482 | 482 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
483 | 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 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
487 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
488 | 488 | } |
489 | 489 | $data['format_source'] = 'aisnmeahttp'; |
490 | 490 | $data['id_source'] = $id_source; |
491 | 491 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
492 | 492 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
493 | 493 | unset($data); |
494 | - } |
|
494 | + } |
|
495 | + } |
|
495 | 496 | } |
496 | - } |
|
497 | 497 | } else { |
498 | - $format = $value['format']; |
|
499 | - if (isset($tt[$format])) $tt[$format]++; |
|
500 | - else $tt[$format] = 0; |
|
501 | - if ($tt[$format] > 30) { |
|
498 | + $format = $value['format']; |
|
499 | + if (isset($tt[$format])) $tt[$format]++; |
|
500 | + else $tt[$format] = 0; |
|
501 | + if ($tt[$format] > 30) { |
|
502 | 502 | if ($globalDebug) echo 'Reconnect...'."\n"; |
503 | 503 | sleep(2); |
504 | 504 | $sourceeen[] = $value; |
505 | 505 | connect_all($sourceeen); |
506 | 506 | $sourceeen = array(); |
507 | - } |
|
507 | + } |
|
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'); |
|
512 | - if ($buffer != '') { |
|
511 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
512 | + if ($buffer != '') { |
|
513 | 513 | //echo $buffer; |
514 | 514 | $all_data = json_decode($buffer,true); |
515 | 515 | //print_r($all_data); |
516 | 516 | if (isset($all_data[0]['DATA'])) { |
517 | - foreach ($all_data[0]['DATA'] as $line) { |
|
517 | + foreach ($all_data[0]['DATA'] as $line) { |
|
518 | 518 | if ($line != '') { |
519 | - $data = array(); |
|
520 | - $data['ident'] = $line['NAME']; |
|
521 | - $data['mmsi'] = $line['MMSI']; |
|
522 | - $data['speed'] = $line['SOG']; |
|
523 | - $data['heading'] = $line['COG']; |
|
524 | - $data['latitude'] = $line['LAT']; |
|
525 | - $data['longitude'] = $line['LNG']; |
|
526 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
527 | - $data['imo'] = $line['IMO']; |
|
528 | - //$data['arrival_code'] = $ais_data['destination']; |
|
529 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
530 | - $data['format_source'] = 'myshiptracking'; |
|
531 | - $data['id_source'] = $id_source; |
|
532 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
533 | - $MI->add($data); |
|
534 | - unset($data); |
|
519 | + $data = array(); |
|
520 | + $data['ident'] = $line['NAME']; |
|
521 | + $data['mmsi'] = $line['MMSI']; |
|
522 | + $data['speed'] = $line['SOG']; |
|
523 | + $data['heading'] = $line['COG']; |
|
524 | + $data['latitude'] = $line['LAT']; |
|
525 | + $data['longitude'] = $line['LNG']; |
|
526 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
527 | + $data['imo'] = $line['IMO']; |
|
528 | + //$data['arrival_code'] = $ais_data['destination']; |
|
529 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
530 | + $data['format_source'] = 'myshiptracking'; |
|
531 | + $data['id_source'] = $id_source; |
|
532 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
533 | + $MI->add($data); |
|
534 | + unset($data); |
|
535 | + } |
|
535 | 536 | } |
536 | - } |
|
537 | 537 | } |
538 | - } |
|
539 | - $last_exec[$id]['last'] = time(); |
|
538 | + } |
|
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'])); |
|
542 | - if ($buffer != '') { |
|
541 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
542 | + if ($buffer != '') { |
|
543 | 543 | $all_data = json_decode($buffer,true); |
544 | 544 | if (isset($all_data[0]['mmsi'])) { |
545 | - foreach ($all_data as $line) { |
|
545 | + foreach ($all_data as $line) { |
|
546 | 546 | if ($line != '') { |
547 | - $data = array(); |
|
548 | - $data['ident'] = $line['shipname']; |
|
549 | - $data['callsign'] = $line['callsign']; |
|
550 | - $data['mmsi'] = $line['mmsi']; |
|
551 | - $data['speed'] = $line['sog']; |
|
552 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
553 | - $data['latitude'] = $line['latitude']; |
|
554 | - $data['longitude'] = $line['longitude']; |
|
555 | - $data['type_id'] = $line['shiptype']; |
|
556 | - $data['arrival_code'] = $line['destination']; |
|
557 | - $data['datetime'] = $line['time']; |
|
558 | - $data['format_source'] = 'boatbeaconapp'; |
|
559 | - $data['id_source'] = $id_source; |
|
560 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
561 | - $MI->add($data); |
|
562 | - unset($data); |
|
547 | + $data = array(); |
|
548 | + $data['ident'] = $line['shipname']; |
|
549 | + $data['callsign'] = $line['callsign']; |
|
550 | + $data['mmsi'] = $line['mmsi']; |
|
551 | + $data['speed'] = $line['sog']; |
|
552 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
553 | + $data['latitude'] = $line['latitude']; |
|
554 | + $data['longitude'] = $line['longitude']; |
|
555 | + $data['type_id'] = $line['shiptype']; |
|
556 | + $data['arrival_code'] = $line['destination']; |
|
557 | + $data['datetime'] = $line['time']; |
|
558 | + $data['format_source'] = 'boatbeaconapp'; |
|
559 | + $data['id_source'] = $id_source; |
|
560 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
561 | + $MI->add($data); |
|
562 | + unset($data); |
|
563 | + } |
|
563 | 564 | } |
564 | - } |
|
565 | 565 | } |
566 | 566 | |
567 | - } |
|
568 | - $last_exec[$id]['last'] = time(); |
|
567 | + } |
|
568 | + $last_exec[$id]['last'] = time(); |
|
569 | 569 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
570 | - $buffer = $Common->getData($value['host']); |
|
571 | - if ($buffer != '') { |
|
570 | + $buffer = $Common->getData($value['host']); |
|
571 | + if ($buffer != '') { |
|
572 | 572 | $all_data = json_decode($buffer,true); |
573 | 573 | if (isset($all_data['features'][0]['id'])) { |
574 | - foreach ($all_data['features'] as $line) { |
|
574 | + foreach ($all_data['features'] as $line) { |
|
575 | 575 | $data = array(); |
576 | 576 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
577 | 577 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -590,59 +590,59 @@ discard block |
||
590 | 590 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
591 | 591 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
592 | 592 | unset($data); |
593 | - } |
|
593 | + } |
|
594 | 594 | } |
595 | 595 | |
596 | - } |
|
597 | - $last_exec[$id]['last'] = time(); |
|
596 | + } |
|
597 | + $last_exec[$id]['last'] = time(); |
|
598 | 598 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
599 | - echo 'download...'; |
|
600 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
601 | - echo 'done !'."\n"; |
|
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); |
|
605 | - foreach ($buffer as $line) { |
|
599 | + echo 'download...'; |
|
600 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
601 | + echo 'done !'."\n"; |
|
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); |
|
605 | + foreach ($buffer as $line) { |
|
606 | 606 | if ($line != '') { |
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)); |
|
610 | - //$data['status'] = substr($line,21,2); |
|
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)); |
|
615 | - //$data['course'] = substr($line,57,5); |
|
616 | - $data['heading'] = round(substr($line,63,3)); |
|
617 | - //$data['draft'] = substr($line,67,4); |
|
618 | - //$data['length'] = substr($line,72,3); |
|
619 | - //$data['beam'] = substr($line,76,2); |
|
620 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
621 | - //$data['callsign'] = trim(substr($line,100,7); |
|
622 | - //$data['dest'] = substr($line,108,20); |
|
623 | - //$data['etaDate'] = substr($line,129,5); |
|
624 | - //$data['etaTime'] = substr($line,135,5); |
|
625 | - $data['format_source'] = 'shipplotter'; |
|
626 | - $data['id_source'] = $id_source; |
|
627 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
628 | - //print_r($data); |
|
629 | - echo 'Add...'."\n"; |
|
630 | - $MI->add($data); |
|
631 | - unset($data); |
|
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)); |
|
610 | + //$data['status'] = substr($line,21,2); |
|
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)); |
|
615 | + //$data['course'] = substr($line,57,5); |
|
616 | + $data['heading'] = round(substr($line,63,3)); |
|
617 | + //$data['draft'] = substr($line,67,4); |
|
618 | + //$data['length'] = substr($line,72,3); |
|
619 | + //$data['beam'] = substr($line,76,2); |
|
620 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
621 | + //$data['callsign'] = trim(substr($line,100,7); |
|
622 | + //$data['dest'] = substr($line,108,20); |
|
623 | + //$data['etaDate'] = substr($line,129,5); |
|
624 | + //$data['etaTime'] = substr($line,135,5); |
|
625 | + $data['format_source'] = 'shipplotter'; |
|
626 | + $data['id_source'] = $id_source; |
|
627 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
628 | + //print_r($data); |
|
629 | + echo 'Add...'."\n"; |
|
630 | + $MI->add($data); |
|
631 | + unset($data); |
|
632 | 632 | } |
633 | - } |
|
634 | - $last_exec[$id]['last'] = time(); |
|
633 | + } |
|
634 | + $last_exec[$id]['last'] = time(); |
|
635 | 635 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
636 | 636 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
637 | - //$buffer = $Common->getData($hosts[$id]); |
|
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); |
|
641 | - $reset = 0; |
|
642 | - foreach ($buffer as $line) { |
|
643 | - if ($line != '') { |
|
644 | - $line = explode(':', $line); |
|
645 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
637 | + //$buffer = $Common->getData($hosts[$id]); |
|
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); |
|
641 | + $reset = 0; |
|
642 | + foreach ($buffer as $line) { |
|
643 | + if ($line != '') { |
|
644 | + $line = explode(':', $line); |
|
645 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
646 | 646 | $data = array(); |
647 | 647 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
648 | 648 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -655,37 +655,37 @@ discard block |
||
655 | 655 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
656 | 656 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
657 | 657 | $data['latitude'] = $line[5]; // lat |
658 | - $data['longitude'] = $line[6]; // long |
|
659 | - $data['verticalrate'] = ''; // vertical rate |
|
660 | - $data['squawk'] = ''; // squawk |
|
661 | - $data['emergency'] = ''; // emergency |
|
662 | - $data['waypoints'] = $line[30]; |
|
658 | + $data['longitude'] = $line[6]; // long |
|
659 | + $data['verticalrate'] = ''; // vertical rate |
|
660 | + $data['squawk'] = ''; // squawk |
|
661 | + $data['emergency'] = ''; // emergency |
|
662 | + $data['waypoints'] = $line[30]; |
|
663 | 663 | $data['datetime'] = date('Y-m-d H:i:s'); |
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 | - $data['departure_airport_icao'] = $line[11]; |
|
667 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
668 | - $data['arrival_airport_icao'] = $line[13]; |
|
666 | + $data['departure_airport_icao'] = $line[11]; |
|
667 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
668 | + $data['arrival_airport_icao'] = $line[13]; |
|
669 | 669 | $data['frequency'] = $line[4]; |
670 | 670 | $data['type'] = $line[18]; |
671 | 671 | $data['range'] = $line[19]; |
672 | 672 | if (isset($line[35])) $data['info'] = $line[35]; |
673 | - $data['id_source'] = $id_source; |
|
674 | - //$data['arrival_airport_time'] = ; |
|
675 | - if ($line[9] != '') { |
|
676 | - $aircraft_data = explode('/',$line[9]); |
|
677 | - if (isset($aircraft_data[1])) { |
|
678 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
679 | - } |
|
680 | - } |
|
681 | - /* |
|
673 | + $data['id_source'] = $id_source; |
|
674 | + //$data['arrival_airport_time'] = ; |
|
675 | + if ($line[9] != '') { |
|
676 | + $aircraft_data = explode('/',$line[9]); |
|
677 | + if (isset($aircraft_data[1])) { |
|
678 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
679 | + } |
|
680 | + } |
|
681 | + /* |
|
682 | 682 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
683 | 683 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
684 | 684 | */ |
685 | - $data['format_source'] = $value['format']; |
|
685 | + $data['format_source'] = $value['format']; |
|
686 | 686 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
687 | 687 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
688 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
688 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
689 | 689 | elseif ($line[3] == 'ATC') { |
690 | 690 | //print_r($data); |
691 | 691 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -706,16 +706,16 @@ discard block |
||
706 | 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 | - unset($data); |
|
710 | - } |
|
711 | - } |
|
712 | - } |
|
713 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
714 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
715 | - $last_exec[$id]['last'] = time(); |
|
716 | - } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
717 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
718 | - if ($buffer != '') { |
|
709 | + unset($data); |
|
710 | + } |
|
711 | + } |
|
712 | + } |
|
713 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
714 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
715 | + $last_exec[$id]['last'] = time(); |
|
716 | + } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
717 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
718 | + if ($buffer != '') { |
|
719 | 719 | $all_data = simplexml_load_string($buffer); |
720 | 720 | foreach($all_data->children() as $childdata) { |
721 | 721 | $data = array(); |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | $SI->add($data); |
738 | 738 | unset($data); |
739 | 739 | } |
740 | - } |
|
741 | - $Source->deleteOldLocationByType('gs'); |
|
742 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
743 | - if ($buffer != '') { |
|
740 | + } |
|
741 | + $Source->deleteOldLocationByType('gs'); |
|
742 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
743 | + if ($buffer != '') { |
|
744 | 744 | $all_data = simplexml_load_string($buffer); |
745 | 745 | foreach($all_data->children() as $childdata) { |
746 | 746 | $data = array(); |
@@ -758,249 +758,249 @@ discard block |
||
758 | 758 | } |
759 | 759 | unset($data); |
760 | 760 | } |
761 | - } |
|
762 | - $last_exec[$id]['last'] = time(); |
|
761 | + } |
|
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'); |
|
765 | - if ($buffer != '') { |
|
766 | - $all_data = json_decode($buffer,true); |
|
767 | - if (isset($all_data['acList'])) { |
|
764 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
765 | + if ($buffer != '') { |
|
766 | + $all_data = json_decode($buffer,true); |
|
767 | + if (isset($all_data['acList'])) { |
|
768 | 768 | $reset = 0; |
769 | 769 | foreach ($all_data['acList'] as $line) { |
770 | - $data = array(); |
|
771 | - $data['hex'] = $line['Icao']; // hex |
|
772 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
773 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
774 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
775 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
776 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
777 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
778 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
779 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
780 | - $data['emergency'] = ''; // emergency |
|
781 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
770 | + $data = array(); |
|
771 | + $data['hex'] = $line['Icao']; // hex |
|
772 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
773 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
774 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
775 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
776 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
777 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
778 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
779 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
780 | + $data['emergency'] = ''; // emergency |
|
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)); |
|
784 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
783 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
784 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
785 | 785 | |
786 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
787 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
788 | - $data['format_source'] = 'aircraftlistjson'; |
|
789 | - $data['id_source'] = $id_source; |
|
790 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
791 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
792 | - if (isset($data['latitude'])) $SI->add($data); |
|
793 | - unset($data); |
|
786 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
787 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
788 | + $data['format_source'] = 'aircraftlistjson'; |
|
789 | + $data['id_source'] = $id_source; |
|
790 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
791 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
792 | + if (isset($data['latitude'])) $SI->add($data); |
|
793 | + unset($data); |
|
794 | 794 | } |
795 | - } elseif (is_array($all_data)) { |
|
795 | + } elseif (is_array($all_data)) { |
|
796 | 796 | $reset = 0; |
797 | 797 | foreach ($all_data as $line) { |
798 | - $data = array(); |
|
799 | - $data['hex'] = $line['hex']; // hex |
|
800 | - $data['ident'] = $line['flight']; // ident |
|
801 | - $data['altitude'] = $line['altitude']; // altitude |
|
802 | - $data['speed'] = $line['speed']; // speed |
|
803 | - $data['heading'] = $line['track']; // heading |
|
804 | - $data['latitude'] = $line['lat']; // lat |
|
805 | - $data['longitude'] = $line['lon']; // long |
|
806 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
807 | - $data['squawk'] = $line['squawk']; // squawk |
|
808 | - $data['emergency'] = ''; // emergency |
|
809 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
810 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
811 | - $data['format_source'] = 'aircraftlistjson'; |
|
812 | - $data['id_source'] = $id_source; |
|
813 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
814 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
815 | - $SI->add($data); |
|
816 | - unset($data); |
|
798 | + $data = array(); |
|
799 | + $data['hex'] = $line['hex']; // hex |
|
800 | + $data['ident'] = $line['flight']; // ident |
|
801 | + $data['altitude'] = $line['altitude']; // altitude |
|
802 | + $data['speed'] = $line['speed']; // speed |
|
803 | + $data['heading'] = $line['track']; // heading |
|
804 | + $data['latitude'] = $line['lat']; // lat |
|
805 | + $data['longitude'] = $line['lon']; // long |
|
806 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
807 | + $data['squawk'] = $line['squawk']; // squawk |
|
808 | + $data['emergency'] = ''; // emergency |
|
809 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
810 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
811 | + $data['format_source'] = 'aircraftlistjson'; |
|
812 | + $data['id_source'] = $id_source; |
|
813 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
814 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
815 | + $SI->add($data); |
|
816 | + unset($data); |
|
817 | 817 | } |
818 | - } |
|
819 | - } |
|
820 | - //$last_exec['aircraftlistjson'] = time(); |
|
821 | - $last_exec[$id]['last'] = time(); |
|
822 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
823 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
824 | - $buffer = $Common->getData($value['host']); |
|
825 | - $all_data = json_decode($buffer,true); |
|
826 | - if (isset($all_data['planes'])) { |
|
818 | + } |
|
819 | + } |
|
820 | + //$last_exec['aircraftlistjson'] = time(); |
|
821 | + $last_exec[$id]['last'] = time(); |
|
822 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
823 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
824 | + $buffer = $Common->getData($value['host']); |
|
825 | + $all_data = json_decode($buffer,true); |
|
826 | + if (isset($all_data['planes'])) { |
|
827 | 827 | $reset = 0; |
828 | 828 | foreach ($all_data['planes'] as $key => $line) { |
829 | - $data = array(); |
|
830 | - $data['hex'] = $key; // hex |
|
831 | - $data['ident'] = $line[3]; // ident |
|
832 | - $data['altitude'] = $line[6]; // altitude |
|
833 | - $data['speed'] = $line[8]; // speed |
|
834 | - $data['heading'] = $line[7]; // heading |
|
835 | - $data['latitude'] = $line[4]; // lat |
|
836 | - $data['longitude'] = $line[5]; // long |
|
837 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
838 | - $data['squawk'] = $line[10]; // squawk |
|
839 | - $data['emergency'] = ''; // emergency |
|
840 | - $data['registration'] = $line[2]; |
|
841 | - $data['aircraft_icao'] = $line[0]; |
|
842 | - $deparr = explode('-',$line[1]); |
|
843 | - if (count($deparr) == 2) { |
|
829 | + $data = array(); |
|
830 | + $data['hex'] = $key; // hex |
|
831 | + $data['ident'] = $line[3]; // ident |
|
832 | + $data['altitude'] = $line[6]; // altitude |
|
833 | + $data['speed'] = $line[8]; // speed |
|
834 | + $data['heading'] = $line[7]; // heading |
|
835 | + $data['latitude'] = $line[4]; // lat |
|
836 | + $data['longitude'] = $line[5]; // long |
|
837 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
838 | + $data['squawk'] = $line[10]; // squawk |
|
839 | + $data['emergency'] = ''; // emergency |
|
840 | + $data['registration'] = $line[2]; |
|
841 | + $data['aircraft_icao'] = $line[0]; |
|
842 | + $deparr = explode('-',$line[1]); |
|
843 | + if (count($deparr) == 2) { |
|
844 | 844 | $data['departure_airport_icao'] = $deparr[0]; |
845 | 845 | $data['arrival_airport_icao'] = $deparr[1]; |
846 | - } |
|
847 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
848 | - $data['format_source'] = 'planeupdatefaa'; |
|
849 | - $data['id_source'] = $id_source; |
|
850 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
851 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
852 | - $SI->add($data); |
|
853 | - unset($data); |
|
846 | + } |
|
847 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
848 | + $data['format_source'] = 'planeupdatefaa'; |
|
849 | + $data['id_source'] = $id_source; |
|
850 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
851 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
852 | + $SI->add($data); |
|
853 | + unset($data); |
|
854 | + } |
|
854 | 855 | } |
855 | - } |
|
856 | - //$last_exec['planeupdatefaa'] = time(); |
|
857 | - $last_exec[$id]['last'] = time(); |
|
858 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
859 | - $buffer = $Common->getData($value['host']); |
|
860 | - $all_data = json_decode($buffer,true); |
|
861 | - if (isset($all_data['states'])) { |
|
856 | + //$last_exec['planeupdatefaa'] = time(); |
|
857 | + $last_exec[$id]['last'] = time(); |
|
858 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
859 | + $buffer = $Common->getData($value['host']); |
|
860 | + $all_data = json_decode($buffer,true); |
|
861 | + if (isset($all_data['states'])) { |
|
862 | 862 | $reset = 0; |
863 | 863 | foreach ($all_data['states'] as $key => $line) { |
864 | - $data = array(); |
|
865 | - $data['hex'] = $line[0]; // hex |
|
866 | - $data['ident'] = trim($line[1]); // ident |
|
867 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
868 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
869 | - $data['heading'] = round($line[10]); // heading |
|
870 | - $data['latitude'] = $line[6]; // lat |
|
871 | - $data['longitude'] = $line[5]; // long |
|
872 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
873 | - //$data['squawk'] = $line[10]; // squawk |
|
874 | - //$data['emergency'] = ''; // emergency |
|
875 | - //$data['registration'] = $line[2]; |
|
876 | - //$data['aircraft_icao'] = $line[0]; |
|
877 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
878 | - $data['format_source'] = 'opensky'; |
|
879 | - $data['id_source'] = $id_source; |
|
880 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
881 | - $SI->add($data); |
|
882 | - unset($data); |
|
864 | + $data = array(); |
|
865 | + $data['hex'] = $line[0]; // hex |
|
866 | + $data['ident'] = trim($line[1]); // ident |
|
867 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
868 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
869 | + $data['heading'] = round($line[10]); // heading |
|
870 | + $data['latitude'] = $line[6]; // lat |
|
871 | + $data['longitude'] = $line[5]; // long |
|
872 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
873 | + //$data['squawk'] = $line[10]; // squawk |
|
874 | + //$data['emergency'] = ''; // emergency |
|
875 | + //$data['registration'] = $line[2]; |
|
876 | + //$data['aircraft_icao'] = $line[0]; |
|
877 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
878 | + $data['format_source'] = 'opensky'; |
|
879 | + $data['id_source'] = $id_source; |
|
880 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
881 | + $SI->add($data); |
|
882 | + unset($data); |
|
883 | + } |
|
883 | 884 | } |
884 | - } |
|
885 | - //$last_exec['planeupdatefaa'] = time(); |
|
886 | - $last_exec[$id]['last'] = time(); |
|
887 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
888 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
889 | - //$buffer = $Common->getData($hosts[$id]); |
|
890 | - $buffer = $Common->getData($value['host']); |
|
891 | - $all_data = json_decode($buffer,true); |
|
892 | - if (!empty($all_data)) $reset = 0; |
|
893 | - foreach ($all_data as $key => $line) { |
|
885 | + //$last_exec['planeupdatefaa'] = time(); |
|
886 | + $last_exec[$id]['last'] = time(); |
|
887 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
888 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
889 | + //$buffer = $Common->getData($hosts[$id]); |
|
890 | + $buffer = $Common->getData($value['host']); |
|
891 | + $all_data = json_decode($buffer,true); |
|
892 | + if (!empty($all_data)) $reset = 0; |
|
893 | + foreach ($all_data as $key => $line) { |
|
894 | 894 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
895 | - $data = array(); |
|
896 | - $data['hex'] = $line[0]; |
|
897 | - $data['ident'] = $line[16]; //$line[13] |
|
898 | - $data['altitude'] = $line[4]; // altitude |
|
899 | - $data['speed'] = $line[5]; // speed |
|
900 | - $data['heading'] = $line[3]; // heading |
|
901 | - $data['latitude'] = $line[1]; // lat |
|
902 | - $data['longitude'] = $line[2]; // long |
|
903 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
904 | - $data['squawk'] = $line[6]; // squawk |
|
905 | - $data['aircraft_icao'] = $line[8]; |
|
906 | - $data['registration'] = $line[9]; |
|
907 | - $data['departure_airport_iata'] = $line[11]; |
|
908 | - $data['arrival_airport_iata'] = $line[12]; |
|
909 | - $data['emergency'] = ''; // emergency |
|
910 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
911 | - $data['format_source'] = 'fr24json'; |
|
912 | - $data['id_source'] = $id_source; |
|
913 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
914 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
915 | - $SI->add($data); |
|
916 | - unset($data); |
|
895 | + $data = array(); |
|
896 | + $data['hex'] = $line[0]; |
|
897 | + $data['ident'] = $line[16]; //$line[13] |
|
898 | + $data['altitude'] = $line[4]; // altitude |
|
899 | + $data['speed'] = $line[5]; // speed |
|
900 | + $data['heading'] = $line[3]; // heading |
|
901 | + $data['latitude'] = $line[1]; // lat |
|
902 | + $data['longitude'] = $line[2]; // long |
|
903 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
904 | + $data['squawk'] = $line[6]; // squawk |
|
905 | + $data['aircraft_icao'] = $line[8]; |
|
906 | + $data['registration'] = $line[9]; |
|
907 | + $data['departure_airport_iata'] = $line[11]; |
|
908 | + $data['arrival_airport_iata'] = $line[12]; |
|
909 | + $data['emergency'] = ''; // emergency |
|
910 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
911 | + $data['format_source'] = 'fr24json'; |
|
912 | + $data['id_source'] = $id_source; |
|
913 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
914 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
915 | + $SI->add($data); |
|
916 | + unset($data); |
|
917 | 917 | } |
918 | - } |
|
919 | - //$last_exec['fr24json'] = time(); |
|
920 | - $last_exec[$id]['last'] = time(); |
|
921 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
922 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
923 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
924 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
925 | - //echo $buffer; |
|
926 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
927 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
928 | - $all_data = json_decode($buffer,true); |
|
929 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
918 | + } |
|
919 | + //$last_exec['fr24json'] = time(); |
|
920 | + $last_exec[$id]['last'] = time(); |
|
921 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
922 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
923 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
924 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
925 | + //echo $buffer; |
|
926 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
927 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
928 | + $all_data = json_decode($buffer,true); |
|
929 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
930 | 930 | die(json_last_error_msg()); |
931 | - } |
|
932 | - if (isset($all_data['mrkrs'])) { |
|
931 | + } |
|
932 | + if (isset($all_data['mrkrs'])) { |
|
933 | 933 | $reset = 0; |
934 | 934 | foreach ($all_data['mrkrs'] as $key => $line) { |
935 | - if (isset($line['inf'])) { |
|
935 | + if (isset($line['inf'])) { |
|
936 | 936 | $data = array(); |
937 | 937 | $data['hex'] = $line['inf']['ia']; |
938 | 938 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
939 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
940 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
941 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
942 | - $data['latitude'] = $line['pt'][0]; // lat |
|
943 | - $data['longitude'] = $line['pt'][1]; // long |
|
944 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
945 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
946 | - //$data['aircraft_icao'] = $line[8]; |
|
947 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
939 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
940 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
941 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
942 | + $data['latitude'] = $line['pt'][0]; // lat |
|
943 | + $data['longitude'] = $line['pt'][1]; // long |
|
944 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
945 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
946 | + //$data['aircraft_icao'] = $line[8]; |
|
947 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
948 | 948 | //$data['departure_airport_iata'] = $line[11]; |
949 | 949 | //$data['arrival_airport_iata'] = $line[12]; |
950 | - //$data['emergency'] = ''; // emergency |
|
950 | + //$data['emergency'] = ''; // emergency |
|
951 | 951 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
952 | - $data['format_source'] = 'radarvirtueljson'; |
|
953 | - $data['id_source'] = $id_source; |
|
952 | + $data['format_source'] = 'radarvirtueljson'; |
|
953 | + $data['id_source'] = $id_source; |
|
954 | 954 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
955 | 955 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
956 | 956 | $SI->add($data); |
957 | 957 | unset($data); |
958 | - } |
|
958 | + } |
|
959 | + } |
|
959 | 960 | } |
960 | - } |
|
961 | - //$last_exec['radarvirtueljson'] = time(); |
|
962 | - $last_exec[$id]['last'] = time(); |
|
963 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
964 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
965 | - //$buffer = $Common->getData($hosts[$id]); |
|
966 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
967 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
961 | + //$last_exec['radarvirtueljson'] = time(); |
|
962 | + $last_exec[$id]['last'] = time(); |
|
963 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
964 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
965 | + //$buffer = $Common->getData($hosts[$id]); |
|
966 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
967 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
968 | 968 | |
969 | - if (isset($all_data['pireps'])) { |
|
969 | + if (isset($all_data['pireps'])) { |
|
970 | 970 | $reset = 0; |
971 | - foreach ($all_data['pireps'] as $line) { |
|
972 | - $data = array(); |
|
973 | - $data['id'] = $line['id']; |
|
974 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
975 | - $data['ident'] = $line['callsign']; // ident |
|
976 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
977 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
978 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
979 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
980 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
981 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
982 | - $data['latitude'] = $line['lat']; // lat |
|
983 | - $data['longitude'] = $line['lon']; // long |
|
984 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
985 | - //$data['squawk'] = $line['squawk']; // squawk |
|
986 | - //$data['emergency'] = ''; // emergency |
|
987 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
988 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
989 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
990 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
991 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
992 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
993 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
994 | - else $data['info'] = ''; |
|
995 | - $data['format_source'] = 'pireps'; |
|
996 | - $data['id_source'] = $id_source; |
|
997 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
998 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
999 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1000 | - if ($line['icon'] == 'plane') { |
|
971 | + foreach ($all_data['pireps'] as $line) { |
|
972 | + $data = array(); |
|
973 | + $data['id'] = $line['id']; |
|
974 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
975 | + $data['ident'] = $line['callsign']; // ident |
|
976 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
977 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
978 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
979 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
980 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
981 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
982 | + $data['latitude'] = $line['lat']; // lat |
|
983 | + $data['longitude'] = $line['lon']; // long |
|
984 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
985 | + //$data['squawk'] = $line['squawk']; // squawk |
|
986 | + //$data['emergency'] = ''; // emergency |
|
987 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
988 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
989 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
990 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
991 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
992 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
993 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
994 | + else $data['info'] = ''; |
|
995 | + $data['format_source'] = 'pireps'; |
|
996 | + $data['id_source'] = $id_source; |
|
997 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
998 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
999 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1000 | + if ($line['icon'] == 'plane') { |
|
1001 | 1001 | $SI->add($data); |
1002 | - // print_r($data); |
|
1003 | - } elseif ($line['icon'] == 'ct') { |
|
1002 | + // print_r($data); |
|
1003 | + } elseif ($line['icon'] == 'ct') { |
|
1004 | 1004 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1005 | 1005 | $data['info'] = str_replace('&sect;','',$data['info']); |
1006 | 1006 | $typec = substr($data['ident'],-3); |
@@ -1015,133 +1015,133 @@ discard block |
||
1015 | 1015 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1016 | 1016 | else $data['type'] = 'Observer'; |
1017 | 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 | - } |
|
1019 | - unset($data); |
|
1018 | + } |
|
1019 | + unset($data); |
|
1020 | + } |
|
1020 | 1021 | } |
1021 | - } |
|
1022 | - //$last_exec['pirepsjson'] = time(); |
|
1023 | - $last_exec[$id]['last'] = time(); |
|
1024 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1025 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1026 | - //$buffer = $Common->getData($hosts[$id]); |
|
1027 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1028 | - $buffer = $Common->getData($value['host']); |
|
1029 | - $all_data = json_decode($buffer,true); |
|
1030 | - if ($buffer != '' && is_array($all_data)) { |
|
1022 | + //$last_exec['pirepsjson'] = time(); |
|
1023 | + $last_exec[$id]['last'] = time(); |
|
1024 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1025 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1026 | + //$buffer = $Common->getData($hosts[$id]); |
|
1027 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1028 | + $buffer = $Common->getData($value['host']); |
|
1029 | + $all_data = json_decode($buffer,true); |
|
1030 | + if ($buffer != '' && is_array($all_data)) { |
|
1031 | 1031 | $reset = 0; |
1032 | 1032 | foreach ($all_data as $line) { |
1033 | - $data = array(); |
|
1034 | - //$data['id'] = $line['id']; // id not usable |
|
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 |
|
1037 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1038 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1039 | - $data['ident'] = $line['flightnum']; // ident |
|
1040 | - $data['altitude'] = $line['alt']; // altitude |
|
1041 | - $data['speed'] = $line['gs']; // speed |
|
1042 | - $data['heading'] = $line['heading']; // heading |
|
1043 | - $data['latitude'] = $line['lat']; // lat |
|
1044 | - $data['longitude'] = $line['lng']; // long |
|
1045 | - $data['verticalrate'] = ''; // verticale rate |
|
1046 | - $data['squawk'] = ''; // squawk |
|
1047 | - $data['emergency'] = ''; // emergency |
|
1048 | - //$data['datetime'] = $line['lastupdate']; |
|
1049 | - //$data['last_update'] = $line['lastupdate']; |
|
1050 | - if (isset($value['timezone'])) { |
|
1051 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1052 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1053 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1054 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1055 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1056 | - $data['departure_airport_time'] = $line['deptime']; |
|
1057 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1058 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1059 | - $data['registration'] = $line['aircraft']; |
|
1060 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1061 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1062 | - if (isset($line['aircraftname'])) { |
|
1033 | + $data = array(); |
|
1034 | + //$data['id'] = $line['id']; // id not usable |
|
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 |
|
1037 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1038 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1039 | + $data['ident'] = $line['flightnum']; // ident |
|
1040 | + $data['altitude'] = $line['alt']; // altitude |
|
1041 | + $data['speed'] = $line['gs']; // speed |
|
1042 | + $data['heading'] = $line['heading']; // heading |
|
1043 | + $data['latitude'] = $line['lat']; // lat |
|
1044 | + $data['longitude'] = $line['lng']; // long |
|
1045 | + $data['verticalrate'] = ''; // verticale rate |
|
1046 | + $data['squawk'] = ''; // squawk |
|
1047 | + $data['emergency'] = ''; // emergency |
|
1048 | + //$data['datetime'] = $line['lastupdate']; |
|
1049 | + //$data['last_update'] = $line['lastupdate']; |
|
1050 | + if (isset($value['timezone'])) { |
|
1051 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1052 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1053 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1054 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1055 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1056 | + $data['departure_airport_time'] = $line['deptime']; |
|
1057 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1058 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1059 | + $data['registration'] = $line['aircraft']; |
|
1060 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1061 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1062 | + if (isset($line['aircraftname'])) { |
|
1063 | 1063 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1064 | 1064 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1065 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1066 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1067 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
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']); |
|
1072 | - } |
|
1073 | - } |
|
1074 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1075 | - $data['id_source'] = $id_source; |
|
1076 | - $data['format_source'] = 'phpvmacars'; |
|
1077 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1078 | - $SI->add($data); |
|
1079 | - unset($data); |
|
1065 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1066 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1067 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
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']); |
|
1072 | + } |
|
1073 | + } |
|
1074 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1075 | + $data['id_source'] = $id_source; |
|
1076 | + $data['format_source'] = 'phpvmacars'; |
|
1077 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1078 | + $SI->add($data); |
|
1079 | + unset($data); |
|
1080 | 1080 | } |
1081 | 1081 | if ($globalDebug) echo 'No more data...'."\n"; |
1082 | 1082 | unset($buffer); |
1083 | 1083 | unset($all_data); |
1084 | - } |
|
1085 | - //$last_exec['phpvmacars'] = time(); |
|
1086 | - $last_exec[$id]['last'] = time(); |
|
1087 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1088 | - //$buffer = $Common->getData($hosts[$id]); |
|
1089 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1090 | - $buffer = $Common->getData($value['host']); |
|
1091 | - $all_data = json_decode($buffer,true); |
|
1092 | - if ($buffer != '' && is_array($all_data)) { |
|
1084 | + } |
|
1085 | + //$last_exec['phpvmacars'] = time(); |
|
1086 | + $last_exec[$id]['last'] = time(); |
|
1087 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1088 | + //$buffer = $Common->getData($hosts[$id]); |
|
1089 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1090 | + $buffer = $Common->getData($value['host']); |
|
1091 | + $all_data = json_decode($buffer,true); |
|
1092 | + if ($buffer != '' && is_array($all_data)) { |
|
1093 | 1093 | $reset = 0; |
1094 | 1094 | foreach ($all_data as $line) { |
1095 | - $data = array(); |
|
1096 | - //$data['id'] = $line['id']; // id not usable |
|
1097 | - $data['id'] = trim($line['flight_id']); |
|
1098 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1099 | - $data['pilot_name'] = $line['pilot_name']; |
|
1100 | - $data['pilot_id'] = $line['pilot_id']; |
|
1101 | - $data['ident'] = trim($line['callsign']); // ident |
|
1102 | - $data['altitude'] = $line['altitude']; // altitude |
|
1103 | - $data['speed'] = $line['gs']; // speed |
|
1104 | - $data['heading'] = $line['heading']; // heading |
|
1105 | - $data['latitude'] = $line['latitude']; // lat |
|
1106 | - $data['longitude'] = $line['longitude']; // long |
|
1107 | - $data['verticalrate'] = ''; // verticale rate |
|
1108 | - $data['squawk'] = ''; // squawk |
|
1109 | - $data['emergency'] = ''; // emergency |
|
1110 | - //$data['datetime'] = $line['lastupdate']; |
|
1111 | - $data['last_update'] = $line['last_update']; |
|
1112 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | - $data['departure_airport_icao'] = $line['departure']; |
|
1114 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1115 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1116 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1117 | - //$data['registration'] = $line['aircraft']; |
|
1118 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1119 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1120 | - $data['id_source'] = $id_source; |
|
1121 | - $data['format_source'] = 'vam'; |
|
1122 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1123 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1124 | - $SI->add($data); |
|
1125 | - unset($data); |
|
1095 | + $data = array(); |
|
1096 | + //$data['id'] = $line['id']; // id not usable |
|
1097 | + $data['id'] = trim($line['flight_id']); |
|
1098 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1099 | + $data['pilot_name'] = $line['pilot_name']; |
|
1100 | + $data['pilot_id'] = $line['pilot_id']; |
|
1101 | + $data['ident'] = trim($line['callsign']); // ident |
|
1102 | + $data['altitude'] = $line['altitude']; // altitude |
|
1103 | + $data['speed'] = $line['gs']; // speed |
|
1104 | + $data['heading'] = $line['heading']; // heading |
|
1105 | + $data['latitude'] = $line['latitude']; // lat |
|
1106 | + $data['longitude'] = $line['longitude']; // long |
|
1107 | + $data['verticalrate'] = ''; // verticale rate |
|
1108 | + $data['squawk'] = ''; // squawk |
|
1109 | + $data['emergency'] = ''; // emergency |
|
1110 | + //$data['datetime'] = $line['lastupdate']; |
|
1111 | + $data['last_update'] = $line['last_update']; |
|
1112 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | + $data['departure_airport_icao'] = $line['departure']; |
|
1114 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1115 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1116 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1117 | + //$data['registration'] = $line['aircraft']; |
|
1118 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1119 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1120 | + $data['id_source'] = $id_source; |
|
1121 | + $data['format_source'] = 'vam'; |
|
1122 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1123 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1124 | + $SI->add($data); |
|
1125 | + unset($data); |
|
1126 | 1126 | } |
1127 | 1127 | if ($globalDebug) echo 'No more data...'."\n"; |
1128 | 1128 | unset($buffer); |
1129 | 1129 | unset($all_data); |
1130 | - } |
|
1131 | - //$last_exec['phpvmacars'] = time(); |
|
1132 | - $last_exec[$id]['last'] = time(); |
|
1133 | - } elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1134 | - //$buffer = $Common->getData($hosts[$id]); |
|
1135 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1136 | - $buffer = $Common->getData($value['host']); |
|
1137 | - $all_data = json_decode($buffer,true); |
|
1138 | - if ($buffer != '') { |
|
1130 | + } |
|
1131 | + //$last_exec['phpvmacars'] = time(); |
|
1132 | + $last_exec[$id]['last'] = time(); |
|
1133 | + } elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1134 | + //$buffer = $Common->getData($hosts[$id]); |
|
1135 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1136 | + $buffer = $Common->getData($value['host']); |
|
1137 | + $all_data = json_decode($buffer,true); |
|
1138 | + if ($buffer != '') { |
|
1139 | 1139 | $Source->deleteLocationBySource('blitzortung'); |
1140 | 1140 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1141 | 1141 | $buffer = explode('\n',$buffer); |
1142 | 1142 | foreach ($buffer as $buffer_line) { |
1143 | - $line = json_decode($buffer_line,true); |
|
1144 | - if (isset($line['time'])) { |
|
1143 | + $line = json_decode($buffer_line,true); |
|
1144 | + if (isset($line['time'])) { |
|
1145 | 1145 | $data = array(); |
1146 | 1146 | $data['altitude'] = $line['alt']; // altitude |
1147 | 1147 | $data['latitude'] = $line['lat']; // lat |
@@ -1153,94 +1153,94 @@ discard block |
||
1153 | 1153 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1154 | 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 | } |
1158 | 1158 | if ($globalDebug) echo 'No more data...'."\n"; |
1159 | 1159 | unset($buffer); |
1160 | - } |
|
1161 | - $last_exec[$id]['last'] = time(); |
|
1160 | + } |
|
1161 | + $last_exec[$id]['last'] = time(); |
|
1162 | 1162 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1163 | 1163 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1164 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1165 | - //$last_exec[$id]['last'] = time(); |
|
1164 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1165 | + //$last_exec[$id]['last'] = time(); |
|
1166 | 1166 | |
1167 | - //$read = array( $sockets[$id] ); |
|
1168 | - $read = $sockets; |
|
1169 | - $write = NULL; |
|
1170 | - $e = NULL; |
|
1171 | - $n = socket_select($read, $write, $e, $timeout); |
|
1172 | - if ($e != NULL) var_dump($e); |
|
1173 | - if ($n > 0) { |
|
1167 | + //$read = array( $sockets[$id] ); |
|
1168 | + $read = $sockets; |
|
1169 | + $write = NULL; |
|
1170 | + $e = NULL; |
|
1171 | + $n = socket_select($read, $write, $e, $timeout); |
|
1172 | + if ($e != NULL) var_dump($e); |
|
1173 | + if ($n > 0) { |
|
1174 | 1174 | $reset = 0; |
1175 | 1175 | foreach ($read as $nb => $r) { |
1176 | - //$value = $formats[$nb]; |
|
1177 | - $format = $globalSources[$nb]['format']; |
|
1178 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1176 | + //$value = $formats[$nb]; |
|
1177 | + $format = $globalSources[$nb]['format']; |
|
1178 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1179 | 1179 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1180 | - } elseif ($format == 'vrstcp') { |
|
1180 | + } elseif ($format == 'vrstcp') { |
|
1181 | 1181 | $buffer = @socket_read($r, 6000); |
1182 | - } else { |
|
1182 | + } else { |
|
1183 | 1183 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1184 | - } |
|
1185 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1186 | - //echo $buffer."\n"; |
|
1187 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1188 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1189 | - $error = false; |
|
1190 | - //$SI::del(); |
|
1191 | - if ($format == 'vrstcp') { |
|
1184 | + } |
|
1185 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1186 | + //echo $buffer."\n"; |
|
1187 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1188 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1189 | + $error = false; |
|
1190 | + //$SI::del(); |
|
1191 | + if ($format == 'vrstcp') { |
|
1192 | 1192 | $buffer = explode('},{',$buffer); |
1193 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1194 | - // SBS format is CSV format |
|
1195 | - if ($buffer !== FALSE && $buffer != '') { |
|
1193 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1194 | + // SBS format is CSV format |
|
1195 | + if ($buffer !== FALSE && $buffer != '') { |
|
1196 | 1196 | $tt[$format] = 0; |
1197 | 1197 | if ($format == 'acarssbs3') { |
1198 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1199 | - $ACARS->add(trim($buffer)); |
|
1200 | - $ACARS->deleteLiveAcarsData(); |
|
1198 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1199 | + $ACARS->add(trim($buffer)); |
|
1200 | + $ACARS->deleteLiveAcarsData(); |
|
1201 | 1201 | } elseif ($format == 'raw') { |
1202 | - // AVR format |
|
1203 | - $data = $SBS->parse($buffer); |
|
1204 | - if (is_array($data)) { |
|
1202 | + // AVR format |
|
1203 | + $data = $SBS->parse($buffer); |
|
1204 | + if (is_array($data)) { |
|
1205 | 1205 | $data['datetime'] = date('Y-m-d H:i:s'); |
1206 | 1206 | $data['format_source'] = 'raw'; |
1207 | 1207 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1208 | 1208 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1209 | 1209 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1210 | 1210 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1211 | - } |
|
1211 | + } |
|
1212 | 1212 | } elseif ($format == 'ais') { |
1213 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1214 | - $data = array(); |
|
1215 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1216 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1217 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1218 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1219 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1220 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1221 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1222 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1223 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1224 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1225 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
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']); |
|
1228 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1229 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1230 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1213 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1214 | + $data = array(); |
|
1215 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1216 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1217 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1218 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1219 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1220 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1221 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1222 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1223 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1224 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1225 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
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']); |
|
1228 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1229 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1230 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1231 | 1231 | |
1232 | - if (isset($ais_data['timestamp'])) { |
|
1232 | + if (isset($ais_data['timestamp'])) { |
|
1233 | 1233 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1234 | - } else { |
|
1234 | + } else { |
|
1235 | 1235 | $data['datetime'] = date('Y-m-d H:i:s'); |
1236 | - } |
|
1237 | - $data['format_source'] = 'aisnmea'; |
|
1238 | - $data['id_source'] = $id_source; |
|
1239 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1240 | - unset($data); |
|
1241 | - } elseif ($format == 'flightgearsp') { |
|
1242 | - //echo $buffer."\n"; |
|
1243 | - if (strlen($buffer) > 5) { |
|
1236 | + } |
|
1237 | + $data['format_source'] = 'aisnmea'; |
|
1238 | + $data['id_source'] = $id_source; |
|
1239 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1240 | + unset($data); |
|
1241 | + } elseif ($format == 'flightgearsp') { |
|
1242 | + //echo $buffer."\n"; |
|
1243 | + if (strlen($buffer) > 5) { |
|
1244 | 1244 | $line = explode(',',$buffer); |
1245 | 1245 | $data = array(); |
1246 | 1246 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1257,38 +1257,38 @@ discard block |
||
1257 | 1257 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1258 | 1258 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1259 | 1259 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1260 | - } |
|
1261 | - } elseif ($format == 'acars') { |
|
1262 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1263 | - $ACARS->add(trim($buffer)); |
|
1264 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1265 | - $ACARS->deleteLiveAcarsData(); |
|
1260 | + } |
|
1261 | + } elseif ($format == 'acars') { |
|
1262 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1263 | + $ACARS->add(trim($buffer)); |
|
1264 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
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 | 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 |
|
1274 | - $data['ident'] = $userserver[0]; |
|
1275 | - $data['registration'] = $userserver[0]; |
|
1276 | - $data['latitude'] = $line[4]; |
|
1277 | - $data['longitude'] = $line[5]; |
|
1278 | - $data['altitude'] = $line[6]; |
|
1279 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1280 | - $aircraft_type = $line[10]; |
|
1281 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1282 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1283 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1284 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1272 | + $userserver = explode('@',$line[0]); |
|
1273 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1274 | + $data['ident'] = $userserver[0]; |
|
1275 | + $data['registration'] = $userserver[0]; |
|
1276 | + $data['latitude'] = $line[4]; |
|
1277 | + $data['longitude'] = $line[5]; |
|
1278 | + $data['altitude'] = $line[6]; |
|
1279 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1280 | + $aircraft_type = $line[10]; |
|
1281 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1282 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1283 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1284 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1285 | + } |
|
1285 | 1286 | } |
1286 | - } |
|
1287 | 1287 | } elseif ($format == 'beast') { |
1288 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1289 | - die; |
|
1288 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1289 | + die; |
|
1290 | 1290 | } elseif ($format == 'vrstcp') { |
1291 | - foreach($buffer as $all_data) { |
|
1291 | + foreach($buffer as $all_data) { |
|
1292 | 1292 | $line = json_decode('{'.$all_data.'}',true); |
1293 | 1293 | $data = array(); |
1294 | 1294 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1308,148 +1308,148 @@ discard block |
||
1308 | 1308 | */ |
1309 | 1309 | $data['datetime'] = date('Y-m-d H:i:s'); |
1310 | 1310 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1311 | - $data['format_source'] = 'vrstcp'; |
|
1311 | + $data['format_source'] = 'vrstcp'; |
|
1312 | 1312 | $data['id_source'] = $id_source; |
1313 | 1313 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1314 | 1314 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1315 | 1315 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1316 | 1316 | unset($data); |
1317 | - } |
|
1317 | + } |
|
1318 | 1318 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1319 | - $line = explode("\t", $buffer); |
|
1320 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1319 | + $line = explode("\t", $buffer); |
|
1320 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1321 | 1321 | $key = $line[$k]; |
1322 | - $lined[$key] = $line[$k+1]; |
|
1323 | - } |
|
1324 | - if (count($lined) > 3) { |
|
1325 | - $data['hex'] = $lined['hexid']; |
|
1326 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1327 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1328 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1329 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1330 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1331 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1332 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1333 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1334 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1335 | - $data['id_source'] = $id_source; |
|
1336 | - $data['format_source'] = 'tsv'; |
|
1337 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1338 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1322 | + $lined[$key] = $line[$k+1]; |
|
1323 | + } |
|
1324 | + if (count($lined) > 3) { |
|
1325 | + $data['hex'] = $lined['hexid']; |
|
1326 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1327 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1328 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1329 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1330 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1331 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1332 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1333 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1334 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1335 | + $data['id_source'] = $id_source; |
|
1336 | + $data['format_source'] = 'tsv'; |
|
1337 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1338 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1339 | 1339 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1340 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1341 | - unset($lined); |
|
1342 | - unset($data); |
|
1343 | - } else $error = true; |
|
1340 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1341 | + unset($lined); |
|
1342 | + unset($data); |
|
1343 | + } else $error = true; |
|
1344 | 1344 | } elseif ($format == 'aprs' && $use_aprs) { |
1345 | - if ($aprs_connect == 0) { |
|
1345 | + if ($aprs_connect == 0) { |
|
1346 | 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 | 1353 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1354 | - } |
|
1354 | + } |
|
1355 | 1355 | |
1356 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1357 | - //echo 'APRS data : '.$buffer."\n"; |
|
1358 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1359 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1360 | - //echo $buffer."\n"; |
|
1361 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1356 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1357 | + //echo 'APRS data : '.$buffer."\n"; |
|
1358 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1359 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1360 | + //echo $buffer."\n"; |
|
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']))) { |
1365 | - $aprs_last_tx = time(); |
|
1366 | - $data = array(); |
|
1367 | - //print_r($line); |
|
1368 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1369 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1370 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1371 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1372 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1373 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1374 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
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']); |
|
1377 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1378 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1379 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1380 | - $data['latitude'] = $line['latitude']; |
|
1381 | - $data['longitude'] = $line['longitude']; |
|
1382 | - //$data['verticalrate'] = $line[16]; |
|
1383 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1384 | - //else $data['speed'] = 0; |
|
1385 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1386 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1387 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1388 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1389 | - //else $data['heading'] = 0; |
|
1390 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1391 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1392 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1393 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1394 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1395 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1396 | - $data['id_source'] = $id_source; |
|
1397 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1398 | - else $data['format_source'] = 'aprs'; |
|
1399 | - $data['source_name'] = $line['source']; |
|
1400 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1401 | - else $data['source_type'] = 'flarm'; |
|
1402 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1403 | - $currentdate = date('Y-m-d H:i:s'); |
|
1404 | - $aprsdate = strtotime($data['datetime']); |
|
1405 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1406 | - // Accept data if time <= system time + 20s |
|
1407 | - //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1408 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1365 | + $aprs_last_tx = time(); |
|
1366 | + $data = array(); |
|
1367 | + //print_r($line); |
|
1368 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1369 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1370 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1371 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1372 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1373 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1374 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
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']); |
|
1377 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1378 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1379 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1380 | + $data['latitude'] = $line['latitude']; |
|
1381 | + $data['longitude'] = $line['longitude']; |
|
1382 | + //$data['verticalrate'] = $line[16]; |
|
1383 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1384 | + //else $data['speed'] = 0; |
|
1385 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1386 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1387 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1388 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1389 | + //else $data['heading'] = 0; |
|
1390 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1391 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1392 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1393 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1394 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1395 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1396 | + $data['id_source'] = $id_source; |
|
1397 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1398 | + else $data['format_source'] = 'aprs'; |
|
1399 | + $data['source_name'] = $line['source']; |
|
1400 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1401 | + else $data['source_type'] = 'flarm'; |
|
1402 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1403 | + $currentdate = date('Y-m-d H:i:s'); |
|
1404 | + $aprsdate = strtotime($data['datetime']); |
|
1405 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1406 | + // Accept data if time <= system time + 20s |
|
1407 | + //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1408 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1409 | 1409 | $send = $SI->add($data); |
1410 | - } elseif ($data['source_type'] == 'ais') { |
|
1410 | + } elseif ($data['source_type'] == 'ais') { |
|
1411 | 1411 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1412 | - } elseif (isset($line['stealth'])) { |
|
1412 | + } elseif (isset($line['stealth'])) { |
|
1413 | 1413 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1414 | 1414 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1415 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1416 | - //$line['symbol'] == 'Balloon' || |
|
1417 | - $line['symbol'] == 'Glider' || |
|
1418 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1419 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1420 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1421 | - $send = $SI->add($data); |
|
1422 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1423 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1424 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1425 | - $send = $MI->add($data); |
|
1426 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1427 | - $line['symbol'] == 'Car' || |
|
1428 | - $line['symbol'] == 'Ambulance' || |
|
1429 | - $line['symbol'] == 'Van' || |
|
1430 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1431 | - $line['symbol'] == 'Motorcycle' || |
|
1432 | - $line['symbol'] == 'Tractor' || |
|
1433 | - $line['symbol'] == 'Police' || |
|
1434 | - $line['symbol'] == 'Bike' || |
|
1435 | - $line['symbol'] == 'Jogger' || |
|
1436 | - $line['symbol'] == 'Horse' || |
|
1437 | - $line['symbol'] == 'Bus' || |
|
1438 | - $line['symbol'] == 'Jeep' || |
|
1439 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1440 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1441 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1442 | - $line['symbol'] == 'Firetruck' || |
|
1443 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1444 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1445 | - $line['symbol'] == 'SUV' || |
|
1446 | - $line['symbol'] == 'Snowmobile' || |
|
1447 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1448 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1415 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1416 | + //$line['symbol'] == 'Balloon' || |
|
1417 | + $line['symbol'] == 'Glider' || |
|
1418 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1419 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1420 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1421 | + $send = $SI->add($data); |
|
1422 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1423 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1424 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1425 | + $send = $MI->add($data); |
|
1426 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1427 | + $line['symbol'] == 'Car' || |
|
1428 | + $line['symbol'] == 'Ambulance' || |
|
1429 | + $line['symbol'] == 'Van' || |
|
1430 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1431 | + $line['symbol'] == 'Motorcycle' || |
|
1432 | + $line['symbol'] == 'Tractor' || |
|
1433 | + $line['symbol'] == 'Police' || |
|
1434 | + $line['symbol'] == 'Bike' || |
|
1435 | + $line['symbol'] == 'Jogger' || |
|
1436 | + $line['symbol'] == 'Horse' || |
|
1437 | + $line['symbol'] == 'Bus' || |
|
1438 | + $line['symbol'] == 'Jeep' || |
|
1439 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1440 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1441 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1442 | + $line['symbol'] == 'Firetruck' || |
|
1443 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1444 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1445 | + $line['symbol'] == 'SUV' || |
|
1446 | + $line['symbol'] == 'Snowmobile' || |
|
1447 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1448 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1449 | 1449 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1450 | 1450 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1451 | 1451 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1452 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
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 | 1455 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | } else { |
1458 | 1458 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1459 | 1459 | } |
1460 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
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'); |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | } else { |
1468 | 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 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
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'); |
@@ -1476,11 +1476,11 @@ discard block |
||
1476 | 1476 | } else { |
1477 | 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 | - } elseif ($globalDebug) { |
|
1480 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1481 | - print_r($line); |
|
1482 | - } |
|
1483 | - unset($data); |
|
1479 | + } elseif ($globalDebug) { |
|
1480 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1481 | + print_r($line); |
|
1482 | + } |
|
1483 | + unset($data); |
|
1484 | 1484 | } |
1485 | 1485 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1486 | 1486 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1499,12 +1499,12 @@ discard block |
||
1499 | 1499 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1500 | 1500 | $globalSources[$nb]['last_weather_clean'] = time(); |
1501 | 1501 | } |
1502 | - } |
|
1502 | + } |
|
1503 | 1503 | } else { |
1504 | - $line = explode(',', $buffer); |
|
1505 | - if (count($line) > 20) { |
|
1506 | - $data['hex'] = $line[4]; |
|
1507 | - /* |
|
1504 | + $line = explode(',', $buffer); |
|
1505 | + if (count($line) > 20) { |
|
1506 | + $data['hex'] = $line[4]; |
|
1507 | + /* |
|
1508 | 1508 | $data['datetime'] = $line[6].' '.$line[7]; |
1509 | 1509 | date_default_timezone_set($globalTimezone); |
1510 | 1510 | $datetime = new DateTime($data['datetime']); |
@@ -1512,30 +1512,30 @@ discard block |
||
1512 | 1512 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1513 | 1513 | date_default_timezone_set('UTC'); |
1514 | 1514 | */ |
1515 | - // Force datetime to current UTC datetime |
|
1516 | - date_default_timezone_set('UTC'); |
|
1517 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1518 | - $data['ident'] = trim($line[10]); |
|
1519 | - $data['latitude'] = $line[14]; |
|
1520 | - $data['longitude'] = $line[15]; |
|
1521 | - $data['verticalrate'] = $line[16]; |
|
1522 | - $data['emergency'] = $line[20]; |
|
1523 | - $data['speed'] = $line[12]; |
|
1524 | - $data['squawk'] = $line[17]; |
|
1525 | - $data['altitude'] = $line[11]; |
|
1526 | - $data['heading'] = $line[13]; |
|
1527 | - $data['ground'] = $line[21]; |
|
1528 | - $data['emergency'] = $line[19]; |
|
1529 | - $data['format_source'] = 'sbs'; |
|
1515 | + // Force datetime to current UTC datetime |
|
1516 | + date_default_timezone_set('UTC'); |
|
1517 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1518 | + $data['ident'] = trim($line[10]); |
|
1519 | + $data['latitude'] = $line[14]; |
|
1520 | + $data['longitude'] = $line[15]; |
|
1521 | + $data['verticalrate'] = $line[16]; |
|
1522 | + $data['emergency'] = $line[20]; |
|
1523 | + $data['speed'] = $line[12]; |
|
1524 | + $data['squawk'] = $line[17]; |
|
1525 | + $data['altitude'] = $line[11]; |
|
1526 | + $data['heading'] = $line[13]; |
|
1527 | + $data['ground'] = $line[21]; |
|
1528 | + $data['emergency'] = $line[19]; |
|
1529 | + $data['format_source'] = 'sbs'; |
|
1530 | 1530 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1531 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1531 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1532 | 1532 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1533 | - $data['id_source'] = $id_source; |
|
1534 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1535 | - else $error = true; |
|
1536 | - unset($data); |
|
1537 | - } else $error = true; |
|
1538 | - if ($error) { |
|
1533 | + $data['id_source'] = $id_source; |
|
1534 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1535 | + else $error = true; |
|
1536 | + unset($data); |
|
1537 | + } else $error = true; |
|
1538 | + if ($error) { |
|
1539 | 1539 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1540 | 1540 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1541 | 1541 | } else { |
@@ -1551,13 +1551,13 @@ discard block |
||
1551 | 1551 | connect_all($sourceer); |
1552 | 1552 | $sourceer = array(); |
1553 | 1553 | } |
1554 | - } |
|
1554 | + } |
|
1555 | 1555 | } |
1556 | 1556 | // Sleep for xxx microseconds |
1557 | 1557 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1558 | - } else { |
|
1558 | + } else { |
|
1559 | 1559 | if ($format == 'flightgearmp') { |
1560 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1560 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1561 | 1561 | //@socket_close($r); |
1562 | 1562 | sleep($globalMinFetch); |
1563 | 1563 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1566,9 +1566,9 @@ discard block |
||
1566 | 1566 | break; |
1567 | 1567 | |
1568 | 1568 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1569 | - if (isset($tt[$format])) $tt[$format]++; |
|
1570 | - else $tt[$format] = 0; |
|
1571 | - if ($tt[$format] > 30) { |
|
1569 | + if (isset($tt[$format])) $tt[$format]++; |
|
1570 | + else $tt[$format] = 0; |
|
1571 | + if ($tt[$format] > 30) { |
|
1572 | 1572 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1573 | 1573 | //@socket_close($r); |
1574 | 1574 | sleep(2); |
@@ -1579,23 +1579,23 @@ discard block |
||
1579 | 1579 | //connect_all($globalSources); |
1580 | 1580 | $tt[$format]=0; |
1581 | 1581 | break; |
1582 | - } |
|
1582 | + } |
|
1583 | + } |
|
1583 | 1584 | } |
1584 | - } |
|
1585 | 1585 | } |
1586 | - } else { |
|
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 | 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 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1593 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1594 | 1594 | |
1595 | - foreach ($sockets as $sock) { |
|
1595 | + foreach ($sockets as $sock) { |
|
1596 | 1596 | @socket_shutdown($sock,2); |
1597 | 1597 | @socket_close($sock); |
1598 | - } |
|
1598 | + } |
|
1599 | 1599 | |
1600 | 1600 | } |
1601 | 1601 | if ($globalDebug) echo "Waiting..."; |
@@ -1610,15 +1610,15 @@ discard block |
||
1610 | 1610 | if ($globalDebug) echo "Restart all connections..."; |
1611 | 1611 | connect_all($globalSources); |
1612 | 1612 | } |
1613 | - } |
|
1613 | + } |
|
1614 | 1614 | } |
1615 | 1615 | if ($globalDaemon === false) { |
1616 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1617 | - if (isset($SI)) $SI->checkAll(); |
|
1618 | - if (isset($TI)) $TI->checkAll(); |
|
1619 | - if (isset($MI)) $MI->checkAll(); |
|
1616 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1617 | + if (isset($SI)) $SI->checkAll(); |
|
1618 | + if (isset($TI)) $TI->checkAll(); |
|
1619 | + if (isset($MI)) $MI->checkAll(); |
|
1620 | + } |
|
1620 | 1621 | } |
1621 | - } |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | ?> |
@@ -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 |
@@ -14,13 +14,17 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
17 | +if (isset($globalTracker) && $globalTracker) { |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | +} |
|
18 | 20 | if (isset($globalMarine) && $globalMarine) { |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
21 | 23 | } |
22 | 24 | |
23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
24 | 28 | |
25 | 29 | // Check if schema is at latest version |
26 | 30 | $Connection = new Connection(); |
@@ -55,35 +59,62 @@ discard block |
||
55 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 60 | if (isset($options['s'])) { |
57 | 61 | $globalSources = array(); |
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | - else $globalSources[] = array('host' => $options['s']); |
|
60 | -} elseif (isset($options['source'])) { |
|
62 | + if (isset($options['format'])) { |
|
63 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
64 | + } else { |
|
65 | + $globalSources[] = array('host' => $options['s']); |
|
66 | + } |
|
67 | + } elseif (isset($options['source'])) { |
|
61 | 68 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['source']); |
|
64 | -} |
|
69 | + if (isset($options['format'])) { |
|
70 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
71 | + } else { |
|
72 | + $globalSources[] = array('host' => $options['source']); |
|
73 | + } |
|
74 | + } |
|
65 | 75 | if (isset($options['aprsserverhost'])) { |
66 | 76 | $globalServerAPRS = TRUE; |
67 | 77 | $globalServerAPRShost = $options['aprsserverhost']; |
68 | 78 | } |
69 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
70 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
71 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
72 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
73 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
74 | -if (isset($options['server'])) $globalServer = TRUE; |
|
75 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
76 | -else $id_source = 1; |
|
79 | +if (isset($options['aprsserverport'])) { |
|
80 | + $globalServerAPRSport = $options['aprsserverport']; |
|
81 | +} |
|
82 | +if (isset($options['aprsserverssid'])) { |
|
83 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
84 | +} |
|
85 | +if (isset($options['aprsserverpass'])) { |
|
86 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
87 | +} |
|
88 | +if (isset($options['noaprsserver'])) { |
|
89 | + $globalServerAPRS = FALSE; |
|
90 | +} |
|
91 | +if (isset($options['nodaemon'])) { |
|
92 | + $globalDaemon = FALSE; |
|
93 | +} |
|
94 | +if (isset($options['server'])) { |
|
95 | + $globalServer = TRUE; |
|
96 | +} |
|
97 | +if (isset($options['idsource'])) { |
|
98 | + $id_source = $options['idsource']; |
|
99 | +} else { |
|
100 | + $id_source = 1; |
|
101 | +} |
|
77 | 102 | if (isset($globalServer) && $globalServer) { |
78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
103 | + if ($globalDebug) { |
|
104 | + echo "Using Server Mode\n"; |
|
105 | + } |
|
79 | 106 | $SI=new SpotterServer(); |
80 | 107 | /* |
81 | 108 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 109 | $SI = new adsb2aprs(); |
83 | 110 | $SI->connect(); |
84 | 111 | */ |
85 | -} else $SI=new SpotterImport($Connection->db); |
|
86 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
112 | +} else { |
|
113 | + $SI=new SpotterImport($Connection->db); |
|
114 | +} |
|
115 | +if (isset($globalTracker) && $globalTracker) { |
|
116 | + $TI = new TrackerImport($Connection->db); |
|
117 | +} |
|
87 | 118 | if (isset($globalMarine) && $globalMarine) { |
88 | 119 | $AIS = new AIS(); |
89 | 120 | $MI = new MarineImport($Connection->db); |
@@ -106,7 +137,9 @@ discard block |
||
106 | 137 | } |
107 | 138 | |
108 | 139 | // let's try and connect |
109 | -if ($globalDebug) echo "Connecting...\n"; |
|
140 | +if ($globalDebug) { |
|
141 | + echo "Connecting...\n"; |
|
142 | +} |
|
110 | 143 | $use_aprs = false; |
111 | 144 | $aprs_full = false; |
112 | 145 | $reset = 0; |
@@ -115,7 +148,9 @@ discard block |
||
115 | 148 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
116 | 149 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
117 | 150 | $reset++; |
118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
151 | + if ($globalDebug) { |
|
152 | + echo 'Connect to all...'."\n"; |
|
153 | + } |
|
119 | 154 | foreach ($hosts as $id => $value) { |
120 | 155 | $host = $value['host']; |
121 | 156 | $globalSources[$id]['last_exec'] = 0; |
@@ -125,22 +160,30 @@ discard block |
||
125 | 160 | //$formats[$id] = 'deltadbtxt'; |
126 | 161 | $globalSources[$id]['format'] = 'deltadbtxt'; |
127 | 162 | //$last_exec['deltadbtxt'] = 0; |
128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
163 | + if ($globalDebug) { |
|
164 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
165 | + } |
|
129 | 166 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
130 | 167 | //$formats[$id] = 'vatsimtxt'; |
131 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; |
132 | 169 | //$last_exec['vatsimtxt'] = 0; |
133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
170 | + if ($globalDebug) { |
|
171 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
172 | + } |
|
134 | 173 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
135 | 174 | //$formats[$id] = 'aircraftlistjson'; |
136 | 175 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
137 | 176 | //$last_exec['aircraftlistjson'] = 0; |
138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
177 | + if ($globalDebug) { |
|
178 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
179 | + } |
|
139 | 180 | } else if (preg_match('/opensky/i',$host)) { |
140 | 181 | //$formats[$id] = 'aircraftlistjson'; |
141 | 182 | $globalSources[$id]['format'] = 'opensky'; |
142 | 183 | //$last_exec['aircraftlistjson'] = 0; |
143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
184 | + if ($globalDebug) { |
|
185 | + echo "Connect to opensky source (".$host.")...\n"; |
|
186 | + } |
|
144 | 187 | /* |
145 | 188 | // Disabled for now, site change source format |
146 | 189 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -157,7 +200,9 @@ discard block |
||
157 | 200 | //$formats[$id] = 'planeupdatefaa'; |
158 | 201 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
159 | 202 | //$last_exec['planeupdatefaa'] = 0; |
160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
203 | + if ($globalDebug) { |
|
204 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
205 | + } |
|
161 | 206 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
162 | 207 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
163 | 208 | exit(0); |
@@ -166,32 +211,46 @@ discard block |
||
166 | 211 | //$formats[$id] = 'phpvmacars'; |
167 | 212 | $globalSources[$id]['format'] = 'phpvmacars'; |
168 | 213 | //$last_exec['phpvmacars'] = 0; |
169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
216 | + } |
|
170 | 217 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
171 | 218 | //$formats[$id] = 'phpvmacars'; |
172 | 219 | $globalSources[$id]['format'] = 'vam'; |
173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
220 | + if ($globalDebug) { |
|
221 | + echo "Connect to Vam source (".$host.")...\n"; |
|
222 | + } |
|
174 | 223 | } else if (preg_match('/whazzup/i',$host)) { |
175 | 224 | //$formats[$id] = 'whazzup'; |
176 | 225 | $globalSources[$id]['format'] = 'whazzup'; |
177 | 226 | //$last_exec['whazzup'] = 0; |
178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
227 | + if ($globalDebug) { |
|
228 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
229 | + } |
|
179 | 230 | } else if (preg_match('/blitzortung/i',$host)) { |
180 | 231 | $globalSources[$id]['format'] = 'blitzortung'; |
181 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
232 | + if ($globalDebug) { |
|
233 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
234 | + } |
|
182 | 235 | } else if (preg_match('/airwhere/i',$host)) { |
183 | 236 | $globalSources[$id]['format'] = 'airwhere'; |
184 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
237 | + if ($globalDebug) { |
|
238 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
239 | + } |
|
185 | 240 | } else if (preg_match('/recentpireps/i',$host)) { |
186 | 241 | //$formats[$id] = 'pirepsjson'; |
187 | 242 | $globalSources[$id]['format'] = 'pirepsjson'; |
188 | 243 | //$last_exec['pirepsjson'] = 0; |
189 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
244 | + if ($globalDebug) { |
|
245 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
246 | + } |
|
190 | 247 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
191 | 248 | //$formats[$id] = 'fr24json'; |
192 | 249 | $globalSources[$id]['format'] = 'fr24json'; |
193 | 250 | //$last_exec['fr24json'] = 0; |
194 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
251 | + if ($globalDebug) { |
|
252 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
253 | + } |
|
195 | 254 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
196 | 255 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
197 | 256 | exit(0); |
@@ -200,7 +259,9 @@ discard block |
||
200 | 259 | //$formats[$id] = 'fr24json'; |
201 | 260 | $globalSources[$id]['format'] = 'myshiptracking'; |
202 | 261 | //$last_exec['fr24json'] = 0; |
203 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
262 | + if ($globalDebug) { |
|
263 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
264 | + } |
|
204 | 265 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
205 | 266 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
206 | 267 | exit(0); |
@@ -209,17 +270,24 @@ discard block |
||
209 | 270 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
210 | 271 | //$formats[$id] = 'tsv'; |
211 | 272 | $globalSources[$id]['format'] = 'tsv'; |
212 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
273 | + if ($globalDebug) { |
|
274 | + echo "Connect to tsv source (".$host.")...\n"; |
|
275 | + } |
|
213 | 276 | } |
214 | 277 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
215 | 278 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
216 | 279 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
217 | 280 | if ($idf !== false) { |
218 | 281 | $httpfeeds[$id] = $idf; |
219 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
282 | + if ($globalDebug) { |
|
283 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
284 | + } |
|
285 | + } elseif ($globalDebug) { |
|
286 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
220 | 287 | } |
221 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
222 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
288 | + } elseif ($globalDebug) { |
|
289 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
290 | + } |
|
223 | 291 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
224 | 292 | $hostport = explode(':',$host); |
225 | 293 | if (isset($hostport[1])) { |
@@ -259,17 +327,25 @@ discard block |
||
259 | 327 | //$formats[$id] = 'beast'; |
260 | 328 | $globalSources[$id]['format'] = 'beast'; |
261 | 329 | //} else $formats[$id] = 'sbs'; |
262 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
330 | + } else { |
|
331 | + $globalSources[$id]['format'] = 'sbs'; |
|
332 | + } |
|
263 | 333 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
264 | 334 | } |
265 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
335 | + if ($globalDebug) { |
|
336 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
337 | + } |
|
266 | 338 | } else { |
267 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
339 | + if ($globalDebug) { |
|
340 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
341 | + } |
|
268 | 342 | } |
269 | 343 | } |
270 | 344 | } |
271 | 345 | } |
272 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
346 | +if (!isset($globalMinFetch)) { |
|
347 | + $globalMinFetch = 15; |
|
348 | +} |
|
273 | 349 | |
274 | 350 | // Initialize all |
275 | 351 | $status = array(); |
@@ -278,13 +354,19 @@ discard block |
||
278 | 354 | $formats = array(); |
279 | 355 | $last_exec = array(); |
280 | 356 | $time = time(); |
281 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
282 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
283 | -else $timeout = 20; |
|
357 | +if (isset($globalSourcesTimeout)) { |
|
358 | + $timeout = $globalSourcesTimeOut; |
|
359 | +} else if (isset($globalSBS1TimeOut)) { |
|
360 | + $timeout = $globalSBS1TimeOut; |
|
361 | +} else { |
|
362 | + $timeout = 20; |
|
363 | +} |
|
284 | 364 | $errno = ''; |
285 | 365 | $errstr=''; |
286 | 366 | |
287 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
367 | +if (!isset($globalDaemon)) { |
|
368 | + $globalDaemon = TRUE; |
|
369 | +} |
|
288 | 370 | /* Initiate connections to all the hosts simultaneously */ |
289 | 371 | //connect_all($hosts); |
290 | 372 | //connect_all($globalSources); |
@@ -313,7 +395,9 @@ discard block |
||
313 | 395 | if (isset($source['format']) && $source['format'] == 'aprs') { |
314 | 396 | $aprs_connect = 0; |
315 | 397 | $use_aprs = true; |
316 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
398 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
399 | + $aprs_full = true; |
|
400 | + } |
|
317 | 401 | break; |
318 | 402 | } |
319 | 403 | } |
@@ -324,25 +408,48 @@ discard block |
||
324 | 408 | $aprs_connect = 0; |
325 | 409 | $aprs_keep = 120; |
326 | 410 | $aprs_last_tx = time(); |
327 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
328 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
329 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
330 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
331 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
332 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
333 | - if ($aprs_full) $aprs_filter = ''; |
|
334 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
335 | - else $aprs_pass = '-1'; |
|
411 | + if (isset($globalAPRSversion)) { |
|
412 | + $aprs_version = $globalAPRSversion; |
|
413 | + } else { |
|
414 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
415 | + } |
|
416 | + if (isset($globalAPRSssid)) { |
|
417 | + $aprs_ssid = $globalAPRSssid; |
|
418 | + } else { |
|
419 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
420 | + } |
|
421 | + if (isset($globalAPRSfilter)) { |
|
422 | + $aprs_filter = $globalAPRSfilter; |
|
423 | + } else { |
|
424 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
425 | + } |
|
426 | + if ($aprs_full) { |
|
427 | + $aprs_filter = ''; |
|
428 | + } |
|
429 | + if (isset($globalAPRSpass)) { |
|
430 | + $aprs_pass = $globalAPRSpass; |
|
431 | + } else { |
|
432 | + $aprs_pass = '-1'; |
|
433 | + } |
|
336 | 434 | |
337 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
338 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
339 | -} |
|
435 | + if ($aprs_filter != '') { |
|
436 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
437 | + } else { |
|
438 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
439 | + } |
|
440 | + } |
|
340 | 441 | |
341 | 442 | // connected - lets do some work |
342 | -if ($globalDebug) echo "Connected!\n"; |
|
443 | +if ($globalDebug) { |
|
444 | + echo "Connected!\n"; |
|
445 | +} |
|
343 | 446 | sleep(1); |
344 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
345 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
447 | +if ($globalDebug) { |
|
448 | + echo "SCAN MODE \n\n"; |
|
449 | +} |
|
450 | +if (!isset($globalCronEnd)) { |
|
451 | + $globalCronEnd = 60; |
|
452 | +} |
|
346 | 453 | $endtime = time()+$globalCronEnd; |
347 | 454 | $i = 1; |
348 | 455 | $tt = array(); |
@@ -356,20 +463,28 @@ discard block |
||
356 | 463 | |
357 | 464 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
358 | 465 | while ($i > 0) { |
359 | - if (!$globalDaemon) $i = $endtime-time(); |
|
466 | + if (!$globalDaemon) { |
|
467 | + $i = $endtime-time(); |
|
468 | + } |
|
360 | 469 | // Delete old ATC |
361 | 470 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
362 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
471 | + if ($globalDebug) { |
|
472 | + echo 'Delete old ATC...'."\n"; |
|
473 | + } |
|
363 | 474 | $ATC->deleteOldATC(); |
364 | 475 | } |
365 | 476 | |
366 | 477 | if (count($last_exec) == count($globalSources)) { |
367 | 478 | $max = $globalMinFetch; |
368 | 479 | foreach ($last_exec as $last) { |
369 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
480 | + if ((time() - $last['last']) < $max) { |
|
481 | + $max = time() - $last['last']; |
|
482 | + } |
|
370 | 483 | } |
371 | 484 | if ($max != $globalMinFetch) { |
372 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
485 | + if ($globalDebug) { |
|
486 | + echo 'Sleeping...'."\n"; |
|
487 | + } |
|
373 | 488 | sleep($globalMinFetch-$max+2); |
374 | 489 | } |
375 | 490 | } |
@@ -378,11 +493,15 @@ discard block |
||
378 | 493 | //foreach ($formats as $id => $value) { |
379 | 494 | foreach ($globalSources as $id => $value) { |
380 | 495 | date_default_timezone_set('UTC'); |
381 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
496 | + if (!isset($last_exec[$id]['last'])) { |
|
497 | + $last_exec[$id]['last'] = 0; |
|
498 | + } |
|
382 | 499 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
383 | 500 | //$buffer = $Common->getData($hosts[$id]); |
384 | 501 | $buffer = $Common->getData($value['host']); |
385 | - if ($buffer != '') $reset = 0; |
|
502 | + if ($buffer != '') { |
|
503 | + $reset = 0; |
|
504 | + } |
|
386 | 505 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
387 | 506 | $buffer = explode('\n',$buffer); |
388 | 507 | foreach ($buffer as $line) { |
@@ -391,20 +510,41 @@ discard block |
||
391 | 510 | $data = array(); |
392 | 511 | $data['hex'] = $line[1]; // hex |
393 | 512 | $data['ident'] = $line[2]; // ident |
394 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
395 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
396 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
397 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
398 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
513 | + if (isset($line[3])) { |
|
514 | + $data['altitude'] = $line[3]; |
|
515 | + } |
|
516 | + // altitude |
|
517 | + if (isset($line[4])) { |
|
518 | + $data['speed'] = $line[4]; |
|
519 | + } |
|
520 | + // speed |
|
521 | + if (isset($line[5])) { |
|
522 | + $data['heading'] = $line[5]; |
|
523 | + } |
|
524 | + // heading |
|
525 | + if (isset($line[6])) { |
|
526 | + $data['latitude'] = $line[6]; |
|
527 | + } |
|
528 | + // lat |
|
529 | + if (isset($line[7])) { |
|
530 | + $data['longitude'] = $line[7]; |
|
531 | + } |
|
532 | + // long |
|
399 | 533 | $data['verticalrate'] = ''; // vertical rate |
400 | 534 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
401 | 535 | $data['emergency'] = ''; // emergency |
402 | 536 | $data['datetime'] = date('Y-m-d H:i:s'); |
403 | 537 | $data['format_source'] = 'deltadbtxt'; |
404 | 538 | $data['id_source'] = $id_source; |
405 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
406 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
407 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
539 | + if (isset($value['name']) && $value['name'] != '') { |
|
540 | + $data['source_name'] = $value['name']; |
|
541 | + } |
|
542 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
543 | + $data['noarchive'] = true; |
|
544 | + } |
|
545 | + if (isset($value['sourcestats'])) { |
|
546 | + $data['sourcestats'] = $value['sourcestats']; |
|
547 | + } |
|
408 | 548 | $SI->add($data); |
409 | 549 | unset($data); |
410 | 550 | } |
@@ -414,7 +554,9 @@ discard block |
||
414 | 554 | date_default_timezone_set('CET'); |
415 | 555 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
416 | 556 | date_default_timezone_set('UTC'); |
417 | - if ($buffer != '') $reset = 0; |
|
557 | + if ($buffer != '') { |
|
558 | + $reset = 0; |
|
559 | + } |
|
418 | 560 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
419 | 561 | $buffer = explode('\n',$buffer); |
420 | 562 | foreach ($buffer as $line) { |
@@ -423,16 +565,36 @@ discard block |
||
423 | 565 | $add = false; |
424 | 566 | $ais_data = $AIS->parse_line(trim($line)); |
425 | 567 | $data = array(); |
426 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
427 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
428 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
429 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
430 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
431 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
432 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
433 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
434 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
435 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
568 | + if (isset($ais_data['ident'])) { |
|
569 | + $data['ident'] = $ais_data['ident']; |
|
570 | + } |
|
571 | + if (isset($ais_data['mmsi'])) { |
|
572 | + $data['mmsi'] = $ais_data['mmsi']; |
|
573 | + } |
|
574 | + if (isset($ais_data['speed'])) { |
|
575 | + $data['speed'] = $ais_data['speed']; |
|
576 | + } |
|
577 | + if (isset($ais_data['heading'])) { |
|
578 | + $data['heading'] = $ais_data['heading']; |
|
579 | + } |
|
580 | + if (isset($ais_data['latitude'])) { |
|
581 | + $data['latitude'] = $ais_data['latitude']; |
|
582 | + } |
|
583 | + if (isset($ais_data['longitude'])) { |
|
584 | + $data['longitude'] = $ais_data['longitude']; |
|
585 | + } |
|
586 | + if (isset($ais_data['status'])) { |
|
587 | + $data['status'] = $ais_data['status']; |
|
588 | + } |
|
589 | + if (isset($ais_data['type'])) { |
|
590 | + $data['type'] = $ais_data['type']; |
|
591 | + } |
|
592 | + if (isset($ais_data['imo'])) { |
|
593 | + $data['imo'] = $ais_data['imo']; |
|
594 | + } |
|
595 | + if (isset($ais_data['callsign'])) { |
|
596 | + $data['callsign'] = $ais_data['callsign']; |
|
597 | + } |
|
436 | 598 | if (isset($ais_data['timestamp'])) { |
437 | 599 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
438 | 600 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -446,8 +608,12 @@ discard block |
||
446 | 608 | $data['format_source'] = 'aisnmeatxt'; |
447 | 609 | $data['id_source'] = $id_source; |
448 | 610 | //print_r($data); |
449 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
450 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
611 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
612 | + $data['noarchive'] = true; |
|
613 | + } |
|
614 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
615 | + $MI->add($data); |
|
616 | + } |
|
451 | 617 | unset($data); |
452 | 618 | } |
453 | 619 | } |
@@ -467,20 +633,48 @@ discard block |
||
467 | 633 | if ($line != '') { |
468 | 634 | $ais_data = $AIS->parse_line(trim($line)); |
469 | 635 | $data = array(); |
470 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
471 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
472 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
473 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
474 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
475 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
476 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
477 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
478 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
479 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
480 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
481 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
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']); |
|
636 | + if (isset($ais_data['ident'])) { |
|
637 | + $data['ident'] = $ais_data['ident']; |
|
638 | + } |
|
639 | + if (isset($ais_data['mmsi'])) { |
|
640 | + $data['mmsi'] = $ais_data['mmsi']; |
|
641 | + } |
|
642 | + if (isset($ais_data['speed'])) { |
|
643 | + $data['speed'] = $ais_data['speed']; |
|
644 | + } |
|
645 | + if (isset($ais_data['heading'])) { |
|
646 | + $data['heading'] = $ais_data['heading']; |
|
647 | + } |
|
648 | + if (isset($ais_data['latitude'])) { |
|
649 | + $data['latitude'] = $ais_data['latitude']; |
|
650 | + } |
|
651 | + if (isset($ais_data['longitude'])) { |
|
652 | + $data['longitude'] = $ais_data['longitude']; |
|
653 | + } |
|
654 | + if (isset($ais_data['status'])) { |
|
655 | + $data['status'] = $ais_data['status']; |
|
656 | + } |
|
657 | + if (isset($ais_data['statusid'])) { |
|
658 | + $data['status_id'] = $ais_data['statusid']; |
|
659 | + } |
|
660 | + if (isset($ais_data['type'])) { |
|
661 | + $data['type'] = $ais_data['type']; |
|
662 | + } |
|
663 | + if (isset($ais_data['typeid'])) { |
|
664 | + $data['type_id'] = $ais_data['typeid']; |
|
665 | + } |
|
666 | + if (isset($ais_data['imo'])) { |
|
667 | + $data['imo'] = $ais_data['imo']; |
|
668 | + } |
|
669 | + if (isset($ais_data['callsign'])) { |
|
670 | + $data['callsign'] = $ais_data['callsign']; |
|
671 | + } |
|
672 | + if (isset($ais_data['destination'])) { |
|
673 | + $data['arrival_code'] = $ais_data['destination']; |
|
674 | + } |
|
675 | + if (isset($ais_data['eta_ts'])) { |
|
676 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
677 | + } |
|
484 | 678 | if (isset($ais_data['timestamp'])) { |
485 | 679 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
486 | 680 | } else { |
@@ -488,18 +682,27 @@ discard block |
||
488 | 682 | } |
489 | 683 | $data['format_source'] = 'aisnmeahttp'; |
490 | 684 | $data['id_source'] = $id_source; |
491 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
492 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
685 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
686 | + $data['noarchive'] = true; |
|
687 | + } |
|
688 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
689 | + $MI->add($data); |
|
690 | + } |
|
493 | 691 | unset($data); |
494 | 692 | } |
495 | 693 | } |
496 | 694 | } |
497 | 695 | } else { |
498 | 696 | $format = $value['format']; |
499 | - if (isset($tt[$format])) $tt[$format]++; |
|
500 | - else $tt[$format] = 0; |
|
697 | + if (isset($tt[$format])) { |
|
698 | + $tt[$format]++; |
|
699 | + } else { |
|
700 | + $tt[$format] = 0; |
|
701 | + } |
|
501 | 702 | if ($tt[$format] > 30) { |
502 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
703 | + if ($globalDebug) { |
|
704 | + echo 'Reconnect...'."\n"; |
|
705 | + } |
|
503 | 706 | sleep(2); |
504 | 707 | $sourceeen[] = $value; |
505 | 708 | connect_all($sourceeen); |
@@ -529,7 +732,9 @@ discard block |
||
529 | 732 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
530 | 733 | $data['format_source'] = 'myshiptracking'; |
531 | 734 | $data['id_source'] = $id_source; |
532 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
735 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
736 | + $data['noarchive'] = true; |
|
737 | + } |
|
533 | 738 | $MI->add($data); |
534 | 739 | unset($data); |
535 | 740 | } |
@@ -549,7 +754,9 @@ discard block |
||
549 | 754 | $data['callsign'] = $line['callsign']; |
550 | 755 | $data['mmsi'] = $line['mmsi']; |
551 | 756 | $data['speed'] = $line['sog']; |
552 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
757 | + if ($line['heading'] != '511') { |
|
758 | + $data['heading'] = $line['heading']; |
|
759 | + } |
|
553 | 760 | $data['latitude'] = $line['latitude']; |
554 | 761 | $data['longitude'] = $line['longitude']; |
555 | 762 | $data['type_id'] = $line['shiptype']; |
@@ -557,7 +764,9 @@ discard block |
||
557 | 764 | $data['datetime'] = $line['time']; |
558 | 765 | $data['format_source'] = 'boatbeaconapp'; |
559 | 766 | $data['id_source'] = $id_source; |
560 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
767 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
768 | + $data['noarchive'] = true; |
|
769 | + } |
|
561 | 770 | $MI->add($data); |
562 | 771 | unset($data); |
563 | 772 | } |
@@ -573,22 +782,44 @@ discard block |
||
573 | 782 | if (isset($all_data['features'][0]['id'])) { |
574 | 783 | foreach ($all_data['features'] as $line) { |
575 | 784 | $data = array(); |
576 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
577 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
578 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; |
|
579 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; |
|
580 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
581 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; |
|
785 | + if (isset($line['properties']['name'])) { |
|
786 | + $data['ident'] = $line['properties']['name']; |
|
787 | + } |
|
788 | + if (isset($line['properties']['callsign'])) { |
|
789 | + $data['callsign'] = $line['properties']['callsign']; |
|
790 | + } |
|
791 | + if (isset($line['properties']['mmsi'])) { |
|
792 | + $data['mmsi'] = $line['properties']['mmsi']; |
|
793 | + } |
|
794 | + if (isset($line['properties']['imo'])) { |
|
795 | + $data['mmsi'] = $line['properties']['imo']; |
|
796 | + } |
|
797 | + if (isset($line['properties']['speed'])) { |
|
798 | + $data['speed'] = $line['properties']['speed']; |
|
799 | + } |
|
800 | + if (isset($line['properties']['heading'])) { |
|
801 | + $data['heading'] = $line['properties']['heading']; |
|
802 | + } |
|
582 | 803 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
583 | 804 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
584 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
585 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
586 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
805 | + if (isset($line['properties']['vesselType'])) { |
|
806 | + $data['type'] = $line['properties']['vesselType']; |
|
807 | + } |
|
808 | + if (isset($line['properties']['destination'])) { |
|
809 | + $data['arrival_code'] = $line['properties']['destination']; |
|
810 | + } |
|
811 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
812 | + $data['arrival_date'] = $line['properties']['eta']; |
|
813 | + } |
|
587 | 814 | $data['format_source'] = 'boatnerd'; |
588 | 815 | $data['id_source'] = $id_source; |
589 | 816 | $data['datetime'] = date('Y-m-d H:i:s'); |
590 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
591 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
817 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
818 | + $data['noarchive'] = true; |
|
819 | + } |
|
820 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
821 | + $MI->add($data); |
|
822 | + } |
|
592 | 823 | unset($data); |
593 | 824 | } |
594 | 825 | } |
@@ -599,7 +830,9 @@ discard block |
||
599 | 830 | echo 'download...'; |
600 | 831 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
601 | 832 | echo 'done !'."\n"; |
602 | - if ($buffer != '') $reset = 0; |
|
833 | + if ($buffer != '') { |
|
834 | + $reset = 0; |
|
835 | + } |
|
603 | 836 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
604 | 837 | $buffer = explode('\n',$buffer); |
605 | 838 | foreach ($buffer as $line) { |
@@ -624,7 +857,9 @@ discard block |
||
624 | 857 | //$data['etaTime'] = substr($line,135,5); |
625 | 858 | $data['format_source'] = 'shipplotter'; |
626 | 859 | $data['id_source'] = $id_source; |
627 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
860 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
861 | + $data['noarchive'] = true; |
|
862 | + } |
|
628 | 863 | //print_r($data); |
629 | 864 | echo 'Add...'."\n"; |
630 | 865 | $MI->add($data); |
@@ -644,16 +879,28 @@ discard block |
||
644 | 879 | $line = explode(':', $line); |
645 | 880 | if (count($line) > 30 && $line[0] != 'callsign') { |
646 | 881 | $data = array(); |
647 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
648 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
882 | + if (isset($line[37]) && $line[37] != '') { |
|
883 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
884 | + } else { |
|
885 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
886 | + } |
|
649 | 887 | $data['pilot_id'] = $line[1]; |
650 | 888 | $data['pilot_name'] = $line[2]; |
651 | 889 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
652 | 890 | $data['ident'] = $line[0]; // ident |
653 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
891 | + if ($line[7] != '' && $line[7] != 0) { |
|
892 | + $data['altitude'] = $line[7]; |
|
893 | + } |
|
894 | + // altitude |
|
654 | 895 | $data['speed'] = $line[8]; // speed |
655 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
656 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
896 | + if (isset($line[45])) { |
|
897 | + $data['heading'] = $line[45]; |
|
898 | + } |
|
899 | + // heading |
|
900 | + elseif (isset($line[38])) { |
|
901 | + $data['heading'] = $line[38]; |
|
902 | + } |
|
903 | + // heading |
|
657 | 904 | $data['latitude'] = $line[5]; // lat |
658 | 905 | $data['longitude'] = $line[6]; // long |
659 | 906 | $data['verticalrate'] = ''; // vertical rate |
@@ -669,7 +916,9 @@ discard block |
||
669 | 916 | $data['frequency'] = $line[4]; |
670 | 917 | $data['type'] = $line[18]; |
671 | 918 | $data['range'] = $line[19]; |
672 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
919 | + if (isset($line[35])) { |
|
920 | + $data['info'] = $line[35]; |
|
921 | + } |
|
673 | 922 | $data['id_source'] = $id_source; |
674 | 923 | //$data['arrival_airport_time'] = ; |
675 | 924 | if ($line[9] != '') { |
@@ -683,27 +932,47 @@ discard block |
||
683 | 932 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
684 | 933 | */ |
685 | 934 | $data['format_source'] = $value['format']; |
686 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
687 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
688 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
689 | - elseif ($line[3] == 'ATC') { |
|
935 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
936 | + $data['noarchive'] = true; |
|
937 | + } |
|
938 | + if (isset($value['name']) && $value['name'] != '') { |
|
939 | + $data['source_name'] = $value['name']; |
|
940 | + } |
|
941 | + if ($line[3] == 'PILOT') { |
|
942 | + $SI->add($data); |
|
943 | + } elseif ($line[3] == 'ATC') { |
|
690 | 944 | //print_r($data); |
691 | 945 | $data['info'] = str_replace('^§','<br />',$data['info']); |
692 | 946 | $data['info'] = str_replace('&sect;','',$data['info']); |
693 | 947 | $typec = substr($data['ident'],-3); |
694 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
695 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
696 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
697 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
698 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
699 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
700 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
701 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
702 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
703 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
948 | + if ($typec == 'APP') { |
|
949 | + $data['type'] = 'Approach'; |
|
950 | + } elseif ($typec == 'TWR') { |
|
951 | + $data['type'] = 'Tower'; |
|
952 | + } elseif ($typec == 'OBS') { |
|
953 | + $data['type'] = 'Observer'; |
|
954 | + } elseif ($typec == 'GND') { |
|
955 | + $data['type'] = 'Ground'; |
|
956 | + } elseif ($typec == 'DEL') { |
|
957 | + $data['type'] = 'Delivery'; |
|
958 | + } elseif ($typec == 'DEP') { |
|
959 | + $data['type'] = 'Departure'; |
|
960 | + } elseif ($typec == 'FSS') { |
|
961 | + $data['type'] = 'Flight Service Station'; |
|
962 | + } elseif ($typec == 'CTR') { |
|
963 | + $data['type'] = 'Control Radar or Centre'; |
|
964 | + } elseif ($data['type'] == '') { |
|
965 | + $data['type'] = 'Observer'; |
|
966 | + } |
|
967 | + if (!isset($data['source_name'])) { |
|
968 | + $data['source_name'] = ''; |
|
969 | + } |
|
704 | 970 | 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']); |
|
971 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
972 | + 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']); |
|
973 | + } else { |
|
974 | + 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']); |
|
975 | + } |
|
707 | 976 | } |
708 | 977 | } |
709 | 978 | unset($data); |
@@ -725,14 +994,20 @@ discard block |
||
725 | 994 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
726 | 995 | $data['latitude'] = (float)$line['pktLatitude']; |
727 | 996 | $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']; |
|
997 | + if ((float)$line['pktTrack'] != 0) { |
|
998 | + $data['heading'] = (float)$line['pktTrack']; |
|
999 | + } |
|
1000 | + if ((int)$line['pktSpeed'] != 0) { |
|
1001 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1002 | + } |
|
730 | 1003 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
731 | 1004 | $data['altitude_relative'] = 'AMSL'; |
732 | 1005 | $data['pilot_id'] = (int)$line['pktPilotID']; |
733 | 1006 | $data['aircraft_icao'] = 'PARAGLIDER'; |
734 | 1007 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
735 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1008 | + if (isset($pilot_data[4])) { |
|
1009 | + $data['pilot_name'] = $pilot_data[4]; |
|
1010 | + } |
|
736 | 1011 | $data['format_source'] = $value['format']; |
737 | 1012 | $SI->add($data); |
738 | 1013 | unset($data); |
@@ -769,27 +1044,61 @@ discard block |
||
769 | 1044 | foreach ($all_data['acList'] as $line) { |
770 | 1045 | $data = array(); |
771 | 1046 | $data['hex'] = $line['Icao']; // hex |
772 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
773 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
774 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
775 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
776 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
777 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1047 | + if (isset($line['Call'])) { |
|
1048 | + $data['ident'] = $line['Call']; |
|
1049 | + } |
|
1050 | + // ident |
|
1051 | + if (isset($line['Alt'])) { |
|
1052 | + $data['altitude'] = $line['Alt']; |
|
1053 | + } |
|
1054 | + // altitude |
|
1055 | + if (isset($line['Spd'])) { |
|
1056 | + $data['speed'] = $line['Spd']; |
|
1057 | + } |
|
1058 | + // speed |
|
1059 | + if (isset($line['Trak'])) { |
|
1060 | + $data['heading'] = $line['Trak']; |
|
1061 | + } |
|
1062 | + // heading |
|
1063 | + if (isset($line['Lat'])) { |
|
1064 | + $data['latitude'] = $line['Lat']; |
|
1065 | + } |
|
1066 | + // lat |
|
1067 | + if (isset($line['Long'])) { |
|
1068 | + $data['longitude'] = $line['Long']; |
|
1069 | + } |
|
1070 | + // long |
|
778 | 1071 | //$data['verticalrate'] = $line['']; // verticale rate |
779 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1072 | + if (isset($line['Sqk'])) { |
|
1073 | + $data['squawk'] = $line['Sqk']; |
|
1074 | + } |
|
1075 | + // squawk |
|
780 | 1076 | $data['emergency'] = ''; // emergency |
781 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1077 | + if (isset($line['Reg'])) { |
|
1078 | + $data['registration'] = $line['Reg']; |
|
1079 | + } |
|
782 | 1080 | |
783 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
784 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1081 | + if (isset($line['PosTime'])) { |
|
1082 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1083 | + } else { |
|
1084 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1085 | + } |
|
785 | 1086 | |
786 | 1087 | //$data['datetime'] = date('Y-m-d H:i:s'); |
787 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1088 | + if (isset($line['Type'])) { |
|
1089 | + $data['aircraft_icao'] = $line['Type']; |
|
1090 | + } |
|
788 | 1091 | $data['format_source'] = 'aircraftlistjson'; |
789 | 1092 | $data['id_source'] = $id_source; |
790 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
791 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
792 | - if (isset($data['latitude'])) $SI->add($data); |
|
1093 | + if (isset($value['name']) && $value['name'] != '') { |
|
1094 | + $data['source_name'] = $value['name']; |
|
1095 | + } |
|
1096 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1097 | + $data['noarchive'] = true; |
|
1098 | + } |
|
1099 | + if (isset($data['latitude'])) { |
|
1100 | + $SI->add($data); |
|
1101 | + } |
|
793 | 1102 | unset($data); |
794 | 1103 | } |
795 | 1104 | } elseif (is_array($all_data)) { |
@@ -806,12 +1115,19 @@ discard block |
||
806 | 1115 | $data['verticalrate'] = $line['vrt']; // verticale rate |
807 | 1116 | $data['squawk'] = $line['squawk']; // squawk |
808 | 1117 | $data['emergency'] = ''; // emergency |
809 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
810 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1118 | + if (isset($line['PosTime'])) { |
|
1119 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1120 | + } else { |
|
1121 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1122 | + } |
|
811 | 1123 | $data['format_source'] = 'aircraftlistjson'; |
812 | 1124 | $data['id_source'] = $id_source; |
813 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
814 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1125 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1126 | + $data['noarchive'] = true; |
|
1127 | + } |
|
1128 | + if (isset($value['name']) && $value['name'] != '') { |
|
1129 | + $data['source_name'] = $value['name']; |
|
1130 | + } |
|
815 | 1131 | $SI->add($data); |
816 | 1132 | unset($data); |
817 | 1133 | } |
@@ -847,8 +1163,12 @@ discard block |
||
847 | 1163 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
848 | 1164 | $data['format_source'] = 'planeupdatefaa'; |
849 | 1165 | $data['id_source'] = $id_source; |
850 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
851 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1166 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1167 | + $data['noarchive'] = true; |
|
1168 | + } |
|
1169 | + if (isset($value['name']) && $value['name'] != '') { |
|
1170 | + $data['source_name'] = $value['name']; |
|
1171 | + } |
|
852 | 1172 | $SI->add($data); |
853 | 1173 | unset($data); |
854 | 1174 | } |
@@ -877,7 +1197,9 @@ discard block |
||
877 | 1197 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
878 | 1198 | $data['format_source'] = 'opensky'; |
879 | 1199 | $data['id_source'] = $id_source; |
880 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1200 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1201 | + $data['noarchive'] = true; |
|
1202 | + } |
|
881 | 1203 | $SI->add($data); |
882 | 1204 | unset($data); |
883 | 1205 | } |
@@ -889,7 +1211,9 @@ discard block |
||
889 | 1211 | //$buffer = $Common->getData($hosts[$id]); |
890 | 1212 | $buffer = $Common->getData($value['host']); |
891 | 1213 | $all_data = json_decode($buffer,true); |
892 | - if (!empty($all_data)) $reset = 0; |
|
1214 | + if (!empty($all_data)) { |
|
1215 | + $reset = 0; |
|
1216 | + } |
|
893 | 1217 | foreach ($all_data as $key => $line) { |
894 | 1218 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
895 | 1219 | $data = array(); |
@@ -910,8 +1234,12 @@ discard block |
||
910 | 1234 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
911 | 1235 | $data['format_source'] = 'fr24json'; |
912 | 1236 | $data['id_source'] = $id_source; |
913 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
914 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1237 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1238 | + $data['noarchive'] = true; |
|
1239 | + } |
|
1240 | + if (isset($value['name']) && $value['name'] != '') { |
|
1241 | + $data['source_name'] = $value['name']; |
|
1242 | + } |
|
915 | 1243 | $SI->add($data); |
916 | 1244 | unset($data); |
917 | 1245 | } |
@@ -935,24 +1263,42 @@ discard block |
||
935 | 1263 | if (isset($line['inf'])) { |
936 | 1264 | $data = array(); |
937 | 1265 | $data['hex'] = $line['inf']['ia']; |
938 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1266 | + if (isset($line['inf']['cs'])) { |
|
1267 | + $data['ident'] = $line['inf']['cs']; |
|
1268 | + } |
|
1269 | + //$line[13] |
|
939 | 1270 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
940 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
941 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1271 | + if (isset($line['inf']['gs'])) { |
|
1272 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1273 | + } |
|
1274 | + // speed |
|
1275 | + if (isset($line['inf']['tr'])) { |
|
1276 | + $data['heading'] = $line['inf']['tr']; |
|
1277 | + } |
|
1278 | + // heading |
|
942 | 1279 | $data['latitude'] = $line['pt'][0]; // lat |
943 | 1280 | $data['longitude'] = $line['pt'][1]; // long |
944 | 1281 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
945 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1282 | + if (isset($line['inf']['sq'])) { |
|
1283 | + $data['squawk'] = $line['inf']['sq']; |
|
1284 | + } |
|
1285 | + // squawk |
|
946 | 1286 | //$data['aircraft_icao'] = $line[8]; |
947 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1287 | + if (isset($line['inf']['rc'])) { |
|
1288 | + $data['registration'] = $line['inf']['rc']; |
|
1289 | + } |
|
948 | 1290 | //$data['departure_airport_iata'] = $line[11]; |
949 | 1291 | //$data['arrival_airport_iata'] = $line[12]; |
950 | 1292 | //$data['emergency'] = ''; // emergency |
951 | 1293 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
952 | 1294 | $data['format_source'] = 'radarvirtueljson'; |
953 | 1295 | $data['id_source'] = $id_source; |
954 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
955 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1296 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1297 | + $data['noarchive'] = true; |
|
1298 | + } |
|
1299 | + if (isset($value['name']) && $value['name'] != '') { |
|
1300 | + $data['source_name'] = $value['name']; |
|
1301 | + } |
|
956 | 1302 | $SI->add($data); |
957 | 1303 | unset($data); |
958 | 1304 | } |
@@ -973,30 +1319,65 @@ discard block |
||
973 | 1319 | $data['id'] = $line['id']; |
974 | 1320 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
975 | 1321 | $data['ident'] = $line['callsign']; // ident |
976 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
977 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
978 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
979 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
980 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
981 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1322 | + if (isset($line['pilotid'])) { |
|
1323 | + $data['pilot_id'] = $line['pilotid']; |
|
1324 | + } |
|
1325 | + // pilot id |
|
1326 | + if (isset($line['name'])) { |
|
1327 | + $data['pilot_name'] = $line['name']; |
|
1328 | + } |
|
1329 | + // pilot name |
|
1330 | + if (isset($line['alt'])) { |
|
1331 | + $data['altitude'] = $line['alt']; |
|
1332 | + } |
|
1333 | + // altitude |
|
1334 | + if (isset($line['gs'])) { |
|
1335 | + $data['speed'] = $line['gs']; |
|
1336 | + } |
|
1337 | + // speed |
|
1338 | + if (isset($line['heading'])) { |
|
1339 | + $data['heading'] = $line['heading']; |
|
1340 | + } |
|
1341 | + // heading |
|
1342 | + if (isset($line['route'])) { |
|
1343 | + $data['waypoints'] = $line['route']; |
|
1344 | + } |
|
1345 | + // route |
|
982 | 1346 | $data['latitude'] = $line['lat']; // lat |
983 | 1347 | $data['longitude'] = $line['lon']; // long |
984 | 1348 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
985 | 1349 | //$data['squawk'] = $line['squawk']; // squawk |
986 | 1350 | //$data['emergency'] = ''; // emergency |
987 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
988 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
989 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1351 | + if (isset($line['depicao'])) { |
|
1352 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1353 | + } |
|
1354 | + if (isset($line['deptime'])) { |
|
1355 | + $data['departure_airport_time'] = $line['deptime']; |
|
1356 | + } |
|
1357 | + if (isset($line['arricao'])) { |
|
1358 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1359 | + } |
|
990 | 1360 | //$data['arrival_airport_time'] = $line['arrtime']; |
991 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
992 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
993 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
994 | - else $data['info'] = ''; |
|
1361 | + if (isset($line['aircraft'])) { |
|
1362 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1363 | + } |
|
1364 | + if (isset($line['transponder'])) { |
|
1365 | + $data['squawk'] = $line['transponder']; |
|
1366 | + } |
|
1367 | + if (isset($line['atis'])) { |
|
1368 | + $data['info'] = $line['atis']; |
|
1369 | + } else { |
|
1370 | + $data['info'] = ''; |
|
1371 | + } |
|
995 | 1372 | $data['format_source'] = 'pireps'; |
996 | 1373 | $data['id_source'] = $id_source; |
997 | 1374 | $data['datetime'] = date('Y-m-d H:i:s'); |
998 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
999 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1375 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1376 | + $data['noarchive'] = true; |
|
1377 | + } |
|
1378 | + if (isset($value['name']) && $value['name'] != '') { |
|
1379 | + $data['source_name'] = $value['name']; |
|
1380 | + } |
|
1000 | 1381 | if ($line['icon'] == 'plane') { |
1001 | 1382 | $SI->add($data); |
1002 | 1383 | // print_r($data); |
@@ -1005,16 +1386,28 @@ discard block |
||
1005 | 1386 | $data['info'] = str_replace('&sect;','',$data['info']); |
1006 | 1387 | $typec = substr($data['ident'],-3); |
1007 | 1388 | $data['type'] = ''; |
1008 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
1009 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
1010 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
1011 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
1012 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
1013 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
1014 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
1015 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
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']); |
|
1389 | + if ($typec == 'APP') { |
|
1390 | + $data['type'] = 'Approach'; |
|
1391 | + } elseif ($typec == 'TWR') { |
|
1392 | + $data['type'] = 'Tower'; |
|
1393 | + } elseif ($typec == 'OBS') { |
|
1394 | + $data['type'] = 'Observer'; |
|
1395 | + } elseif ($typec == 'GND') { |
|
1396 | + $data['type'] = 'Ground'; |
|
1397 | + } elseif ($typec == 'DEL') { |
|
1398 | + $data['type'] = 'Delivery'; |
|
1399 | + } elseif ($typec == 'DEP') { |
|
1400 | + $data['type'] = 'Departure'; |
|
1401 | + } elseif ($typec == 'FSS') { |
|
1402 | + $data['type'] = 'Flight Service Station'; |
|
1403 | + } elseif ($typec == 'CTR') { |
|
1404 | + $data['type'] = 'Control Radar or Centre'; |
|
1405 | + } else { |
|
1406 | + $data['type'] = 'Observer'; |
|
1407 | + } |
|
1408 | + if (isset($ATC)) { |
|
1409 | + 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']); |
|
1410 | + } |
|
1018 | 1411 | } |
1019 | 1412 | unset($data); |
1020 | 1413 | } |
@@ -1024,7 +1417,9 @@ discard block |
||
1024 | 1417 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1025 | 1418 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
1026 | 1419 | //$buffer = $Common->getData($hosts[$id]); |
1027 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1420 | + if ($globalDebug) { |
|
1421 | + echo 'Get Data...'."\n"; |
|
1422 | + } |
|
1028 | 1423 | $buffer = $Common->getData($value['host']); |
1029 | 1424 | $all_data = json_decode($buffer,true); |
1030 | 1425 | if ($buffer != '' && is_array($all_data)) { |
@@ -1032,10 +1427,16 @@ discard block |
||
1032 | 1427 | foreach ($all_data as $line) { |
1033 | 1428 | $data = array(); |
1034 | 1429 | //$data['id'] = $line['id']; // id not usable |
1035 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1430 | + if (isset($line['pilotid'])) { |
|
1431 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1432 | + } |
|
1036 | 1433 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1037 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1038 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1434 | + if (isset($line['pilotname'])) { |
|
1435 | + $data['pilot_name'] = $line['pilotname']; |
|
1436 | + } |
|
1437 | + if (isset($line['pilotid'])) { |
|
1438 | + $data['pilot_id'] = $line['pilotid']; |
|
1439 | + } |
|
1039 | 1440 | $data['ident'] = $line['flightnum']; // ident |
1040 | 1441 | $data['altitude'] = $line['alt']; // altitude |
1041 | 1442 | $data['speed'] = $line['gs']; // speed |
@@ -1051,34 +1452,52 @@ discard block |
||
1051 | 1452 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1052 | 1453 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1053 | 1454 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1054 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1455 | + } else { |
|
1456 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1457 | + } |
|
1055 | 1458 | $data['departure_airport_icao'] = $line['depicao']; |
1056 | 1459 | $data['departure_airport_time'] = $line['deptime']; |
1057 | 1460 | $data['arrival_airport_icao'] = $line['arricao']; |
1058 | 1461 | $data['arrival_airport_time'] = $line['arrtime']; |
1059 | 1462 | $data['registration'] = $line['aircraft']; |
1060 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1061 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1463 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1464 | + $data['noarchive'] = true; |
|
1465 | + } |
|
1466 | + if (isset($line['route'])) { |
|
1467 | + $data['waypoints'] = $line['route']; |
|
1468 | + } |
|
1469 | + // route |
|
1062 | 1470 | if (isset($line['aircraftname'])) { |
1063 | 1471 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1064 | 1472 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1065 | 1473 | $aircraft_data = explode('-',$line['aircraftname']); |
1066 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1067 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1068 | - else { |
|
1474 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1475 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1476 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1477 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1478 | + } else { |
|
1069 | 1479 | $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']); |
|
1480 | + if (isset($aircraft_data[1])) { |
|
1481 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1482 | + } else { |
|
1483 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1484 | + } |
|
1072 | 1485 | } |
1073 | 1486 | } |
1074 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1487 | + if (isset($line['route'])) { |
|
1488 | + $data['waypoints'] = $line['route']; |
|
1489 | + } |
|
1075 | 1490 | $data['id_source'] = $id_source; |
1076 | 1491 | $data['format_source'] = 'phpvmacars'; |
1077 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1492 | + if (isset($value['name']) && $value['name'] != '') { |
|
1493 | + $data['source_name'] = $value['name']; |
|
1494 | + } |
|
1078 | 1495 | $SI->add($data); |
1079 | 1496 | unset($data); |
1080 | 1497 | } |
1081 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1498 | + if ($globalDebug) { |
|
1499 | + echo 'No more data...'."\n"; |
|
1500 | + } |
|
1082 | 1501 | unset($buffer); |
1083 | 1502 | unset($all_data); |
1084 | 1503 | } |
@@ -1086,7 +1505,9 @@ discard block |
||
1086 | 1505 | $last_exec[$id]['last'] = time(); |
1087 | 1506 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
1088 | 1507 | //$buffer = $Common->getData($hosts[$id]); |
1089 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1508 | + if ($globalDebug) { |
|
1509 | + echo 'Get Data...'."\n"; |
|
1510 | + } |
|
1090 | 1511 | $buffer = $Common->getData($value['host']); |
1091 | 1512 | $all_data = json_decode($buffer,true); |
1092 | 1513 | if ($buffer != '' && is_array($all_data)) { |
@@ -1115,16 +1536,25 @@ discard block |
||
1115 | 1536 | $data['arrival_airport_icao'] = $line['arrival']; |
1116 | 1537 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1117 | 1538 | //$data['registration'] = $line['aircraft']; |
1118 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1539 | + if (isset($line['route'])) { |
|
1540 | + $data['waypoints'] = $line['route']; |
|
1541 | + } |
|
1542 | + // route |
|
1119 | 1543 | $data['aircraft_icao'] = $line['plane_type']; |
1120 | 1544 | $data['id_source'] = $id_source; |
1121 | 1545 | $data['format_source'] = 'vam'; |
1122 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1123 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1546 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1547 | + $data['noarchive'] = true; |
|
1548 | + } |
|
1549 | + if (isset($value['name']) && $value['name'] != '') { |
|
1550 | + $data['source_name'] = $value['name']; |
|
1551 | + } |
|
1124 | 1552 | $SI->add($data); |
1125 | 1553 | unset($data); |
1126 | 1554 | } |
1127 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1555 | + if ($globalDebug) { |
|
1556 | + echo 'No more data...'."\n"; |
|
1557 | + } |
|
1128 | 1558 | unset($buffer); |
1129 | 1559 | unset($all_data); |
1130 | 1560 | } |
@@ -1132,7 +1562,9 @@ discard block |
||
1132 | 1562 | $last_exec[$id]['last'] = time(); |
1133 | 1563 | } elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
1134 | 1564 | //$buffer = $Common->getData($hosts[$id]); |
1135 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1565 | + if ($globalDebug) { |
|
1566 | + echo 'Get Data...'."\n"; |
|
1567 | + } |
|
1136 | 1568 | $buffer = $Common->getData($value['host']); |
1137 | 1569 | $all_data = json_decode($buffer,true); |
1138 | 1570 | if ($buffer != '') { |
@@ -1150,18 +1582,24 @@ discard block |
||
1150 | 1582 | $data['id_source'] = $id_source; |
1151 | 1583 | $data['format_source'] = 'blitzortung'; |
1152 | 1584 | $SI->add($data); |
1153 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1585 | + if ($globalDebug) { |
|
1586 | + echo '☈ Lightning added'."\n"; |
|
1587 | + } |
|
1154 | 1588 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1155 | 1589 | unset($data); |
1156 | 1590 | } |
1157 | 1591 | } |
1158 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1592 | + if ($globalDebug) { |
|
1593 | + echo 'No more data...'."\n"; |
|
1594 | + } |
|
1159 | 1595 | unset($buffer); |
1160 | 1596 | } |
1161 | 1597 | $last_exec[$id]['last'] = time(); |
1162 | 1598 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1163 | 1599 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1164 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1600 | + if (function_exists('pcntl_fork')) { |
|
1601 | + pcntl_signal_dispatch(); |
|
1602 | + } |
|
1165 | 1603 | //$last_exec[$id]['last'] = time(); |
1166 | 1604 | |
1167 | 1605 | //$read = array( $sockets[$id] ); |
@@ -1169,7 +1607,9 @@ discard block |
||
1169 | 1607 | $write = NULL; |
1170 | 1608 | $e = NULL; |
1171 | 1609 | $n = socket_select($read, $write, $e, $timeout); |
1172 | - if ($e != NULL) var_dump($e); |
|
1610 | + if ($e != NULL) { |
|
1611 | + var_dump($e); |
|
1612 | + } |
|
1173 | 1613 | if ($n > 0) { |
1174 | 1614 | $reset = 0; |
1175 | 1615 | foreach ($read as $nb => $r) { |
@@ -1190,12 +1630,16 @@ discard block |
||
1190 | 1630 | //$SI::del(); |
1191 | 1631 | if ($format == 'vrstcp') { |
1192 | 1632 | $buffer = explode('},{',$buffer); |
1193 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1633 | + } else { |
|
1634 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1635 | + } |
|
1194 | 1636 | // SBS format is CSV format |
1195 | 1637 | if ($buffer !== FALSE && $buffer != '') { |
1196 | 1638 | $tt[$format] = 0; |
1197 | 1639 | if ($format == 'acarssbs3') { |
1198 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1640 | + if ($globalDebug) { |
|
1641 | + echo 'ACARS : '.$buffer."\n"; |
|
1642 | + } |
|
1199 | 1643 | $ACARS->add(trim($buffer)); |
1200 | 1644 | $ACARS->deleteLiveAcarsData(); |
1201 | 1645 | } elseif ($format == 'raw') { |
@@ -1204,30 +1648,70 @@ discard block |
||
1204 | 1648 | if (is_array($data)) { |
1205 | 1649 | $data['datetime'] = date('Y-m-d H:i:s'); |
1206 | 1650 | $data['format_source'] = 'raw'; |
1207 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1208 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1209 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1210 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1651 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1652 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1653 | + } |
|
1654 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1655 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1656 | + } |
|
1657 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1658 | + $data['noarchive'] = true; |
|
1659 | + } |
|
1660 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1661 | + $SI->add($data); |
|
1662 | + } |
|
1211 | 1663 | } |
1212 | 1664 | } elseif ($format == 'ais') { |
1213 | 1665 | $ais_data = $AIS->parse_line(trim($buffer)); |
1214 | 1666 | $data = array(); |
1215 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1216 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1217 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1218 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1219 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1220 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1221 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1222 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1223 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1224 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1225 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
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']); |
|
1228 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1229 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1230 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1667 | + if (isset($ais_data['ident'])) { |
|
1668 | + $data['ident'] = $ais_data['ident']; |
|
1669 | + } |
|
1670 | + if (isset($ais_data['mmsi'])) { |
|
1671 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1672 | + } |
|
1673 | + if (isset($ais_data['speed'])) { |
|
1674 | + $data['speed'] = $ais_data['speed']; |
|
1675 | + } |
|
1676 | + if (isset($ais_data['heading'])) { |
|
1677 | + $data['heading'] = $ais_data['heading']; |
|
1678 | + } |
|
1679 | + if (isset($ais_data['latitude'])) { |
|
1680 | + $data['latitude'] = $ais_data['latitude']; |
|
1681 | + } |
|
1682 | + if (isset($ais_data['longitude'])) { |
|
1683 | + $data['longitude'] = $ais_data['longitude']; |
|
1684 | + } |
|
1685 | + if (isset($ais_data['status'])) { |
|
1686 | + $data['status'] = $ais_data['status']; |
|
1687 | + } |
|
1688 | + if (isset($ais_data['statusid'])) { |
|
1689 | + $data['status_id'] = $ais_data['statusid']; |
|
1690 | + } |
|
1691 | + if (isset($ais_data['type'])) { |
|
1692 | + $data['type'] = $ais_data['type']; |
|
1693 | + } |
|
1694 | + if (isset($ais_data['imo'])) { |
|
1695 | + $data['imo'] = $ais_data['imo']; |
|
1696 | + } |
|
1697 | + if (isset($ais_data['callsign'])) { |
|
1698 | + $data['callsign'] = $ais_data['callsign']; |
|
1699 | + } |
|
1700 | + if (isset($ais_data['destination'])) { |
|
1701 | + $data['arrival_code'] = $ais_data['destination']; |
|
1702 | + } |
|
1703 | + if (isset($ais_data['eta_ts'])) { |
|
1704 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1705 | + } |
|
1706 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1707 | + $data['noarchive'] = true; |
|
1708 | + } |
|
1709 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1710 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1711 | + } |
|
1712 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1713 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1714 | + } |
|
1231 | 1715 | |
1232 | 1716 | if (isset($ais_data['timestamp'])) { |
1233 | 1717 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1236,7 +1720,9 @@ discard block |
||
1236 | 1720 | } |
1237 | 1721 | $data['format_source'] = 'aisnmea'; |
1238 | 1722 | $data['id_source'] = $id_source; |
1239 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1723 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1724 | + $MI->add($data); |
|
1725 | + } |
|
1240 | 1726 | unset($data); |
1241 | 1727 | } elseif ($format == 'flightgearsp') { |
1242 | 1728 | //echo $buffer."\n"; |
@@ -1254,12 +1740,18 @@ discard block |
||
1254 | 1740 | $data['speed'] = round($line[5]*1.94384); |
1255 | 1741 | $data['datetime'] = date('Y-m-d H:i:s'); |
1256 | 1742 | $data['format_source'] = 'flightgearsp'; |
1257 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1258 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1743 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1744 | + $data['noarchive'] = true; |
|
1745 | + } |
|
1746 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1747 | + $SI->add($data); |
|
1748 | + } |
|
1259 | 1749 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1260 | 1750 | } |
1261 | 1751 | } elseif ($format == 'acars') { |
1262 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1752 | + if ($globalDebug) { |
|
1753 | + echo 'ACARS : '.$buffer."\n"; |
|
1754 | + } |
|
1263 | 1755 | $ACARS->add(trim($buffer)); |
1264 | 1756 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1265 | 1757 | $ACARS->deleteLiveAcarsData(); |
@@ -1280,8 +1772,12 @@ discard block |
||
1280 | 1772 | $aircraft_type = $line[10]; |
1281 | 1773 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1282 | 1774 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1283 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1284 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1775 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1776 | + $data['noarchive'] = true; |
|
1777 | + } |
|
1778 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1779 | + $SI->add($data); |
|
1780 | + } |
|
1285 | 1781 | } |
1286 | 1782 | } |
1287 | 1783 | } elseif ($format == 'beast') { |
@@ -1291,28 +1787,62 @@ discard block |
||
1291 | 1787 | foreach($buffer as $all_data) { |
1292 | 1788 | $line = json_decode('{'.$all_data.'}',true); |
1293 | 1789 | $data = array(); |
1294 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1295 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1296 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1297 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1298 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1299 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1300 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1790 | + if (isset($line['Icao'])) { |
|
1791 | + $data['hex'] = $line['Icao']; |
|
1792 | + } |
|
1793 | + // hex |
|
1794 | + if (isset($line['Call'])) { |
|
1795 | + $data['ident'] = $line['Call']; |
|
1796 | + } |
|
1797 | + // ident |
|
1798 | + if (isset($line['Alt'])) { |
|
1799 | + $data['altitude'] = $line['Alt']; |
|
1800 | + } |
|
1801 | + // altitude |
|
1802 | + if (isset($line['Spd'])) { |
|
1803 | + $data['speed'] = $line['Spd']; |
|
1804 | + } |
|
1805 | + // speed |
|
1806 | + if (isset($line['Trak'])) { |
|
1807 | + $data['heading'] = $line['Trak']; |
|
1808 | + } |
|
1809 | + // heading |
|
1810 | + if (isset($line['Lat'])) { |
|
1811 | + $data['latitude'] = $line['Lat']; |
|
1812 | + } |
|
1813 | + // lat |
|
1814 | + if (isset($line['Long'])) { |
|
1815 | + $data['longitude'] = $line['Long']; |
|
1816 | + } |
|
1817 | + // long |
|
1301 | 1818 | //$data['verticalrate'] = $line['']; // verticale rate |
1302 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1819 | + if (isset($line['Sqk'])) { |
|
1820 | + $data['squawk'] = $line['Sqk']; |
|
1821 | + } |
|
1822 | + // squawk |
|
1303 | 1823 | $data['emergency'] = ''; // emergency |
1304 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1824 | + if (isset($line['Reg'])) { |
|
1825 | + $data['registration'] = $line['Reg']; |
|
1826 | + } |
|
1305 | 1827 | /* |
1306 | 1828 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1307 | 1829 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1308 | 1830 | */ |
1309 | 1831 | $data['datetime'] = date('Y-m-d H:i:s'); |
1310 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1832 | + if (isset($line['Type'])) { |
|
1833 | + $data['aircraft_icao'] = $line['Type']; |
|
1834 | + } |
|
1311 | 1835 | $data['format_source'] = 'vrstcp'; |
1312 | 1836 | $data['id_source'] = $id_source; |
1313 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1314 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1315 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1837 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1838 | + $data['noarchive'] = true; |
|
1839 | + } |
|
1840 | + if (isset($value['name']) && $value['name'] != '') { |
|
1841 | + $data['source_name'] = $value['name']; |
|
1842 | + } |
|
1843 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
1844 | + $SI->add($data); |
|
1845 | + } |
|
1316 | 1846 | unset($data); |
1317 | 1847 | } |
1318 | 1848 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1325,22 +1855,46 @@ discard block |
||
1325 | 1855 | $data['hex'] = $lined['hexid']; |
1326 | 1856 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1327 | 1857 | $data['datetime'] = date('Y-m-d H:i:s');; |
1328 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1329 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1330 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1331 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1332 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1333 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1334 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1858 | + if (isset($lined['ident'])) { |
|
1859 | + $data['ident'] = $lined['ident']; |
|
1860 | + } |
|
1861 | + if (isset($lined['lat'])) { |
|
1862 | + $data['latitude'] = $lined['lat']; |
|
1863 | + } |
|
1864 | + if (isset($lined['lon'])) { |
|
1865 | + $data['longitude'] = $lined['lon']; |
|
1866 | + } |
|
1867 | + if (isset($lined['speed'])) { |
|
1868 | + $data['speed'] = $lined['speed']; |
|
1869 | + } |
|
1870 | + if (isset($lined['squawk'])) { |
|
1871 | + $data['squawk'] = $lined['squawk']; |
|
1872 | + } |
|
1873 | + if (isset($lined['alt'])) { |
|
1874 | + $data['altitude'] = $lined['alt']; |
|
1875 | + } |
|
1876 | + if (isset($lined['heading'])) { |
|
1877 | + $data['heading'] = $lined['heading']; |
|
1878 | + } |
|
1335 | 1879 | $data['id_source'] = $id_source; |
1336 | 1880 | $data['format_source'] = 'tsv'; |
1337 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1338 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1339 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1340 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1881 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1882 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1883 | + } |
|
1884 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1885 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1886 | + } |
|
1887 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1888 | + $data['noarchive'] = true; |
|
1889 | + } |
|
1890 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1891 | + $SI->add($data); |
|
1892 | + } |
|
1341 | 1893 | unset($lined); |
1342 | 1894 | unset($data); |
1343 | - } else $error = true; |
|
1895 | + } else { |
|
1896 | + $error = true; |
|
1897 | + } |
|
1344 | 1898 | } elseif ($format == 'aprs' && $use_aprs) { |
1345 | 1899 | if ($aprs_connect == 0) { |
1346 | 1900 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1365,59 +1919,117 @@ discard block |
||
1365 | 1919 | $aprs_last_tx = time(); |
1366 | 1920 | $data = array(); |
1367 | 1921 | //print_r($line); |
1368 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1369 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1370 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1371 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1372 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1373 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1374 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
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']); |
|
1377 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1922 | + if (isset($line['address'])) { |
|
1923 | + $data['hex'] = $line['address']; |
|
1924 | + } |
|
1925 | + if (isset($line['mmsi'])) { |
|
1926 | + $data['mmsi'] = $line['mmsi']; |
|
1927 | + } |
|
1928 | + if (isset($line['imo'])) { |
|
1929 | + $data['imo'] = $line['imo']; |
|
1930 | + } |
|
1931 | + if (isset($line['squawk'])) { |
|
1932 | + $data['squawk'] = $line['squawk']; |
|
1933 | + } |
|
1934 | + if (isset($line['arrival_code'])) { |
|
1935 | + $data['arrical_code'] = $line['arrival_code']; |
|
1936 | + } |
|
1937 | + if (isset($line['arrival_date'])) { |
|
1938 | + $data['arrical_date'] = $line['arrival_date']; |
|
1939 | + } |
|
1940 | + if (isset($line['type_id'])) { |
|
1941 | + $data['type_id'] = $line['typeid']; |
|
1942 | + } |
|
1943 | + if (isset($line['status_id'])) { |
|
1944 | + $data['status_id'] = $line['statusid']; |
|
1945 | + } |
|
1946 | + if (isset($line['timestamp'])) { |
|
1947 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1948 | + } else { |
|
1949 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1950 | + } |
|
1378 | 1951 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1379 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1952 | + if (isset($line['ident'])) { |
|
1953 | + $data['ident'] = $line['ident']; |
|
1954 | + } |
|
1380 | 1955 | $data['latitude'] = $line['latitude']; |
1381 | 1956 | $data['longitude'] = $line['longitude']; |
1382 | 1957 | //$data['verticalrate'] = $line[16]; |
1383 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1958 | + if (isset($line['speed'])) { |
|
1959 | + $data['speed'] = $line['speed']; |
|
1960 | + } |
|
1384 | 1961 | //else $data['speed'] = 0; |
1385 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1386 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1387 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1388 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1962 | + if (isset($line['altitude'])) { |
|
1963 | + $data['altitude'] = $line['altitude']; |
|
1964 | + } |
|
1965 | + if (isset($line['comment'])) { |
|
1966 | + $data['comment'] = $line['comment']; |
|
1967 | + } |
|
1968 | + if (isset($line['symbol'])) { |
|
1969 | + $data['type'] = $line['symbol']; |
|
1970 | + } |
|
1971 | + if (isset($line['heading'])) { |
|
1972 | + $data['heading'] = $line['heading']; |
|
1973 | + } |
|
1389 | 1974 | //else $data['heading'] = 0; |
1390 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1975 | + if (isset($line['stealth'])) { |
|
1976 | + $data['aircraft_type'] = $line['stealth']; |
|
1977 | + } |
|
1391 | 1978 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1392 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1393 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1394 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1395 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1979 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
1980 | + $data['noarchive'] = true; |
|
1981 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
1982 | + $data['noarchive'] = false; |
|
1983 | + } |
|
1984 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1985 | + $data['noarchive'] = true; |
|
1986 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
1987 | + $data['noarchive'] = false; |
|
1988 | + } |
|
1396 | 1989 | $data['id_source'] = $id_source; |
1397 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1398 | - else $data['format_source'] = 'aprs'; |
|
1990 | + if (isset($line['format_source'])) { |
|
1991 | + $data['format_source'] = $line['format_source']; |
|
1992 | + } else { |
|
1993 | + $data['format_source'] = 'aprs'; |
|
1994 | + } |
|
1399 | 1995 | $data['source_name'] = $line['source']; |
1400 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1401 | - else $data['source_type'] = 'flarm'; |
|
1402 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1996 | + if (isset($line['source_type'])) { |
|
1997 | + $data['source_type'] = $line['source_type']; |
|
1998 | + } else { |
|
1999 | + $data['source_type'] = 'flarm'; |
|
2000 | + } |
|
2001 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2002 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2003 | + } |
|
1403 | 2004 | $currentdate = date('Y-m-d H:i:s'); |
1404 | 2005 | $aprsdate = strtotime($data['datetime']); |
1405 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2006 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2007 | + $data['altitude_relative'] = 'AMSL'; |
|
2008 | + } |
|
1406 | 2009 | // Accept data if time <= system time + 20s |
1407 | 2010 | //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1408 | 2011 | if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1409 | 2012 | $send = $SI->add($data); |
1410 | 2013 | } elseif ($data['source_type'] == 'ais') { |
1411 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2014 | + if (isset($globalMarine) && $globalMarine) { |
|
2015 | + $send = $MI->add($data); |
|
2016 | + } |
|
1412 | 2017 | } elseif (isset($line['stealth'])) { |
1413 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1414 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2018 | + if ($line['stealth'] != 0) { |
|
2019 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2020 | + } else { |
|
2021 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2022 | + } |
|
1415 | 2023 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1416 | 2024 | //$line['symbol'] == 'Balloon' || |
1417 | 2025 | $line['symbol'] == 'Glider' || |
1418 | 2026 | $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1419 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1420 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2027 | + if ($line['symbol'] == 'Ballon') { |
|
2028 | + $data['aircraft_icao'] = 'BALL'; |
|
2029 | + } |
|
2030 | + if ($line['symbol'] == 'Glider') { |
|
2031 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2032 | + } |
|
1421 | 2033 | $send = $SI->add($data); |
1422 | 2034 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1423 | 2035 | $line['symbol'] == 'Yacht (Sail)' || |
@@ -1448,9 +2060,13 @@ discard block |
||
1448 | 2060 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1449 | 2061 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1450 | 2062 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1451 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2063 | + if (isset($globalTracker) && $globalTracker) { |
|
2064 | + $send = $TI->add($data); |
|
2065 | + } |
|
1452 | 2066 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1453 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2067 | + if (!isset($data['altitude'])) { |
|
2068 | + $data['altitude'] = 0; |
|
2069 | + } |
|
1454 | 2070 | $Source->deleteOldLocationByType('gs'); |
1455 | 2071 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1456 | 2072 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1459,7 +2075,9 @@ discard block |
||
1459 | 2075 | } |
1460 | 2076 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1461 | 2077 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1462 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2078 | + if ($globalDebug) { |
|
2079 | + echo '# Weather Station added'."\n"; |
|
2080 | + } |
|
1463 | 2081 | $Source->deleteOldLocationByType('wx'); |
1464 | 2082 | $weather_data = json_encode($line); |
1465 | 2083 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1469,7 +2087,9 @@ discard block |
||
1469 | 2087 | } |
1470 | 2088 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
1471 | 2089 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1472 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2090 | + if ($globalDebug) { |
|
2091 | + echo '☈ Lightning added'."\n"; |
|
2092 | + } |
|
1473 | 2093 | $Source->deleteOldLocationByType('lightning'); |
1474 | 2094 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1475 | 2095 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1481,8 +2101,7 @@ discard block |
||
1481 | 2101 | print_r($line); |
1482 | 2102 | } |
1483 | 2103 | unset($data); |
1484 | - } |
|
1485 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2104 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1486 | 2105 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1487 | 2106 | } |
1488 | 2107 | /* |
@@ -1491,7 +2110,9 @@ discard block |
||
1491 | 2110 | } |
1492 | 2111 | */ |
1493 | 2112 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1494 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2113 | + elseif ($line == true && $globalDebug) { |
|
2114 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2115 | + } |
|
1495 | 2116 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1496 | 2117 | $Source->deleteOldLocationByType('lightning'); |
1497 | 2118 | $Source->deleteOldLocationByType('wx'); |
@@ -1527,26 +2148,45 @@ discard block |
||
1527 | 2148 | $data['ground'] = $line[21]; |
1528 | 2149 | $data['emergency'] = $line[19]; |
1529 | 2150 | $data['format_source'] = 'sbs'; |
1530 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1531 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1532 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2151 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2152 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2153 | + } |
|
2154 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2155 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2156 | + } |
|
2157 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2158 | + $data['noarchive'] = true; |
|
2159 | + } |
|
1533 | 2160 | $data['id_source'] = $id_source; |
1534 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1535 | - else $error = true; |
|
2161 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2162 | + $send = $SI->add($data); |
|
2163 | + } else { |
|
2164 | + $error = true; |
|
2165 | + } |
|
1536 | 2166 | unset($data); |
1537 | - } else $error = true; |
|
2167 | + } else { |
|
2168 | + $error = true; |
|
2169 | + } |
|
1538 | 2170 | if ($error) { |
1539 | 2171 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1540 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2172 | + if ($globalDebug) { |
|
2173 | + echo "Not a message. Ignoring... \n"; |
|
2174 | + } |
|
1541 | 2175 | } else { |
1542 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2176 | + if ($globalDebug) { |
|
2177 | + echo "Wrong line format. Ignoring... \n"; |
|
2178 | + } |
|
1543 | 2179 | if ($globalDebug) { |
1544 | 2180 | echo $buffer; |
1545 | 2181 | //print_r($line); |
1546 | 2182 | } |
1547 | 2183 | //socket_close($r); |
1548 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1549 | - if ($format == 'aprs') $aprs_connect = 0; |
|
2184 | + if ($globalDebug) { |
|
2185 | + echo "Reconnect after an error...\n"; |
|
2186 | + } |
|
2187 | + if ($format == 'aprs') { |
|
2188 | + $aprs_connect = 0; |
|
2189 | + } |
|
1550 | 2190 | $sourceer[$nb] = $globalSources[$nb]; |
1551 | 2191 | connect_all($sourceer); |
1552 | 2192 | $sourceer = array(); |
@@ -1554,10 +2194,14 @@ discard block |
||
1554 | 2194 | } |
1555 | 2195 | } |
1556 | 2196 | // Sleep for xxx microseconds |
1557 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2197 | + if (isset($globalSBSSleep)) { |
|
2198 | + usleep($globalSBSSleep); |
|
2199 | + } |
|
1558 | 2200 | } else { |
1559 | 2201 | if ($format == 'flightgearmp') { |
1560 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2202 | + if ($globalDebug) { |
|
2203 | + echo "Reconnect FlightGear MP..."; |
|
2204 | + } |
|
1561 | 2205 | //@socket_close($r); |
1562 | 2206 | sleep($globalMinFetch); |
1563 | 2207 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1566,10 +2210,15 @@ discard block |
||
1566 | 2210 | break; |
1567 | 2211 | |
1568 | 2212 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1569 | - if (isset($tt[$format])) $tt[$format]++; |
|
1570 | - else $tt[$format] = 0; |
|
2213 | + if (isset($tt[$format])) { |
|
2214 | + $tt[$format]++; |
|
2215 | + } else { |
|
2216 | + $tt[$format] = 0; |
|
2217 | + } |
|
1571 | 2218 | if ($tt[$format] > 30) { |
1572 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2219 | + if ($globalDebug) { |
|
2220 | + echo "ERROR : Reconnect ".$format."..."; |
|
2221 | + } |
|
1573 | 2222 | //@socket_close($r); |
1574 | 2223 | sleep(2); |
1575 | 2224 | $aprs_connect = 0; |
@@ -1586,11 +2235,17 @@ discard block |
||
1586 | 2235 | } else { |
1587 | 2236 | $error = socket_strerror(socket_last_error()); |
1588 | 2237 | 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"; |
|
1590 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2238 | + if ($globalDebug) { |
|
2239 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2240 | + } |
|
2241 | + if (isset($globalDebug)) { |
|
2242 | + echo "Restarting...\n"; |
|
2243 | + } |
|
1591 | 2244 | // Restart the script if possible |
1592 | 2245 | if (is_array($sockets)) { |
1593 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2246 | + if ($globalDebug) { |
|
2247 | + echo "Shutdown all sockets..."; |
|
2248 | + } |
|
1594 | 2249 | |
1595 | 2250 | foreach ($sockets as $sock) { |
1596 | 2251 | @socket_shutdown($sock,2); |
@@ -1598,25 +2253,45 @@ discard block |
||
1598 | 2253 | } |
1599 | 2254 | |
1600 | 2255 | } |
1601 | - if ($globalDebug) echo "Waiting..."; |
|
2256 | + if ($globalDebug) { |
|
2257 | + echo "Waiting..."; |
|
2258 | + } |
|
1602 | 2259 | sleep(2); |
1603 | 2260 | $time = time(); |
1604 | 2261 | //connect_all($hosts); |
1605 | 2262 | $aprs_connect = 0; |
1606 | - if ($reset%5 == 0) sleep(20); |
|
1607 | - if ($reset%10 == 0) sleep(100); |
|
1608 | - if ($reset%20 == 0) sleep(200); |
|
1609 | - if ($reset > 100) exit('Too many attempts...'); |
|
1610 | - if ($globalDebug) echo "Restart all connections..."; |
|
2263 | + if ($reset%5 == 0) { |
|
2264 | + sleep(20); |
|
2265 | + } |
|
2266 | + if ($reset%10 == 0) { |
|
2267 | + sleep(100); |
|
2268 | + } |
|
2269 | + if ($reset%20 == 0) { |
|
2270 | + sleep(200); |
|
2271 | + } |
|
2272 | + if ($reset > 100) { |
|
2273 | + exit('Too many attempts...'); |
|
2274 | + } |
|
2275 | + if ($globalDebug) { |
|
2276 | + echo "Restart all connections..."; |
|
2277 | + } |
|
1611 | 2278 | connect_all($globalSources); |
1612 | 2279 | } |
1613 | 2280 | } |
1614 | 2281 | } |
1615 | 2282 | if ($globalDaemon === false) { |
1616 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1617 | - if (isset($SI)) $SI->checkAll(); |
|
1618 | - if (isset($TI)) $TI->checkAll(); |
|
1619 | - if (isset($MI)) $MI->checkAll(); |
|
2283 | + if ($globalDebug) { |
|
2284 | + echo 'Check all...'."\n"; |
|
2285 | + } |
|
2286 | + if (isset($SI)) { |
|
2287 | + $SI->checkAll(); |
|
2288 | + } |
|
2289 | + if (isset($TI)) { |
|
2290 | + $TI->checkAll(); |
|
2291 | + } |
|
2292 | + if (isset($MI)) { |
|
2293 | + $MI->checkAll(); |
|
2294 | + } |
|
1620 | 2295 | } |
1621 | 2296 | } |
1622 | 2297 | } |
@@ -131,45 +131,72 @@ discard block |
||
131 | 131 | </div> |
132 | 132 | <p> |
133 | 133 | <label for="dbhost">Database hostname</label> |
134 | - <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" /> |
|
134 | + <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) { |
|
135 | + print $globalDBhost; |
|
136 | +} |
|
137 | +?>" /> |
|
135 | 138 | </p> |
136 | 139 | <p> |
137 | 140 | <label for="dbport">Database port</label> |
138 | - <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" /> |
|
141 | + <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) { |
|
142 | + print $globalDBport; |
|
143 | +} |
|
144 | +?>" /> |
|
139 | 145 | <p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p> |
140 | 146 | </p> |
141 | 147 | <p> |
142 | 148 | <label for="dbname">Database name</label> |
143 | - <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" /> |
|
149 | + <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) { |
|
150 | + print $globalDBname; |
|
151 | +} |
|
152 | +?>" /> |
|
144 | 153 | </p> |
145 | 154 | <p> |
146 | 155 | <label for="dbuser">Database user</label> |
147 | - <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" /> |
|
156 | + <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) { |
|
157 | + print $globalDBuser; |
|
158 | +} |
|
159 | +?>" /> |
|
148 | 160 | </p> |
149 | 161 | <p> |
150 | 162 | <label for="dbuserpass">Database user password</label> |
151 | - <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" /> |
|
163 | + <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) { |
|
164 | + print $globalDBpass; |
|
165 | +} |
|
166 | +?>" /> |
|
152 | 167 | </p> |
153 | 168 | </fieldset> |
154 | 169 | <fieldset id="site"> |
155 | 170 | <legend>Site configuration</legend> |
156 | 171 | <p> |
157 | 172 | <label for="sitename">Site name</label> |
158 | - <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" /> |
|
173 | + <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) { |
|
174 | + print $globalName; |
|
175 | +} |
|
176 | +?>" /> |
|
159 | 177 | </p> |
160 | 178 | <p> |
161 | 179 | <label for="siteurl">Site directory</label> |
162 | - <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" /> |
|
180 | + <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) { |
|
181 | + print $globalURL; |
|
182 | +} |
|
183 | +?>" /> |
|
163 | 184 | <p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p> |
164 | 185 | </p> |
165 | 186 | <p> |
166 | 187 | <label for="timezone">Timezone</label> |
167 | - <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" /> |
|
188 | + <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) { |
|
189 | + print $globalTimezone; |
|
190 | +} |
|
191 | +?>" /> |
|
168 | 192 | <p class="help-block">ex : UTC, Europe/Paris,...</p> |
169 | 193 | </p> |
170 | 194 | <p> |
171 | 195 | <label for="language">Language</label> |
172 | - <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" /> |
|
196 | + <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) { |
|
197 | + print $globalLanguage; |
|
198 | +} |
|
199 | +?>" /> |
|
173 | 200 | <p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p> |
174 | 201 | </p> |
175 | 202 | </fieldset> |
@@ -190,11 +217,17 @@ discard block |
||
190 | 217 | <div id="mapbox_data"> |
191 | 218 | <p> |
192 | 219 | <label for="mapboxid">Mapbox id</label> |
193 | - <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" /> |
|
220 | + <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) { |
|
221 | + print $globalMapboxId; |
|
222 | +} |
|
223 | +?>" /> |
|
194 | 224 | </p> |
195 | 225 | <p> |
196 | 226 | <label for="mapboxtoken">Mapbox token</label> |
197 | - <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" /> |
|
227 | + <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) { |
|
228 | + print $globalMapboxToken; |
|
229 | +} |
|
230 | +?>" /> |
|
198 | 231 | </p> |
199 | 232 | <p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p> |
200 | 233 | </div> |
@@ -202,7 +235,10 @@ discard block |
||
202 | 235 | <div id="google_data"> |
203 | 236 | <p> |
204 | 237 | <label for="googlekey">Google API key</label> |
205 | - <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" /> |
|
238 | + <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) { |
|
239 | + print $globalGoogleAPIKey; |
|
240 | +} |
|
241 | +?>" /> |
|
206 | 242 | <p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p> |
207 | 243 | </p> |
208 | 244 | </div> |
@@ -210,7 +246,10 @@ discard block |
||
210 | 246 | <div id="bing_data"> |
211 | 247 | <p> |
212 | 248 | <label for="bingkey">Bing Map key</label> |
213 | - <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" /> |
|
249 | + <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) { |
|
250 | + print $globalBingMapKey; |
|
251 | +} |
|
252 | +?>" /> |
|
214 | 253 | <p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p> |
215 | 254 | </p> |
216 | 255 | </div> |
@@ -218,7 +257,10 @@ discard block |
||
218 | 257 | <div id="mapquest_data"> |
219 | 258 | <p> |
220 | 259 | <label for="mapquestkey">MapQuest key</label> |
221 | - <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" /> |
|
260 | + <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) { |
|
261 | + print $globalMapQuestKey; |
|
262 | +} |
|
263 | +?>" /> |
|
222 | 264 | <p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p> |
223 | 265 | </p> |
224 | 266 | </div> |
@@ -226,11 +268,17 @@ discard block |
||
226 | 268 | <div id="here_data"> |
227 | 269 | <p> |
228 | 270 | <label for="hereappid">Here App_Id</label> |
229 | - <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" /> |
|
271 | + <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) { |
|
272 | + print $globalHereappId; |
|
273 | +} |
|
274 | +?>" /> |
|
230 | 275 | </p> |
231 | 276 | <p> |
232 | 277 | <label for="hereappcode">Here App_Code</label> |
233 | - <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" /> |
|
278 | + <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) { |
|
279 | + print $globalHereappCode; |
|
280 | +} |
|
281 | +?>" /> |
|
234 | 282 | </p> |
235 | 283 | <p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p> |
236 | 284 | </div> |
@@ -238,7 +286,10 @@ discard block |
||
238 | 286 | <div id="openweathermap_data"> |
239 | 287 | <p> |
240 | 288 | <label for="openweathermapkey">OpenWeatherMap key (weather layer)</label> |
241 | - <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" /> |
|
289 | + <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) { |
|
290 | + print $globalOpenWeatherMapKey; |
|
291 | +} |
|
292 | +?>" /> |
|
242 | 293 | <p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p> |
243 | 294 | </p> |
244 | 295 | </div> |
@@ -248,42 +299,86 @@ discard block |
||
248 | 299 | <legend>Coverage area</legend> |
249 | 300 | <p> |
250 | 301 | <label for="latitudemax">The maximum latitude (north)</label> |
251 | - <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" /> |
|
302 | + <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) { |
|
303 | + print $globalLatitudeMax; |
|
304 | +} |
|
305 | +?>" /> |
|
252 | 306 | </p> |
253 | 307 | <p> |
254 | 308 | <label for="latitudemin">The minimum latitude (south)</label> |
255 | - <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" /> |
|
309 | + <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) { |
|
310 | + print $globalLatitudeMin; |
|
311 | +} |
|
312 | +?>" /> |
|
256 | 313 | </p> |
257 | 314 | <p> |
258 | 315 | <label for="longitudemax">The maximum longitude (west)</label> |
259 | - <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" /> |
|
316 | + <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) { |
|
317 | + print $globalLongitudeMax; |
|
318 | +} |
|
319 | +?>" /> |
|
260 | 320 | </p> |
261 | 321 | <p> |
262 | 322 | <label for="longitudemin">The minimum longitude (east)</label> |
263 | - <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" /> |
|
323 | + <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) { |
|
324 | + print $globalLongitudeMin; |
|
325 | +} |
|
326 | +?>" /> |
|
264 | 327 | </p> |
265 | 328 | <p> |
266 | 329 | <label for="latitudecenter">The latitude center</label> |
267 | - <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" /> |
|
330 | + <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) { |
|
331 | + print $globalCenterLatitude; |
|
332 | +} |
|
333 | +?>" /> |
|
268 | 334 | </p> |
269 | 335 | <p> |
270 | 336 | <label for="longitudecenter">The longitude center</label> |
271 | - <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" /> |
|
337 | + <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) { |
|
338 | + print $globalCenterLongitude; |
|
339 | +} |
|
340 | +?>" /> |
|
272 | 341 | </p> |
273 | 342 | <p> |
274 | 343 | <label for="livezoom">Default Zoom on live map</label> |
275 | - <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" /> |
|
344 | + <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) { |
|
345 | + print $globalLiveZoom; |
|
346 | +} else { |
|
347 | + print '9'; |
|
348 | +} |
|
349 | +?>" /> |
|
276 | 350 | </p> |
277 | 351 | <p> |
278 | 352 | <label for="squawk_country">Country for squawk usage</label> |
279 | 353 | <select name="squawk_country" id="squawk_country"> |
280 | - <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option> |
|
281 | - <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option> |
|
282 | - <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option> |
|
283 | - <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option> |
|
284 | - <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option> |
|
285 | - <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option> |
|
286 | - <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option> |
|
354 | + <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') { |
|
355 | + print ' selected '; |
|
356 | +} |
|
357 | +?>>UK</option> |
|
358 | + <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') { |
|
359 | + print ' selected '; |
|
360 | +} |
|
361 | +?>>NZ</option> |
|
362 | + <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') { |
|
363 | + print ' selected '; |
|
364 | +} |
|
365 | +?>>US</option> |
|
366 | + <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') { |
|
367 | + print ' selected '; |
|
368 | +} |
|
369 | +?>>AU</option> |
|
370 | + <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') { |
|
371 | + print ' selected '; |
|
372 | +} |
|
373 | +?>>NL</option> |
|
374 | + <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') { |
|
375 | + print ' selected '; |
|
376 | +} |
|
377 | +?>>FR</option> |
|
378 | + <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') { |
|
379 | + print ' selected '; |
|
380 | +} |
|
381 | +?>>TR</option> |
|
287 | 382 | </select> |
288 | 383 | </p> |
289 | 384 | </fieldset> |
@@ -292,15 +387,24 @@ discard block |
||
292 | 387 | <p><i>Only put in DB flights that are inside a circle</i></p> |
293 | 388 | <p> |
294 | 389 | <label for="latitude">Center latitude</label> |
295 | - <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" /> |
|
390 | + <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) { |
|
391 | + echo $globalDistanceIgnore['latitude']; |
|
392 | +} |
|
393 | +?>" /> |
|
296 | 394 | </p> |
297 | 395 | <p> |
298 | 396 | <label for="longitude">Center longitude</label> |
299 | - <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" /> |
|
397 | + <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) { |
|
398 | + echo $globalDistanceIgnore['longitude']; |
|
399 | +} |
|
400 | +?>" /> |
|
300 | 401 | </p> |
301 | 402 | <p> |
302 | 403 | <label for="Distance">Distance (in km)</label> |
303 | - <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" /> |
|
404 | + <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) { |
|
405 | + echo $globalDistanceIgnore['distance']; |
|
406 | +} |
|
407 | +?>" /> |
|
304 | 408 | </p> |
305 | 409 | </fieldset> |
306 | 410 | <fieldset id="sourceloc"> |
@@ -409,11 +513,17 @@ discard block |
||
409 | 513 | <div id="flightaware_data"> |
410 | 514 | <p> |
411 | 515 | <label for="flightawareusername">FlightAware username</label> |
412 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
516 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
517 | + print $globalFlightAwareUsername; |
|
518 | +} |
|
519 | +?>" /> |
|
413 | 520 | </p> |
414 | 521 | <p> |
415 | 522 | <label for="flightawarepassword">FlightAware password/API key</label> |
416 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
523 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
524 | + print $globalFlightAwarePassword; |
|
525 | +} |
|
526 | +?>" /> |
|
417 | 527 | </p> |
418 | 528 | </div> |
419 | 529 | --> |
@@ -455,7 +565,10 @@ discard block |
||
455 | 565 | if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
456 | 566 | ?> |
457 | 567 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
458 | - <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
|
568 | + <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) { |
|
569 | + print $source['port']; |
|
570 | +} |
|
571 | +?>" /></td> |
|
459 | 572 | <?php |
460 | 573 | } else { |
461 | 574 | $hostport = explode(':',$source['host']); |
@@ -474,33 +587,102 @@ discard block |
||
474 | 587 | ?> |
475 | 588 | <td> |
476 | 589 | <select name="format[]" id="format"> |
477 | - <option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option> |
|
478 | - <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option> |
|
479 | - <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option> |
|
480 | - <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option> |
|
481 | - <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option> |
|
482 | - <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option> |
|
483 | - <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option> |
|
484 | - <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option> |
|
485 | - <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option> |
|
486 | - <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option> |
|
487 | - <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option> |
|
488 | - <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option> |
|
489 | - <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option> |
|
490 | - <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option> |
|
491 | - <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
492 | - <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option> |
|
493 | - <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option> |
|
494 | - <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option> |
|
495 | - <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option> |
|
496 | - <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option> |
|
590 | + <option value="auto" <?php if (!isset($source['format'])) { |
|
591 | + print 'selected'; |
|
592 | +} |
|
593 | +?>>Auto</option> |
|
594 | + <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') { |
|
595 | + print 'selected'; |
|
596 | +} |
|
597 | +?>>SBS</option> |
|
598 | + <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') { |
|
599 | + print 'selected'; |
|
600 | +} |
|
601 | +?>>TSV</option> |
|
602 | + <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') { |
|
603 | + print 'selected'; |
|
604 | +} |
|
605 | +?>>Raw</option> |
|
606 | + <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') { |
|
607 | + print 'selected'; |
|
608 | +} |
|
609 | +?>>APRS</option> |
|
610 | + <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') { |
|
611 | + print 'selected'; |
|
612 | +} |
|
613 | +?>>Radarcape deltadb.txt</option> |
|
614 | + <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') { |
|
615 | + print 'selected'; |
|
616 | +} |
|
617 | +?>>Vatsim</option> |
|
618 | + <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') { |
|
619 | + print 'selected'; |
|
620 | +} |
|
621 | +?>>Virtual Radar Server AircraftList.json</option> |
|
622 | + <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') { |
|
623 | + print 'selected'; |
|
624 | +} |
|
625 | +?>>Virtual Radar Server TCP</option> |
|
626 | + <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
627 | + print 'selected'; |
|
628 | +} |
|
629 | +?>>phpVMS</option> |
|
630 | + <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') { |
|
631 | + print 'selected'; |
|
632 | +} |
|
633 | +?>>Virtual Airlines Manager</option> |
|
634 | + <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') { |
|
635 | + print 'selected'; |
|
636 | +} |
|
637 | +?>>IVAO</option> |
|
638 | + <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') { |
|
639 | + print 'selected'; |
|
640 | +} |
|
641 | +?>>FlightGear Multiplayer</option> |
|
642 | + <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') { |
|
643 | + print 'selected'; |
|
644 | +} |
|
645 | +?>>FlightGear Singleplayer</option> |
|
646 | + <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') { |
|
647 | + print 'selected'; |
|
648 | +} |
|
649 | +?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
650 | + <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') { |
|
651 | + print 'selected'; |
|
652 | +} |
|
653 | +?>>ACARS SBS-3 over TCP</option> |
|
654 | + <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') { |
|
655 | + print 'selected'; |
|
656 | +} |
|
657 | +?>>NMEA AIS over TCP</option> |
|
658 | + <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') { |
|
659 | + print 'selected'; |
|
660 | +} |
|
661 | +?>>AirWhere website</option> |
|
662 | + <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') { |
|
663 | + print 'selected'; |
|
664 | +} |
|
665 | +?>>HidnSeek Callback</option> |
|
666 | + <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') { |
|
667 | + print 'selected'; |
|
668 | +} |
|
669 | +?>>Blitzortung</option> |
|
497 | 670 | </select> |
498 | 671 | </td> |
499 | 672 | <td> |
500 | - <input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /> |
|
673 | + <input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) { |
|
674 | + print $source['name']; |
|
675 | +} |
|
676 | +?>" /> |
|
501 | 677 | </td> |
502 | - <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td> |
|
503 | - <td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td> |
|
678 | + <td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) { |
|
679 | + print 'checked'; |
|
680 | +} |
|
681 | +?> /></td> |
|
682 | + <td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) { |
|
683 | + print 'checked'; |
|
684 | +} |
|
685 | +?> /></td> |
|
504 | 686 | <td> |
505 | 687 | <select name="timezones[]" id="timezones"> |
506 | 688 | <?php |
@@ -510,7 +692,9 @@ discard block |
||
510 | 692 | print '<option selected>'.$timezones.'</option>'; |
511 | 693 | } elseif (!isset($source['timezone']) && $timezones == 'UTC') { |
512 | 694 | print '<option selected>'.$timezones.'</option>'; |
513 | - } else print '<option>'.$timezones.'</option>'; |
|
695 | + } else { |
|
696 | + print '<option>'.$timezones.'</option>'; |
|
697 | + } |
|
514 | 698 | } |
515 | 699 | ?> |
516 | 700 | </select> |
@@ -560,7 +744,9 @@ discard block |
||
560 | 744 | foreach($timezonelist as $timezones){ |
561 | 745 | if ($timezones == 'UTC') { |
562 | 746 | print '<option selected>'.$timezones.'</option>'; |
563 | - } else print '<option>'.$timezones.'</option>'; |
|
747 | + } else { |
|
748 | + print '<option>'.$timezones.'</option>'; |
|
749 | + } |
|
564 | 750 | } |
565 | 751 | ?> |
566 | 752 | </select> |
@@ -583,11 +769,17 @@ discard block |
||
583 | 769 | <p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p> |
584 | 770 | <p> |
585 | 771 | <label for="acarshost">ACARS UDP host</label> |
586 | - <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" /> |
|
772 | + <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) { |
|
773 | + print $globalACARSHost; |
|
774 | +} |
|
775 | +?>" /> |
|
587 | 776 | </p> |
588 | 777 | <p> |
589 | 778 | <label for="acarsport">ACARS UDP port</label> |
590 | - <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" /> |
|
779 | + <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) { |
|
780 | + print $globalACARSPort; |
|
781 | +} |
|
782 | +?>" /> |
|
591 | 783 | </p> |
592 | 784 | </fieldset> |
593 | 785 | </div> |
@@ -667,13 +859,19 @@ discard block |
||
667 | 859 | <div id="schedules_options"> |
668 | 860 | <p> |
669 | 861 | <label for="britishairways">British Airways API Key</label> |
670 | - <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" /> |
|
862 | + <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) { |
|
863 | + print $globalBritishAirwaysKey; |
|
864 | +} |
|
865 | +?>" /> |
|
671 | 866 | <p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p> |
672 | 867 | </p> |
673 | 868 | <!-- |
674 | 869 | <p> |
675 | 870 | <label for="transavia">Transavia Test API Consumer Key</label> |
676 | - <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" /> |
|
871 | + <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) { |
|
872 | + print $globalTransaviaKey; |
|
873 | +} |
|
874 | +?>" /> |
|
677 | 875 | <p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p> |
678 | 876 | </p> |
679 | 877 | --> |
@@ -682,10 +880,16 @@ discard block |
||
682 | 880 | <b>Lufthansa API Key</b> |
683 | 881 | <p> |
684 | 882 | <label for="lufthansakey">Key</label> |
685 | - <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" /> |
|
883 | + <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) { |
|
884 | + print $globalLufthansaKey['key']; |
|
885 | +} |
|
886 | +?>" /> |
|
686 | 887 | </p><p> |
687 | 888 | <label for="lufthansasecret">Secret</label> |
688 | - <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" /> |
|
889 | + <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) { |
|
890 | + print $globalLufthansaKey['secret']; |
|
891 | +} |
|
892 | +?>" /> |
|
689 | 893 | </p> |
690 | 894 | </div> |
691 | 895 | <p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p> |
@@ -705,7 +909,10 @@ discard block |
||
705 | 909 | </p> |
706 | 910 | <p> |
707 | 911 | <label for="notamsource">URL of your feed from notaminfo.com</label> |
708 | - <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" /> |
|
912 | + <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) { |
|
913 | + print $globalNOTAMSource; |
|
914 | +} |
|
915 | +?>" /> |
|
709 | 916 | <p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p> |
710 | 917 | </p> |
711 | 918 | <br /> |
@@ -721,14 +928,20 @@ discard block |
||
721 | 928 | <div id="metarsrc"> |
722 | 929 | <p> |
723 | 930 | <label for="metarsource">URL of your METAR source</label> |
724 | - <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" /> |
|
931 | + <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) { |
|
932 | + print $globalMETARurl; |
|
933 | +} |
|
934 | +?>" /> |
|
725 | 935 | <p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p> |
726 | 936 | </p> |
727 | 937 | </div> |
728 | 938 | <br /> |
729 | 939 | <p> |
730 | 940 | <label for="bitly">Bit.ly access token api (used in search page)</label> |
731 | - <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" /> |
|
941 | + <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) { |
|
942 | + print $globalBitlyAccessToken; |
|
943 | +} |
|
944 | +?>" /> |
|
732 | 945 | </p> |
733 | 946 | <br /> |
734 | 947 | <p> |
@@ -744,11 +957,26 @@ discard block |
||
744 | 957 | <p> |
745 | 958 | <label for="geoid_source">Geoid Source</label> |
746 | 959 | <select name="geoid_source" id="geoid_source"> |
747 | - <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option> |
|
748 | - <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option> |
|
749 | - <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option> |
|
750 | - <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option> |
|
751 | - <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option> |
|
960 | + <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') { |
|
961 | + print ' selected="selected"'; |
|
962 | +} |
|
963 | +?>>EGM96 15' (2.1MB)</option> |
|
964 | + <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') { |
|
965 | + print ' selected="selected"'; |
|
966 | +} |
|
967 | +?>>EGM96 5' (19MB)</option> |
|
968 | + <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') { |
|
969 | + print ' selected="selected"'; |
|
970 | +} |
|
971 | +?>>EGM2008 5' (19MB)</option> |
|
972 | + <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') { |
|
973 | + print ' selected="selected"'; |
|
974 | +} |
|
975 | +?>>EGM2008 2.5' (75MB)</option> |
|
976 | + <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') { |
|
977 | + print ' selected="selected"'; |
|
978 | +} |
|
979 | +?>>EGM2008 1' (470MB)</option> |
|
752 | 980 | </select> |
753 | 981 | <p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p> |
754 | 982 | </p> |
@@ -766,7 +994,12 @@ discard block |
||
766 | 994 | </p> |
767 | 995 | <p> |
768 | 996 | <label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label> |
769 | - <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" /> |
|
997 | + <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) { |
|
998 | + print $globalArchiveMonths; |
|
999 | +} else { |
|
1000 | + echo '0'; |
|
1001 | +} |
|
1002 | +?>" /> |
|
770 | 1003 | <p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p> |
771 | 1004 | </p> |
772 | 1005 | <p> |
@@ -776,12 +1009,22 @@ discard block |
||
776 | 1009 | </p> |
777 | 1010 | <p> |
778 | 1011 | <label for="archivekeepmonths">Keep flights data for xx months in archive</label> |
779 | - <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" /> |
|
1012 | + <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) { |
|
1013 | + print $globalArchiveKeepMonths; |
|
1014 | +} else { |
|
1015 | + echo '0'; |
|
1016 | +} |
|
1017 | +?>" /> |
|
780 | 1018 | <p class="help-block">0 to disable</p> |
781 | 1019 | </p> |
782 | 1020 | <p> |
783 | 1021 | <label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label> |
784 | - <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" /> |
|
1022 | + <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) { |
|
1023 | + print $globalArchiveKeepTrackMonths; |
|
1024 | +} else { |
|
1025 | + echo '0'; |
|
1026 | +} |
|
1027 | +?>" /> |
|
785 | 1028 | <p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p> |
786 | 1029 | </p> |
787 | 1030 | <br /> |
@@ -791,7 +1034,12 @@ discard block |
||
791 | 1034 | <p class="help-block">Uncheck if the script is running as cron job</p> |
792 | 1035 | <div id="cronends"> |
793 | 1036 | <label for="cronend">Run script for xx seconds</label> |
794 | - <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" /> |
|
1037 | + <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) { |
|
1038 | + print $globalCronEnd; |
|
1039 | +} else { |
|
1040 | + print '0'; |
|
1041 | +} |
|
1042 | +?>" /> |
|
795 | 1043 | <p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p> |
796 | 1044 | </div> |
797 | 1045 | </p> |
@@ -844,15 +1092,30 @@ discard block |
||
844 | 1092 | <br /> |
845 | 1093 | <p> |
846 | 1094 | <label for="refresh">Show flights detected since xxx seconds</label> |
847 | - <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" /> |
|
1095 | + <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) { |
|
1096 | + echo $globalLiveInterval; |
|
1097 | +} else { |
|
1098 | + echo '200'; |
|
1099 | +} |
|
1100 | +?>" /> |
|
848 | 1101 | </p> |
849 | 1102 | <p> |
850 | 1103 | <label for="maprefresh">Live map refresh (in seconds)</label> |
851 | - <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" /> |
|
1104 | + <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) { |
|
1105 | + echo $globalMapRefresh; |
|
1106 | +} else { |
|
1107 | + echo '30'; |
|
1108 | +} |
|
1109 | +?>" /> |
|
852 | 1110 | </p> |
853 | 1111 | <p> |
854 | 1112 | <label for="mapidle">Map idle timeout (in minutes)</label> |
855 | - <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" /> |
|
1113 | + <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) { |
|
1114 | + echo $globalMapIdleTimeout; |
|
1115 | +} else { |
|
1116 | + echo '30'; |
|
1117 | +} |
|
1118 | +?>" /> |
|
856 | 1119 | <p class="help-block">0 to disable</p> |
857 | 1120 | </p> |
858 | 1121 | <p> |
@@ -867,12 +1130,20 @@ discard block |
||
867 | 1130 | <br /> |
868 | 1131 | <p> |
869 | 1132 | <label for="closestmindist">Distance to airport set as arrival (in km)</label> |
870 | - <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" /> |
|
1133 | + <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) { |
|
1134 | + echo $globalClosestMinDist; |
|
1135 | +} else { |
|
1136 | + echo '50'; |
|
1137 | +} |
|
1138 | +?>" /> |
|
871 | 1139 | </p> |
872 | 1140 | <br /> |
873 | 1141 | <p> |
874 | 1142 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
875 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
1143 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) { |
|
1144 | + echo $globalAircraftSize; |
|
1145 | +} |
|
1146 | +?>" /> |
|
876 | 1147 | </p> |
877 | 1148 | <br /> |
878 | 1149 | <p> |
@@ -885,7 +1156,12 @@ discard block |
||
885 | 1156 | if (extension_loaded('gd') && function_exists('gd_info')) { |
886 | 1157 | ?> |
887 | 1158 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
888 | - <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
|
1159 | + <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) { |
|
1160 | + echo $globalAircraftIconColor; |
|
1161 | +} else { |
|
1162 | + echo '1a3151'; |
|
1163 | +} |
|
1164 | +?>" /> |
|
889 | 1165 | <?php |
890 | 1166 | if (!is_writable('../cache')) { |
891 | 1167 | ?> |
@@ -903,14 +1179,27 @@ discard block |
||
903 | 1179 | <p> |
904 | 1180 | <label for="airportzoom">Zoom level minimum to see airports icons</label> |
905 | 1181 | <div class="range"> |
906 | - <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" /> |
|
907 | - <output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output> |
|
1182 | + <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) { |
|
1183 | + echo $globalAirportZoom; |
|
1184 | +} else { |
|
1185 | + echo '7'; |
|
1186 | +} |
|
1187 | +?>" /> |
|
1188 | + <output id="range"><?php if (isset($globalAirportZoom)) { |
|
1189 | + echo $globalAirportZoom; |
|
1190 | +} else { |
|
1191 | + echo '7'; |
|
1192 | +} |
|
1193 | +?></output> |
|
908 | 1194 | </div> |
909 | 1195 | </p> |
910 | 1196 | <br /> |
911 | 1197 | <p> |
912 | 1198 | <label for="customcss">Custom CSS web path</label> |
913 | - <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" /> |
|
1199 | + <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) { |
|
1200 | + echo $globalCustomCSS; |
|
1201 | +} |
|
1202 | +?>" /> |
|
914 | 1203 | </p> |
915 | 1204 | </fieldset> |
916 | 1205 | <input type="submit" name="submit" value="Create/Update database & write setup" /> |
@@ -937,8 +1226,12 @@ discard block |
||
937 | 1226 | $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
938 | 1227 | $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
939 | 1228 | |
940 | - if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
|
941 | - if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
1229 | + if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) { |
|
1230 | + $error .= 'Mysql driver for PDO must be loaded'; |
|
1231 | + } |
|
1232 | + if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) { |
|
1233 | + $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
1234 | + } |
|
942 | 1235 | |
943 | 1236 | $_SESSION['database_root'] = $dbroot; |
944 | 1237 | $_SESSION['database_rootpass'] = $dbrootpass; |
@@ -1006,15 +1299,23 @@ discard block |
||
1006 | 1299 | $source_city = $_POST['source_city']; |
1007 | 1300 | $source_country = $_POST['source_country']; |
1008 | 1301 | $source_ref = $_POST['source_ref']; |
1009 | - if (isset($source_id)) $source_id = $_POST['source_id']; |
|
1010 | - else $source_id = array(); |
|
1302 | + if (isset($source_id)) { |
|
1303 | + $source_id = $_POST['source_id']; |
|
1304 | + } else { |
|
1305 | + $source_id = array(); |
|
1306 | + } |
|
1011 | 1307 | |
1012 | 1308 | $sources = array(); |
1013 | 1309 | foreach ($source_name as $keys => $name) { |
1014 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1015 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1310 | + if (isset($source_id[$keys])) { |
|
1311 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1312 | + } else { |
|
1313 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1314 | + } |
|
1315 | + } |
|
1316 | + if (count($sources) > 0) { |
|
1317 | + $_SESSION['sources'] = $sources; |
|
1016 | 1318 | } |
1017 | - if (count($sources) > 0) $_SESSION['sources'] = $sources; |
|
1018 | 1319 | |
1019 | 1320 | //$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING); |
1020 | 1321 | //$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT); |
@@ -1035,14 +1336,23 @@ discard block |
||
1035 | 1336 | $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
1036 | 1337 | |
1037 | 1338 | $globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING); |
1038 | - if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1039 | - else $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1339 | + if ($globalaircraft == 'aircraft') { |
|
1340 | + $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
1341 | + } else { |
|
1342 | + $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
1343 | + } |
|
1040 | 1344 | $globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING); |
1041 | - if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1042 | - else $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1345 | + if ($globaltracker == 'tracker') { |
|
1346 | + $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
1347 | + } else { |
|
1348 | + $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
1349 | + } |
|
1043 | 1350 | $globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING); |
1044 | - if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1045 | - else $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1351 | + if ($globalmarine == 'marine') { |
|
1352 | + $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
1353 | + } else { |
|
1354 | + $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
1355 | + } |
|
1046 | 1356 | |
1047 | 1357 | /* |
1048 | 1358 | $globalSBS1Hosts = array(); |
@@ -1064,23 +1374,37 @@ discard block |
||
1064 | 1374 | $name = $_POST['name']; |
1065 | 1375 | $format = $_POST['format']; |
1066 | 1376 | $timezones = $_POST['timezones']; |
1067 | - if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats']; |
|
1068 | - else $sourcestats = array(); |
|
1069 | - if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive']; |
|
1070 | - else $noarchive = array(); |
|
1377 | + if (isset($_POST['sourcestats'])) { |
|
1378 | + $sourcestats = $_POST['sourcestats']; |
|
1379 | + } else { |
|
1380 | + $sourcestats = array(); |
|
1381 | + } |
|
1382 | + if (isset($_POST['noarchive'])) { |
|
1383 | + $noarchive = $_POST['noarchive']; |
|
1384 | + } else { |
|
1385 | + $noarchive = array(); |
|
1386 | + } |
|
1071 | 1387 | $gSources = array(); |
1072 | 1388 | $forcepilots = false; |
1073 | 1389 | foreach ($host as $key => $h) { |
1074 | - if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE'; |
|
1075 | - else $cov = 'FALSE'; |
|
1076 | - if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE'; |
|
1077 | - else $arch = 'FALSE'; |
|
1390 | + if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) { |
|
1391 | + $cov = 'TRUE'; |
|
1392 | + } else { |
|
1393 | + $cov = 'FALSE'; |
|
1394 | + } |
|
1395 | + if (isset($noarchive[$key]) && $noarchive[$key] == 1) { |
|
1396 | + $arch = 'TRUE'; |
|
1397 | + } else { |
|
1398 | + $arch = 'FALSE'; |
|
1399 | + } |
|
1078 | 1400 | if (strpos($format[$key],'_callback')) { |
1079 | 1401 | $gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE'); |
1080 | 1402 | } elseif ($h != '' || $name[$key] != '') { |
1081 | 1403 | $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE'); |
1082 | 1404 | } |
1083 | - if ($format[$key] == 'airwhere') $forcepilots = true; |
|
1405 | + if ($format[$key] == 'airwhere') { |
|
1406 | + $forcepilots = true; |
|
1407 | + } |
|
1084 | 1408 | } |
1085 | 1409 | $settings = array_merge($settings,array('globalSources' => $gSources)); |
1086 | 1410 | |
@@ -1108,7 +1432,9 @@ discard block |
||
1108 | 1432 | $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
1109 | 1433 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
1110 | 1434 | $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
1111 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1435 | + } else { |
|
1436 | + $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
1437 | + } |
|
1112 | 1438 | |
1113 | 1439 | $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
1114 | 1440 | $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
@@ -1147,7 +1473,9 @@ discard block |
||
1147 | 1473 | |
1148 | 1474 | // Create in settings.php keys not yet configurable if not already here |
1149 | 1475 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
1150 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1476 | + if (!isset($globalDebug)) { |
|
1477 | + $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
1478 | + } |
|
1151 | 1479 | |
1152 | 1480 | $resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING); |
1153 | 1481 | if ($resetyearstats == 'resetyearstats') { |
@@ -1184,37 +1512,56 @@ discard block |
||
1184 | 1512 | } |
1185 | 1513 | */ |
1186 | 1514 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
1187 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1188 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1189 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1190 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1515 | + if ($globalsbs == 'sbs') { |
|
1516 | + $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
1517 | + } else { |
|
1518 | + $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
1519 | + } |
|
1520 | + if ($globalaprs == 'aprs') { |
|
1521 | + $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
1522 | + } else { |
|
1523 | + $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
1524 | + } |
|
1191 | 1525 | $va = false; |
1192 | 1526 | if ($globalivao == 'ivao') { |
1193 | 1527 | $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
1194 | 1528 | $va = true; |
1195 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
1529 | + } else { |
|
1530 | + $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
1531 | + } |
|
1196 | 1532 | if ($globalvatsim == 'vatsim') { |
1197 | 1533 | $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
1198 | 1534 | $va = true; |
1199 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
1535 | + } else { |
|
1536 | + $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
1537 | + } |
|
1200 | 1538 | if ($globalphpvms == 'phpvms') { |
1201 | 1539 | $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
1202 | 1540 | $va = true; |
1203 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
1541 | + } else { |
|
1542 | + $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
1543 | + } |
|
1204 | 1544 | if ($globalvam == 'vam') { |
1205 | 1545 | $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
1206 | 1546 | $va = true; |
1207 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
1547 | + } else { |
|
1548 | + $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
1549 | + } |
|
1208 | 1550 | if ($va) { |
1209 | 1551 | $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
1210 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
1552 | + } else { |
|
1553 | + $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
1554 | + } |
|
1211 | 1555 | if ($globalva == 'va' || $va) { |
1212 | 1556 | $settings = array_merge($settings,array('globalVA' => 'TRUE')); |
1213 | 1557 | $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
1214 | 1558 | } else { |
1215 | 1559 | $settings = array_merge($settings,array('globalVA' => 'FALSE')); |
1216 | - if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1217 | - else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
1560 | + if ($forcepilots) { |
|
1561 | + $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
1562 | + } else { |
|
1563 | + $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
1564 | + } |
|
1218 | 1565 | } |
1219 | 1566 | |
1220 | 1567 | |
@@ -1390,7 +1737,9 @@ discard block |
||
1390 | 1737 | $settings = array_merge($settings,array('globalNoAirlines' => 'FALSE')); |
1391 | 1738 | } |
1392 | 1739 | |
1393 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
1740 | + if (!isset($globalTransaction)) { |
|
1741 | + $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
1742 | + } |
|
1394 | 1743 | |
1395 | 1744 | // Set some defaults values... |
1396 | 1745 | if (!isset($globalAircraftImageSources)) { |
@@ -1405,15 +1754,23 @@ discard block |
||
1405 | 1754 | |
1406 | 1755 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1407 | 1756 | |
1408 | - if ($error == '') settings::modify_settings($settings); |
|
1409 | - if ($error == '') settings::comment_settings($settings_comment); |
|
1757 | + if ($error == '') { |
|
1758 | + settings::modify_settings($settings); |
|
1759 | + } |
|
1760 | + if ($error == '') { |
|
1761 | + settings::comment_settings($settings_comment); |
|
1762 | + } |
|
1410 | 1763 | if ($error != '') { |
1411 | 1764 | print '<div class="info column">'.$error.'</div>'; |
1412 | 1765 | require('../footer.php'); |
1413 | 1766 | exit; |
1414 | 1767 | } else { |
1415 | - if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1; |
|
1416 | - if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1; |
|
1768 | + if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') { |
|
1769 | + $_SESSION['waypoints'] = 1; |
|
1770 | + } |
|
1771 | + if (isset($_POST['owner']) && $_POST['owner'] == 'owner') { |
|
1772 | + $_SESSION['owner'] = 1; |
|
1773 | + } |
|
1417 | 1774 | if (isset($_POST['createdb'])) { |
1418 | 1775 | $_SESSION['install'] = 'database_create'; |
1419 | 1776 | } else { |
@@ -1449,10 +1806,18 @@ discard block |
||
1449 | 1806 | $popw = false; |
1450 | 1807 | foreach ($_SESSION['done'] as $done) { |
1451 | 1808 | print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
1452 | - if ($done == 'Create database') $pop = true; |
|
1453 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1454 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1455 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1809 | + if ($done == 'Create database') { |
|
1810 | + $pop = true; |
|
1811 | + } |
|
1812 | + if ($_SESSION['install'] == 'database_create') { |
|
1813 | + $pop = true; |
|
1814 | + } |
|
1815 | + if ($_SESSION['install'] == 'database_import') { |
|
1816 | + $popi = true; |
|
1817 | + } |
|
1818 | + if ($_SESSION['install'] == 'waypoints') { |
|
1819 | + $popw = true; |
|
1820 | + } |
|
1456 | 1821 | } |
1457 | 1822 | if ($pop) { |
1458 | 1823 | sleep(5); |
@@ -1463,7 +1828,9 @@ discard block |
||
1463 | 1828 | } else if ($popw) { |
1464 | 1829 | sleep(5); |
1465 | 1830 | print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
1466 | - } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
1831 | + } else { |
|
1832 | + print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
1833 | + } |
|
1467 | 1834 | print '</div></ul>'; |
1468 | 1835 | print '<div id="error"></div>'; |
1469 | 1836 | /* foreach ($_SESSION['done'] as $done) { |
@@ -17,9 +17,13 @@ discard block |
||
17 | 17 | date_default_timezone_set('UTC'); |
18 | 18 | |
19 | 19 | print '<div class="top">'; |
20 | -if ($spotter_item['name'] != '') print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>'; |
|
21 | -elseif ($spotter_item['location_id'] != 0) print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>'; |
|
22 | -else print '<div class="right"><div class="callsign-details"><div class="callsign"></div>'; |
|
20 | +if ($spotter_item['name'] != '') { |
|
21 | + print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>'; |
|
22 | +} elseif ($spotter_item['location_id'] != 0) { |
|
23 | + print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>'; |
|
24 | +} else { |
|
25 | + print '<div class="right"><div class="callsign-details"><div class="callsign"></div>'; |
|
26 | +} |
|
23 | 27 | print '</div>'; |
24 | 28 | |
25 | 29 | print '</div></div>'; |
@@ -34,8 +38,12 @@ discard block |
||
34 | 38 | print $spotter_item['last_seen'].' UTC'; |
35 | 39 | print '</div>'; |
36 | 40 | |
37 | -if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>'; |
|
38 | -if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
|
41 | +if ($spotter_item['city'] != '') { |
|
42 | + print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>'; |
|
43 | +} |
|
44 | +if ($spotter_item['country'] !='') { |
|
45 | + print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
|
46 | +} |
|
39 | 47 | print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>'; |
40 | 48 | /* |
41 | 49 | if ($spotter_item['atc_range'] > 0) { |
@@ -47,13 +55,27 @@ discard block |
||
47 | 55 | if ($spotter_item['type'] == 'wx') { |
48 | 56 | $weather = json_decode($spotter_item['description'],true); |
49 | 57 | //print_r($weather); |
50 | - if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>'; |
|
51 | - if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>'; |
|
52 | - if (isset($weather['wind_gust'])) print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>'; |
|
53 | - if (isset($weather['humidity'])) print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>'; |
|
54 | - if (isset($weather['rain'])) print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>'; |
|
55 | - if (isset($weather['precipitation'])) print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>'; |
|
56 | - if (isset($weather['precipitation24h'])) print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>'; |
|
58 | + if (isset($weather['temp'])) { |
|
59 | + print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>'; |
|
60 | + } |
|
61 | + if (isset($weather['pressure'])) { |
|
62 | + print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>'; |
|
63 | + } |
|
64 | + if (isset($weather['wind_gust'])) { |
|
65 | + print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>'; |
|
66 | + } |
|
67 | + if (isset($weather['humidity'])) { |
|
68 | + print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>'; |
|
69 | + } |
|
70 | + if (isset($weather['rain'])) { |
|
71 | + print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>'; |
|
72 | + } |
|
73 | + if (isset($weather['precipitation'])) { |
|
74 | + print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>'; |
|
75 | + } |
|
76 | + if (isset($weather['precipitation24h'])) { |
|
77 | + print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>'; |
|
78 | + } |
|
57 | 79 | $spotter_item['description'] = $weather['comment']; |
58 | 80 | } |
59 | 81 | print '</div>'; |