@@ -8,7 +8,7 @@ |
||
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | require_once('header.php'); |
@@ -7,109 +7,109 @@ discard block |
||
7 | 7 | public $db; |
8 | 8 | |
9 | 9 | protected $texts = Array( |
10 | - 'MI' => 'Shallow', |
|
11 | - 'PR' => 'Partial', |
|
12 | - 'BC' => 'Low drifting', |
|
13 | - 'BL' => 'Blowing', |
|
14 | - 'SH' => 'Showers', |
|
15 | - 'TS' => 'Thunderstorm', |
|
16 | - 'FZ' => 'Freezing', |
|
17 | - 'DZ' => 'Drizzle', |
|
18 | - 'RA' => 'Rain', |
|
19 | - 'SN' => 'Snow', |
|
20 | - 'SG' => 'Snow Grains', |
|
21 | - 'IC' => 'Ice crystals', |
|
22 | - 'PL' => 'Ice pellets', |
|
23 | - 'GR' => 'Hail', |
|
24 | - 'GS' => 'Small hail', |
|
25 | - 'UP' => 'Unknown', |
|
26 | - 'BR' => 'Mist', |
|
27 | - 'FG' => 'Fog', |
|
28 | - 'FU' => 'Smoke', |
|
29 | - 'VA' => 'Volcanic ash', |
|
30 | - 'DU' => 'Widespread dust', |
|
31 | - 'SA' => 'Sand', |
|
32 | - 'HZ' => 'Haze', |
|
33 | - 'PY' => 'Spray', |
|
34 | - 'PO' => 'Well developed dust / sand whirls', |
|
35 | - 'SQ' => 'Squalls', |
|
36 | - 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | - 'SS' => 'Sandstorm', |
|
38 | - 'DS' => 'Duststorm' |
|
10 | + 'MI' => 'Shallow', |
|
11 | + 'PR' => 'Partial', |
|
12 | + 'BC' => 'Low drifting', |
|
13 | + 'BL' => 'Blowing', |
|
14 | + 'SH' => 'Showers', |
|
15 | + 'TS' => 'Thunderstorm', |
|
16 | + 'FZ' => 'Freezing', |
|
17 | + 'DZ' => 'Drizzle', |
|
18 | + 'RA' => 'Rain', |
|
19 | + 'SN' => 'Snow', |
|
20 | + 'SG' => 'Snow Grains', |
|
21 | + 'IC' => 'Ice crystals', |
|
22 | + 'PL' => 'Ice pellets', |
|
23 | + 'GR' => 'Hail', |
|
24 | + 'GS' => 'Small hail', |
|
25 | + 'UP' => 'Unknown', |
|
26 | + 'BR' => 'Mist', |
|
27 | + 'FG' => 'Fog', |
|
28 | + 'FU' => 'Smoke', |
|
29 | + 'VA' => 'Volcanic ash', |
|
30 | + 'DU' => 'Widespread dust', |
|
31 | + 'SA' => 'Sand', |
|
32 | + 'HZ' => 'Haze', |
|
33 | + 'PY' => 'Spray', |
|
34 | + 'PO' => 'Well developed dust / sand whirls', |
|
35 | + 'SQ' => 'Squalls', |
|
36 | + 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | + 'SS' => 'Sandstorm', |
|
38 | + 'DS' => 'Duststorm' |
|
39 | 39 | ); |
40 | 40 | |
41 | 41 | public function __construct($dbc = null) { |
42 | - $Connection = new Connection($dbc); |
|
43 | - $this->db = $Connection->db; |
|
44 | - } |
|
42 | + $Connection = new Connection($dbc); |
|
43 | + $this->db = $Connection->db; |
|
44 | + } |
|
45 | 45 | |
46 | - public static function check_last_update() { |
|
47 | - global $globalDBdriver; |
|
48 | - if ($globalDBdriver == 'mysql') { |
|
46 | + public static function check_last_update() { |
|
47 | + global $globalDBdriver; |
|
48 | + if ($globalDBdriver == 'mysql') { |
|
49 | 49 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)"; |
50 | 50 | } else { |
51 | 51 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'"; |
52 | 52 | } |
53 | - try { |
|
54 | - $Connection = new Connection(); |
|
55 | - $sth = $Connection->db->prepare($query); |
|
56 | - $sth->execute(); |
|
57 | - } catch(PDOException $e) { |
|
58 | - return "error : ".$e->getMessage(); |
|
59 | - } |
|
60 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
61 | - $sth->closeCursor(); |
|
62 | - if ($row['nb'] > 0) return false; |
|
63 | - else return true; |
|
64 | - } |
|
53 | + try { |
|
54 | + $Connection = new Connection(); |
|
55 | + $sth = $Connection->db->prepare($query); |
|
56 | + $sth->execute(); |
|
57 | + } catch(PDOException $e) { |
|
58 | + return "error : ".$e->getMessage(); |
|
59 | + } |
|
60 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
61 | + $sth->closeCursor(); |
|
62 | + if ($row['nb'] > 0) return false; |
|
63 | + else return true; |
|
64 | + } |
|
65 | 65 | |
66 | - public static function insert_last_update() { |
|
67 | - $query = "DELETE FROM config WHERE name = 'last_update_metar'; |
|
66 | + public static function insert_last_update() { |
|
67 | + $query = "DELETE FROM config WHERE name = 'last_update_metar'; |
|
68 | 68 | INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());"; |
69 | - try { |
|
70 | - $Connection = new Connection(); |
|
71 | - $sth = $Connection->db->prepare($query); |
|
72 | - $sth->execute(); |
|
73 | - } catch(PDOException $e) { |
|
74 | - return "error : ".$e->getMessage(); |
|
75 | - } |
|
76 | - } |
|
69 | + try { |
|
70 | + $Connection = new Connection(); |
|
71 | + $sth = $Connection->db->prepare($query); |
|
72 | + $sth->execute(); |
|
73 | + } catch(PDOException $e) { |
|
74 | + return "error : ".$e->getMessage(); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | 79 | |
80 | - public function parse($data) { |
|
81 | - //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
|
82 | - $codes = implode('|', array_keys($this->texts)); |
|
83 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
84 | - //$pieces = explode(' ',$data); |
|
85 | - $pieces = preg_split('/\s/',$data); |
|
86 | - $pos = 0; |
|
87 | - if ($pieces[0] == 'METAR') $pos++; |
|
88 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | - $result = array(); |
|
91 | - $result['location'] = $pieces[$pos]; |
|
92 | - $pos++; |
|
93 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | - $result['time'] = substr($pieces[$pos],2,4); |
|
95 | - $c = count($pieces); |
|
96 | - for($pos++; $pos < $c; $pos++) { |
|
97 | - $piece = $pieces[$pos]; |
|
98 | - if ($piece == 'RMK') break; |
|
99 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | - if ($piece == 'COR') $result['correction'] = true; |
|
101 | - // Wind Speed |
|
102 | - if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
|
103 | - $result['wind']['direction'] = (float)$matches[1]; |
|
80 | + public function parse($data) { |
|
81 | + //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
|
82 | + $codes = implode('|', array_keys($this->texts)); |
|
83 | + $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
84 | + //$pieces = explode(' ',$data); |
|
85 | + $pieces = preg_split('/\s/',$data); |
|
86 | + $pos = 0; |
|
87 | + if ($pieces[0] == 'METAR') $pos++; |
|
88 | + elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | + $result = array(); |
|
91 | + $result['location'] = $pieces[$pos]; |
|
92 | + $pos++; |
|
93 | + $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | + $result['time'] = substr($pieces[$pos],2,4); |
|
95 | + $c = count($pieces); |
|
96 | + for($pos++; $pos < $c; $pos++) { |
|
97 | + $piece = $pieces[$pos]; |
|
98 | + if ($piece == 'RMK') break; |
|
99 | + if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | + if ($piece == 'COR') $result['correction'] = true; |
|
101 | + // Wind Speed |
|
102 | + if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
|
103 | + $result['wind']['direction'] = (float)$matches[1]; |
|
104 | 104 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
105 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
108 | 108 | $result['wind']['gust'] = (float)$matches[3]; |
109 | 109 | $result['wind']['unit'] = $matches[4]; |
110 | 110 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
111 | 111 | $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | 114 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
115 | 115 | $result['wind_direction'] = (float)$matches[1]; |
@@ -126,35 +126,35 @@ discard block |
||
126 | 126 | } |
127 | 127 | } |
128 | 128 | */ |
129 | - // Temperature |
|
130 | - if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
|
131 | - $temp = (float)$matches[1]; |
|
129 | + // Temperature |
|
130 | + if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
|
131 | + $temp = (float)$matches[1]; |
|
132 | 132 | if ($matches[1]{0} == 'M') { |
133 | 133 | $temp = ((float)substr($matches[1], 1)) * -1; |
134 | 134 | } |
135 | - $result['temperature'] = $temp; |
|
136 | - $dew = (float)$matches[2]; |
|
135 | + $result['temperature'] = $temp; |
|
136 | + $dew = (float)$matches[2]; |
|
137 | 137 | if ($matches[2]{0} == 'M') { |
138 | 138 | $dew = ((float)substr($matches[2], 1)) * -1; |
139 | 139 | } |
140 | 140 | $result['dew'] = $dew; |
141 | - } |
|
142 | - // QNH |
|
143 | - if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) { |
|
144 | - // #^(Q|A)(////|[0-9]{4})( )# |
|
145 | - if ($matches[1] == 'Q') { |
|
146 | - // hPa |
|
147 | - $result['QNH'] = $matches[2]; |
|
148 | - } else { |
|
149 | - // inHg |
|
150 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
151 | 141 | } |
152 | - /* |
|
142 | + // QNH |
|
143 | + if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) { |
|
144 | + // #^(Q|A)(////|[0-9]{4})( )# |
|
145 | + if ($matches[1] == 'Q') { |
|
146 | + // hPa |
|
147 | + $result['QNH'] = $matches[2]; |
|
148 | + } else { |
|
149 | + // inHg |
|
150 | + $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
151 | + } |
|
152 | + /* |
|
153 | 153 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
154 | 154 | $result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg'; |
155 | 155 | */ |
156 | - } |
|
157 | - /* |
|
156 | + } |
|
157 | + /* |
|
158 | 158 | // Wind Direction |
159 | 159 | if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) { |
160 | 160 | $result['wind_direction'] = $matches[1]; |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | $result['speed_variable'] = $matches[1]; |
166 | 166 | } |
167 | 167 | */ |
168 | - // Visibility |
|
169 | - if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
|
170 | - if (isset($matches[3]) && strlen($matches[3]) > 0) { |
|
168 | + // Visibility |
|
169 | + if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
|
170 | + if (isset($matches[3]) && strlen($matches[3]) > 0) { |
|
171 | 171 | $result['visibility'] = (float)$matches[3] * 1609.34; |
172 | 172 | } else { |
173 | 173 | if ($matches[1] == '9999') { |
@@ -180,28 +180,28 @@ discard block |
||
180 | 180 | $result['visibility'] = '> 10000'; |
181 | 181 | $result['weather'] = "CAVOK"; |
182 | 182 | } |
183 | - } |
|
184 | - // Cloud Coverage |
|
185 | - if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) { |
|
186 | - //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
|
187 | - $type = $matches[1]; |
|
188 | - $cloud = array(); |
|
189 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
197 | - $cloud['type_code'] = $type; |
|
198 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
199 | - $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
|
200 | - $result['cloud'][] = $cloud; |
|
201 | - } |
|
202 | - // RVR |
|
203 | - if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) { |
|
204 | - $rvr = array(); |
|
183 | + } |
|
184 | + // Cloud Coverage |
|
185 | + if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) { |
|
186 | + //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
|
187 | + $type = $matches[1]; |
|
188 | + $cloud = array(); |
|
189 | + if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | + elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | + elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | + elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | + elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | + elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | + elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | + elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
197 | + $cloud['type_code'] = $type; |
|
198 | + $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
199 | + $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
|
200 | + $result['cloud'][] = $cloud; |
|
201 | + } |
|
202 | + // RVR |
|
203 | + if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) { |
|
204 | + $rvr = array(); |
|
205 | 205 | $rvr['runway'] = $matches[1]; |
206 | 206 | $rvr['assessment'] = $matches[2]; |
207 | 207 | $rvr['rvr'] = $matches[3]; |
@@ -210,33 +210,33 @@ discard block |
||
210 | 210 | $result['RVR'] = $rvr; |
211 | 211 | } |
212 | 212 | |
213 | - //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
214 | - if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) { |
|
215 | - //print_r($matches); |
|
216 | - // https://github.com/davidmegginson/metar-taf/blob/master/Metar.php |
|
217 | - $result['RVR']['runway'] = $matches[1]; |
|
218 | - $result['RVR']['deposits'] = $matches[2]; |
|
219 | - $result['RVR']['extent'] = $matches[3]; |
|
220 | - $result['RVR']['depth'] = $matches[4]; |
|
221 | - $result['RVR']['friction'] = $matches[5]; |
|
222 | - } |
|
223 | - if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
224 | - //echo $piece; |
|
225 | - //print_r($matches); |
|
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
213 | + //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
214 | + if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) { |
|
215 | + //print_r($matches); |
|
216 | + // https://github.com/davidmegginson/metar-taf/blob/master/Metar.php |
|
217 | + $result['RVR']['runway'] = $matches[1]; |
|
218 | + $result['RVR']['deposits'] = $matches[2]; |
|
219 | + $result['RVR']['extent'] = $matches[3]; |
|
220 | + $result['RVR']['depth'] = $matches[4]; |
|
221 | + $result['RVR']['friction'] = $matches[5]; |
|
222 | + } |
|
223 | + if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
224 | + //echo $piece; |
|
225 | + //print_r($matches); |
|
226 | + if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | + else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
228 | 228 | if (isset($matches[3])) { |
229 | 229 | $range = Array( |
230 | - 'from' => (float)$matches[2], |
|
231 | - 'to' => (float)$matches[4], |
|
232 | - 'unit' => $matches[5] ? 'FT' : 'M' |
|
230 | + 'from' => (float)$matches[2], |
|
231 | + 'to' => (float)$matches[4], |
|
232 | + 'unit' => $matches[5] ? 'FT' : 'M' |
|
233 | 233 | ); |
234 | 234 | } |
235 | 235 | $result['RVR'] = $matches[1]; |
236 | 236 | $result['RVR_range'] = $range; |
237 | - } |
|
238 | - // Weather |
|
239 | - if (preg_match($regWeather, $piece, $matches)) { |
|
237 | + } |
|
238 | + // Weather |
|
239 | + if (preg_match($regWeather, $piece, $matches)) { |
|
240 | 240 | $text = Array(); |
241 | 241 | switch ($matches[1]) { |
242 | 242 | case '+': |
@@ -259,35 +259,35 @@ discard block |
||
259 | 259 | } |
260 | 260 | if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
261 | 261 | else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
262 | - } |
|
263 | - } |
|
264 | - return $result; |
|
262 | + } |
|
263 | + } |
|
264 | + return $result; |
|
265 | 265 | |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | 268 | public function getMETAR($icao) { |
269 | - global $globalMETARcycle, $globalDBdriver; |
|
270 | - if (isset($globalMETARcycle) && $globalMETARcycle) { |
|
271 | - $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
|
272 | - } else { |
|
273 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
275 | - } |
|
276 | - $query_values = array(':icao' => $icao); |
|
277 | - try { |
|
278 | - $sth = $this->db->prepare($query); |
|
279 | - $sth->execute($query_values); |
|
280 | - } catch(PDOException $e) { |
|
281 | - return "error : ".$e->getMessage(); |
|
282 | - } |
|
283 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | - if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) { |
|
285 | - $all = $this->downloadMETAR($icao); |
|
286 | - } |
|
287 | - return $all; |
|
288 | - } |
|
269 | + global $globalMETARcycle, $globalDBdriver; |
|
270 | + if (isset($globalMETARcycle) && $globalMETARcycle) { |
|
271 | + $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
|
272 | + } else { |
|
273 | + if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | + else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
275 | + } |
|
276 | + $query_values = array(':icao' => $icao); |
|
277 | + try { |
|
278 | + $sth = $this->db->prepare($query); |
|
279 | + $sth->execute($query_values); |
|
280 | + } catch(PDOException $e) { |
|
281 | + return "error : ".$e->getMessage(); |
|
282 | + } |
|
283 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | + if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) { |
|
285 | + $all = $this->downloadMETAR($icao); |
|
286 | + } |
|
287 | + return $all; |
|
288 | + } |
|
289 | 289 | |
290 | - public function addMETAR($location,$metar,$date) { |
|
290 | + public function addMETAR($location,$metar,$date) { |
|
291 | 291 | global $globalDBdriver; |
292 | 292 | $date = date('Y-m-d H:i:s',strtotime($date)); |
293 | 293 | if ($globalDBdriver == 'mysql') { |
@@ -295,106 +295,106 @@ discard block |
||
295 | 295 | } else { |
296 | 296 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
297 | 297 | } |
298 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
299 | - try { |
|
300 | - $sth = $this->db->prepare($query); |
|
301 | - $sth->execute($query_values); |
|
302 | - } catch(PDOException $e) { |
|
303 | - return "error : ".$e->getMessage(); |
|
304 | - } |
|
305 | - } |
|
298 | + $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
299 | + try { |
|
300 | + $sth = $this->db->prepare($query); |
|
301 | + $sth->execute($query_values); |
|
302 | + } catch(PDOException $e) { |
|
303 | + return "error : ".$e->getMessage(); |
|
304 | + } |
|
305 | + } |
|
306 | 306 | |
307 | - public function deleteMETAR($id) { |
|
308 | - $query = "DELETE FROM metar WHERE id = :id"; |
|
309 | - $query_values = array(':id' => $id); |
|
310 | - try { |
|
311 | - $sth = $this->db->prepare($query); |
|
312 | - $sth->execute($query_values); |
|
313 | - } catch(PDOException $e) { |
|
314 | - return "error : ".$e->getMessage(); |
|
315 | - } |
|
316 | - } |
|
317 | - public function deleteAllMETARLocation() { |
|
318 | - $query = "DELETE FROM metar"; |
|
319 | - try { |
|
320 | - $sth = $this->db->prepare($query); |
|
321 | - $sth->execute(); |
|
322 | - } catch(PDOException $e) { |
|
323 | - return "error : ".$e->getMessage(); |
|
324 | - } |
|
325 | - } |
|
307 | + public function deleteMETAR($id) { |
|
308 | + $query = "DELETE FROM metar WHERE id = :id"; |
|
309 | + $query_values = array(':id' => $id); |
|
310 | + try { |
|
311 | + $sth = $this->db->prepare($query); |
|
312 | + $sth->execute($query_values); |
|
313 | + } catch(PDOException $e) { |
|
314 | + return "error : ".$e->getMessage(); |
|
315 | + } |
|
316 | + } |
|
317 | + public function deleteAllMETARLocation() { |
|
318 | + $query = "DELETE FROM metar"; |
|
319 | + try { |
|
320 | + $sth = $this->db->prepare($query); |
|
321 | + $sth->execute(); |
|
322 | + } catch(PDOException $e) { |
|
323 | + return "error : ".$e->getMessage(); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | - public function addMETARCycle() { |
|
328 | - global $globalDebug, $globalIVAO, $globalTransaction; |
|
329 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
330 | - date_default_timezone_set("UTC"); |
|
331 | - $Common = new Common(); |
|
332 | - if (isset($globalIVAO) && $globalIVAO) { |
|
333 | - //$cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
|
327 | + public function addMETARCycle() { |
|
328 | + global $globalDebug, $globalIVAO, $globalTransaction; |
|
329 | + if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
330 | + date_default_timezone_set("UTC"); |
|
331 | + $Common = new Common(); |
|
332 | + if (isset($globalIVAO) && $globalIVAO) { |
|
333 | + //$cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
|
334 | 334 | $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
335 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
336 | - } else { |
|
335 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
336 | + } else { |
|
337 | 337 | //$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT'); |
338 | 338 | $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
339 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
340 | - } |
|
341 | - if ($handle) { |
|
339 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
340 | + } |
|
341 | + if ($handle) { |
|
342 | 342 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
343 | 343 | $date = ''; |
344 | - //foreach(explode("\n",$cycle) as $line) { |
|
345 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
346 | - while(($line = fgets($handle,4096)) !== false) { |
|
344 | + //foreach(explode("\n",$cycle) as $line) { |
|
345 | + if ($globalTransaction) $this->db->beginTransaction(); |
|
346 | + while(($line = fgets($handle,4096)) !== false) { |
|
347 | 347 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
348 | 348 | $date = $line; |
349 | - } elseif ($line != '') { |
|
350 | - //$this->parse($line); |
|
351 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
352 | - $pos = 0; |
|
353 | - $pieces = preg_split('/\s/',$line); |
|
354 | - if ($pieces[0] == 'METAR') $pos++; |
|
355 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
356 | - $location = $pieces[$pos]; |
|
357 | - echo $this->addMETAR($location,$line,$date); |
|
358 | - } |
|
359 | - } |
|
360 | - fclose($handle); |
|
361 | - if ($globalTransaction) $this->db->commit(); |
|
362 | - } |
|
363 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
349 | + } elseif ($line != '') { |
|
350 | + //$this->parse($line); |
|
351 | + if ($date == '') $date = date('Y/m/d H:m'); |
|
352 | + $pos = 0; |
|
353 | + $pieces = preg_split('/\s/',$line); |
|
354 | + if ($pieces[0] == 'METAR') $pos++; |
|
355 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
356 | + $location = $pieces[$pos]; |
|
357 | + echo $this->addMETAR($location,$line,$date); |
|
358 | + } |
|
359 | + } |
|
360 | + fclose($handle); |
|
361 | + if ($globalTransaction) $this->db->commit(); |
|
362 | + } |
|
363 | + if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
364 | 364 | |
365 | - } |
|
366 | - public function downloadMETAR($icao) { |
|
367 | - global $globalMETARurl; |
|
368 | - if ($globalMETARurl == '') return array(); |
|
369 | - date_default_timezone_set("UTC"); |
|
370 | - $Common = new Common(); |
|
371 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
372 | - $cycle = $Common->getData($url); |
|
373 | - $date = ''; |
|
374 | - foreach(explode("\n",$cycle) as $line) { |
|
375 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
376 | - //echo "date : ".$line."\n"; |
|
377 | - $date = $line; |
|
378 | - } |
|
379 | - if ($line != '') { |
|
380 | - //$this->parse($line); |
|
381 | - //echo $line; |
|
382 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
383 | - $pos = 0; |
|
384 | - $pieces = preg_split('/\s/',$line); |
|
385 | - if ($pieces[0] == 'METAR') $pos++; |
|
386 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
387 | - $location = $pieces[$pos]; |
|
388 | - if (strlen($location == 4)) { |
|
389 | - $this->addMETAR($location,$line,$date); |
|
390 | - return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
|
391 | - } else return array(); |
|
392 | - } |
|
393 | - //echo $line."\n"; |
|
394 | - } |
|
395 | - return array(); |
|
365 | + } |
|
366 | + public function downloadMETAR($icao) { |
|
367 | + global $globalMETARurl; |
|
368 | + if ($globalMETARurl == '') return array(); |
|
369 | + date_default_timezone_set("UTC"); |
|
370 | + $Common = new Common(); |
|
371 | + $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
372 | + $cycle = $Common->getData($url); |
|
373 | + $date = ''; |
|
374 | + foreach(explode("\n",$cycle) as $line) { |
|
375 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
376 | + //echo "date : ".$line."\n"; |
|
377 | + $date = $line; |
|
378 | + } |
|
379 | + if ($line != '') { |
|
380 | + //$this->parse($line); |
|
381 | + //echo $line; |
|
382 | + if ($date == '') $date = date('Y/m/d H:m'); |
|
383 | + $pos = 0; |
|
384 | + $pieces = preg_split('/\s/',$line); |
|
385 | + if ($pieces[0] == 'METAR') $pos++; |
|
386 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
387 | + $location = $pieces[$pos]; |
|
388 | + if (strlen($location == 4)) { |
|
389 | + $this->addMETAR($location,$line,$date); |
|
390 | + return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
|
391 | + } else return array(); |
|
392 | + } |
|
393 | + //echo $line."\n"; |
|
394 | + } |
|
395 | + return array(); |
|
396 | 396 | |
397 | - } |
|
397 | + } |
|
398 | 398 | } |
399 | 399 | /* |
400 | 400 | $METAR = new METAR(); |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | } |
517 | 517 | } |
518 | 518 | <?php |
519 | - } else { |
|
520 | - ?> |
|
519 | + } else { |
|
520 | + ?> |
|
521 | 521 | if (map.getZoom() > 7) { |
522 | 522 | var style = { |
523 | 523 | "color": "#1a3151", |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | layer_marine_data.addLayer(layer); |
537 | 537 | } |
538 | 538 | <?php |
539 | - } |
|
539 | + } |
|
540 | 540 | ?> |
541 | 541 | } |
542 | 542 | } |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | } |
518 | 518 | } |
519 | 519 | <?php |
520 | - } else { |
|
521 | - ?> |
|
520 | + } else { |
|
521 | + ?> |
|
522 | 522 | if (map.getZoom() > 7) { |
523 | 523 | var style = { |
524 | 524 | "color": "#1a3151", |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | layer_tracker_data.addLayer(layer); |
538 | 538 | } |
539 | 539 | <?php |
540 | - } |
|
540 | + } |
|
541 | 541 | ?> |
542 | 542 | } |
543 | 543 | } |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | }); |
353 | 353 | update_locationsLayer(); |
354 | 354 | <?php |
355 | - // Add support for custom json via $globalMapJson |
|
356 | - if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
355 | + // Add support for custom json via $globalMapJson |
|
356 | + if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
357 | 357 | foreach ($globalMapJson as $json) { |
358 | - if (isset($json['url'])) { |
|
358 | + if (isset($json['url'])) { |
|
359 | 359 | ?> |
360 | 360 | update_genLayer('<?php print $json['url']; ?>'); |
361 | 361 | <?php |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | setInterval(function(){update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>); |
365 | 365 | <?php |
366 | 366 | } |
367 | - } |
|
367 | + } |
|
368 | + } |
|
368 | 369 | } |
369 | - } |
|
370 | 370 | |
371 | 371 | ?> |
372 | 372 | //adds the bootstrap tooltip to the map icons |
@@ -4,31 +4,31 @@ discard block |
||
4 | 4 | $hex = str_replace("#", "", $hex); |
5 | 5 | $color = array(); |
6 | 6 | if (strlen($hex) == 3) { |
7 | - $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1)); |
|
8 | - $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1)); |
|
9 | - $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1)); |
|
7 | + $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1)); |
|
8 | + $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1)); |
|
9 | + $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1)); |
|
10 | 10 | } else if (strlen($hex) == 6) { |
11 | - $color['r'] = hexdec(substr($hex, 0, 2)); |
|
12 | - $color['g'] = hexdec(substr($hex, 2, 2)); |
|
13 | - $color['b'] = hexdec(substr($hex, 4, 2)); |
|
11 | + $color['r'] = hexdec(substr($hex, 0, 2)); |
|
12 | + $color['g'] = hexdec(substr($hex, 2, 2)); |
|
13 | + $color['b'] = hexdec(substr($hex, 4, 2)); |
|
14 | 14 | } |
15 | 15 | return $color; |
16 | 16 | } |
17 | 17 | |
18 | 18 | |
19 | 19 | if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/',$_GET['color'])) { |
20 | - exit(0); |
|
20 | + exit(0); |
|
21 | 21 | } |
22 | 22 | $color = $_GET['color']; |
23 | 23 | if (!isset($_GET['filename']) || !preg_match('/^[a-z0-9-_]+\.png$/', strtolower($_GET['filename']))) { |
24 | - echo "Incorrect filename"; |
|
25 | - exit(0); |
|
24 | + echo "Incorrect filename"; |
|
25 | + exit(0); |
|
26 | 26 | } |
27 | 27 | $filename = $_GET['filename']; |
28 | 28 | if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename)) { |
29 | - header('Content-type: image/png'); |
|
30 | - readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename); |
|
31 | - exit(0); |
|
29 | + header('Content-type: image/png'); |
|
30 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename); |
|
31 | + exit(0); |
|
32 | 32 | } |
33 | 33 | if (isset($_GET['tracker'])) { |
34 | 34 | $original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'vehicules'.DIRECTORY_SEPARATOR.$filename; |
@@ -38,66 +38,66 @@ discard block |
||
38 | 38 | $original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'aircrafts'.DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.$filename; |
39 | 39 | } |
40 | 40 | if (!file_exists($original)) { |
41 | - echo "File not found"; |
|
41 | + echo "File not found"; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | if (extension_loaded('gd') && function_exists('gd_info')) { |
45 | - $image = imagecreatefrompng($original); |
|
46 | - $index = imagecolorexact($image,26,49,81); |
|
47 | - if ($index < 0) { |
|
45 | + $image = imagecreatefrompng($original); |
|
46 | + $index = imagecolorexact($image,26,49,81); |
|
47 | + if ($index < 0) { |
|
48 | 48 | $index = imagecolorexact($image,25,49,79); |
49 | - } |
|
50 | - if ($index < 0) { |
|
49 | + } |
|
50 | + if ($index < 0) { |
|
51 | 51 | $index = imagecolorexact($image,0,0,0); |
52 | - } |
|
53 | - $c = hexToRGB($color); |
|
54 | - imagecolorset($image,$index,$c['r'],$c['g'],$c['b']); |
|
52 | + } |
|
53 | + $c = hexToRGB($color); |
|
54 | + imagecolorset($image,$index,$c['r'],$c['g'],$c['b']); |
|
55 | 55 | /* |
56 | 56 | $ig = imagecolorat($image, 0, 0); |
57 | 57 | imagecolortransparent($image, $ig); |
58 | 58 | */ |
59 | 59 | |
60 | - header('Content-type: image/png'); |
|
61 | - if (isset($_GET['resize']) && function_exists('imagecopyresampled')) { |
|
60 | + header('Content-type: image/png'); |
|
61 | + if (isset($_GET['resize']) && function_exists('imagecopyresampled')) { |
|
62 | 62 | $resize = filter_input(INPUT_GET,'resize',FILTER_SANITIZE_NUMBER_INT); |
63 | 63 | $newimg = imagecreatetruecolor($resize,$resize); |
64 | - imagealphablending($newimg, false); |
|
64 | + imagealphablending($newimg, false); |
|
65 | 65 | imagesavealpha($newimg, true); |
66 | 66 | imagecopyresampled($newimg,$image,0,0,0,0,15,15,imagesx($image),imagesy($image)); |
67 | 67 | if (isset($_GET['heading'])) { |
68 | - $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT); |
|
69 | - $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127)); |
|
70 | - imagealphablending($rotation, false); |
|
71 | - imagesavealpha($rotation, true); |
|
72 | - imagepng($rotation); |
|
73 | - imagedestroy($newimg); |
|
74 | - imagedestroy($image); |
|
75 | - imagedestroy($rotation); |
|
68 | + $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT); |
|
69 | + $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127)); |
|
70 | + imagealphablending($rotation, false); |
|
71 | + imagesavealpha($rotation, true); |
|
72 | + imagepng($rotation); |
|
73 | + imagedestroy($newimg); |
|
74 | + imagedestroy($image); |
|
75 | + imagedestroy($rotation); |
|
76 | 76 | |
77 | 77 | } else { |
78 | - imagepng($newimg); |
|
79 | - imagedestroy($newimg); |
|
80 | - imagedestroy($image); |
|
81 | - } |
|
82 | - } else { |
|
78 | + imagepng($newimg); |
|
79 | + imagedestroy($newimg); |
|
80 | + imagedestroy($image); |
|
81 | + } |
|
82 | + } else { |
|
83 | 83 | imagealphablending($image, false); |
84 | - imagesavealpha($image, true); |
|
84 | + imagesavealpha($image, true); |
|
85 | 85 | imagepng($image); |
86 | 86 | imagepng($image); |
87 | 87 | if (is_writable('cache')) { |
88 | - imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename); |
|
88 | + imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename); |
|
89 | + } |
|
90 | + imagedestroy($image); |
|
89 | 91 | } |
90 | - imagedestroy($image); |
|
91 | - } |
|
92 | 92 | } else { |
93 | - header('Content-type: image/png'); |
|
94 | - if (isset($_GET['tracker'])) { |
|
95 | - readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
96 | - } elseif (isset($_GET['marine'])) { |
|
97 | - readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
98 | - } else { |
|
99 | - if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename); |
|
93 | + header('Content-type: image/png'); |
|
94 | + if (isset($_GET['tracker'])) { |
|
95 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
96 | + } elseif (isset($_GET['marine'])) { |
|
97 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
98 | + } else { |
|
99 | + if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename); |
|
100 | 100 | else readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename); |
101 | - } |
|
101 | + } |
|
102 | 102 | } |
103 | 103 | ?> |
104 | 104 | \ No newline at end of file |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return ($dec); |
58 | 58 | } |
59 | 59 | |
60 | - /* |
|
60 | + /* |
|
61 | 61 | $ais_map64 = array( |
62 | 62 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48 |
63 | 63 | ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | // ' ' --- '?', // 0x20 - 0x3F |
98 | 98 | // '@' --- '_', // 0x40 - 0x5F |
99 | 99 | $ais_chars = array( |
100 | - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', |
|
101 | - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', |
|
102 | - 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', |
|
103 | - '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'', |
|
104 | - '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', |
|
105 | - '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', |
|
106 | - '<', '=', '>', '?' |
|
100 | + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', |
|
101 | + 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', |
|
102 | + 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', |
|
103 | + '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'', |
|
104 | + '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', |
|
105 | + '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', |
|
106 | + '<', '=', '>', '?' |
|
107 | 107 | ); |
108 | 108 | // " |
109 | 109 | $rv = ''; |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | } |
420 | 420 | if ($num_seq > 1) { // for multipart messages |
421 | 421 | if ($cmsg_sid != $msg_sid // different msg_sid |
422 | - || $msg_sid == -1 // invalid initial msg_sid |
|
423 | - || ($seq - $pseq) != 1 // not insequence |
|
422 | + || $msg_sid == -1 // invalid initial msg_sid |
|
423 | + || ($seq - $pseq) != 1 // not insequence |
|
424 | 424 | ) { // invalid for multipart message |
425 | 425 | $msg_sid = -1; |
426 | 426 | $cmsg_sid = -1; |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $itu = $itu.$pcs[5]; // get itu message |
434 | 434 | $filler += (int)$pcs[6][0]; // get filler |
435 | 435 | if ($num_seq == 1 // valid single message |
436 | - || $num_seq == $pseq // valid multi-part message |
|
436 | + || $num_seq == $pseq // valid multi-part message |
|
437 | 437 | ) { |
438 | 438 | if ($num_seq != 1) { // test |
439 | 439 | //echo $rawdata; |
@@ -516,13 +516,13 @@ discard block |
||
516 | 516 | else $pad = ''; |
517 | 517 | $rv = ''; |
518 | 518 | $ais_chars = array( |
519 | - '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
|
520 | - 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19, |
|
521 | - 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29, |
|
522 | - '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39, |
|
523 | - '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, |
|
524 | - '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59, |
|
525 | - '<'=>60, '='=>61, '>'=>62, '?'=>63 |
|
519 | + '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
|
520 | + 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19, |
|
521 | + 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29, |
|
522 | + '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39, |
|
523 | + '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, |
|
524 | + '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59, |
|
525 | + '<'=>60, '='=>61, '>'=>62, '?'=>63 |
|
526 | 526 | ); |
527 | 527 | // " |
528 | 528 | $_a = str_split($name); |
@@ -8,7 +8,7 @@ |
||
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
12 | 12 | } |
13 | 13 | setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
14 | 14 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
12 | 12 | } |
13 | 13 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
14 | 14 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $airport_airport_array = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month); |
29 | 29 | |
30 | 30 | print 'var series = ['; |
31 | - $airport_data = ''; |
|
31 | + $airport_data = ''; |
|
32 | 32 | foreach($airport_airport_array as $airport_item) |
33 | 33 | { |
34 | 34 | $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],'; |