@@ -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(); |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | $this->db = $Connection->db; |
9 | 9 | } |
10 | 10 | |
11 | - /** |
|
12 | - * Get SQL query part for filter used |
|
13 | - * @param Array $filter the filter |
|
14 | - * @return Array the SQL part |
|
15 | - */ |
|
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
11 | + /** |
|
12 | + * Get SQL query part for filter used |
|
13 | + * @param Array $filter the filter |
|
14 | + * @return Array the SQL part |
|
15 | + */ |
|
16 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -27,58 +27,58 @@ discard block |
||
27 | 27 | $filter_query_join = ''; |
28 | 28 | $filter_query_where = ''; |
29 | 29 | foreach($filters as $flt) { |
30 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
30 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
31 | 31 | if ($flt['airlines'][0] != '') { |
32 | - if (isset($flt['source'])) { |
|
32 | + if (isset($flt['source'])) { |
|
33 | 33 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
34 | - } else { |
|
34 | + } else { |
|
35 | 35 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
36 | - } |
|
36 | + } |
|
37 | + } |
|
37 | 38 | } |
38 | - } |
|
39 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
39 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
40 | 40 | if (isset($flt['source'])) { |
41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
42 | 42 | } else { |
43 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
43 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | 44 | } |
45 | - } |
|
46 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
|
45 | + } |
|
46 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
|
47 | 47 | if (isset($flt['source'])) { |
48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
49 | + } |
|
49 | 50 | } |
50 | - } |
|
51 | 51 | } |
52 | 52 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
53 | - if ($filter['airlines'][0] != '') { |
|
53 | + if ($filter['airlines'][0] != '') { |
|
54 | 54 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
55 | - } |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
59 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
59 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
60 | 60 | } |
61 | 61 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
63 | 63 | } |
64 | 64 | if (isset($filter['source']) && !empty($filter['source'])) { |
65 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
65 | + $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
66 | 66 | } |
67 | 67 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
68 | - $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
|
68 | + $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
|
69 | 69 | } |
70 | 70 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
71 | - if ($filter_query_where == '') { |
|
71 | + if ($filter_query_where == '') { |
|
72 | 72 | $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
73 | - } else { |
|
73 | + } else { |
|
74 | 74 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | - } |
|
75 | + } |
|
76 | 76 | } |
77 | 77 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
78 | 78 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
79 | 79 | $filter_query = $filter_query_join.$filter_query_where; |
80 | 80 | return $filter_query; |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | 83 | // Spotter_archive |
84 | 84 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -109,44 +109,44 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * Gets all the spotter information based on a particular callsign |
|
114 | - * |
|
115 | - * @return Array the spotter information |
|
116 | - * |
|
117 | - */ |
|
118 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
119 | - { |
|
112 | + /** |
|
113 | + * Gets all the spotter information based on a particular callsign |
|
114 | + * |
|
115 | + * @return Array the spotter information |
|
116 | + * |
|
117 | + */ |
|
118 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
119 | + { |
|
120 | 120 | $Spotter = new Spotter($this->db); |
121 | - date_default_timezone_set('UTC'); |
|
121 | + date_default_timezone_set('UTC'); |
|
122 | 122 | |
123 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
124 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
125 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
123 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
124 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
125 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
126 | 126 | |
127 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
127 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
128 | 128 | |
129 | - return $spotter_array; |
|
130 | - } |
|
129 | + return $spotter_array; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * Gets last the spotter information based on a particular id |
|
135 | - * |
|
136 | - * @return Array the spotter information |
|
137 | - * |
|
138 | - */ |
|
139 | - public function getLastArchiveSpotterDataById($id) |
|
140 | - { |
|
141 | - $Spotter = new Spotter($this->db); |
|
142 | - date_default_timezone_set('UTC'); |
|
143 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
144 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
145 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
146 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
133 | + /** |
|
134 | + * Gets last the spotter information based on a particular id |
|
135 | + * |
|
136 | + * @return Array the spotter information |
|
137 | + * |
|
138 | + */ |
|
139 | + public function getLastArchiveSpotterDataById($id) |
|
140 | + { |
|
141 | + $Spotter = new Spotter($this->db); |
|
142 | + date_default_timezone_set('UTC'); |
|
143 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
144 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
145 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
146 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
147 | 147 | |
148 | 148 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
149 | - /* |
|
149 | + /* |
|
150 | 150 | try { |
151 | 151 | $Connection = new Connection(); |
152 | 152 | $sth = Connection->$db->prepare($query); |
@@ -156,232 +156,232 @@ discard block |
||
156 | 156 | } |
157 | 157 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
158 | 158 | */ |
159 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
160 | - |
|
161 | - return $spotter_array; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Gets all the spotter information based on a particular id |
|
166 | - * |
|
167 | - * @return Array the spotter information |
|
168 | - * |
|
169 | - */ |
|
170 | - public function getAllArchiveSpotterDataById($id) |
|
171 | - { |
|
172 | - date_default_timezone_set('UTC'); |
|
173 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
174 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
159 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
160 | + |
|
161 | + return $spotter_array; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Gets all the spotter information based on a particular id |
|
166 | + * |
|
167 | + * @return Array the spotter information |
|
168 | + * |
|
169 | + */ |
|
170 | + public function getAllArchiveSpotterDataById($id) |
|
171 | + { |
|
172 | + date_default_timezone_set('UTC'); |
|
173 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
174 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
175 | 175 | |
176 | 176 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
177 | 177 | |
178 | - try { |
|
179 | - $sth = $this->db->prepare($query); |
|
180 | - $sth->execute(array(':id' => $id)); |
|
181 | - } catch(PDOException $e) { |
|
182 | - echo $e->getMessage(); |
|
183 | - die; |
|
184 | - } |
|
185 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
186 | - |
|
187 | - return $spotter_array; |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Gets coordinate & time spotter information based on a particular id |
|
192 | - * |
|
193 | - * @return Array the spotter information |
|
194 | - * |
|
195 | - */ |
|
196 | - public function getCoordArchiveSpotterDataById($id) |
|
197 | - { |
|
198 | - date_default_timezone_set('UTC'); |
|
199 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
200 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
178 | + try { |
|
179 | + $sth = $this->db->prepare($query); |
|
180 | + $sth->execute(array(':id' => $id)); |
|
181 | + } catch(PDOException $e) { |
|
182 | + echo $e->getMessage(); |
|
183 | + die; |
|
184 | + } |
|
185 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
186 | + |
|
187 | + return $spotter_array; |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Gets coordinate & time spotter information based on a particular id |
|
192 | + * |
|
193 | + * @return Array the spotter information |
|
194 | + * |
|
195 | + */ |
|
196 | + public function getCoordArchiveSpotterDataById($id) |
|
197 | + { |
|
198 | + date_default_timezone_set('UTC'); |
|
199 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
200 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
201 | 201 | |
202 | 202 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
203 | 203 | |
204 | - try { |
|
205 | - $sth = $this->db->prepare($query); |
|
206 | - $sth->execute(array(':id' => $id)); |
|
207 | - } catch(PDOException $e) { |
|
208 | - echo $e->getMessage(); |
|
209 | - die; |
|
210 | - } |
|
211 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
204 | + try { |
|
205 | + $sth = $this->db->prepare($query); |
|
206 | + $sth->execute(array(':id' => $id)); |
|
207 | + } catch(PDOException $e) { |
|
208 | + echo $e->getMessage(); |
|
209 | + die; |
|
210 | + } |
|
211 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
212 | 212 | |
213 | - return $spotter_array; |
|
214 | - } |
|
213 | + return $spotter_array; |
|
214 | + } |
|
215 | 215 | |
216 | 216 | |
217 | - /** |
|
218 | - * Gets altitude information based on a particular callsign |
|
219 | - * |
|
220 | - * @return Array the spotter information |
|
221 | - * |
|
222 | - */ |
|
223 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
224 | - { |
|
217 | + /** |
|
218 | + * Gets altitude information based on a particular callsign |
|
219 | + * |
|
220 | + * @return Array the spotter information |
|
221 | + * |
|
222 | + */ |
|
223 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
224 | + { |
|
225 | 225 | |
226 | - date_default_timezone_set('UTC'); |
|
226 | + date_default_timezone_set('UTC'); |
|
227 | 227 | |
228 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
229 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
228 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
229 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
230 | 230 | |
231 | - try { |
|
232 | - $sth = $this->db->prepare($query); |
|
233 | - $sth->execute(array(':ident' => $ident)); |
|
234 | - } catch(PDOException $e) { |
|
235 | - echo $e->getMessage(); |
|
236 | - die; |
|
237 | - } |
|
238 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
231 | + try { |
|
232 | + $sth = $this->db->prepare($query); |
|
233 | + $sth->execute(array(':ident' => $ident)); |
|
234 | + } catch(PDOException $e) { |
|
235 | + echo $e->getMessage(); |
|
236 | + die; |
|
237 | + } |
|
238 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
239 | 239 | |
240 | - return $spotter_array; |
|
241 | - } |
|
240 | + return $spotter_array; |
|
241 | + } |
|
242 | 242 | |
243 | - /** |
|
244 | - * Gets altitude information based on a particular id |
|
245 | - * |
|
246 | - * @return Array the spotter information |
|
247 | - * |
|
248 | - */ |
|
249 | - public function getAltitudeArchiveSpotterDataById($id) |
|
250 | - { |
|
243 | + /** |
|
244 | + * Gets altitude information based on a particular id |
|
245 | + * |
|
246 | + * @return Array the spotter information |
|
247 | + * |
|
248 | + */ |
|
249 | + public function getAltitudeArchiveSpotterDataById($id) |
|
250 | + { |
|
251 | 251 | |
252 | - date_default_timezone_set('UTC'); |
|
252 | + date_default_timezone_set('UTC'); |
|
253 | 253 | |
254 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
255 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
254 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
255 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
256 | 256 | |
257 | - try { |
|
258 | - $sth = $this->db->prepare($query); |
|
259 | - $sth->execute(array(':id' => $id)); |
|
260 | - } catch(PDOException $e) { |
|
261 | - echo $e->getMessage(); |
|
262 | - die; |
|
263 | - } |
|
264 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
257 | + try { |
|
258 | + $sth = $this->db->prepare($query); |
|
259 | + $sth->execute(array(':id' => $id)); |
|
260 | + } catch(PDOException $e) { |
|
261 | + echo $e->getMessage(); |
|
262 | + die; |
|
263 | + } |
|
264 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
265 | 265 | |
266 | - return $spotter_array; |
|
267 | - } |
|
266 | + return $spotter_array; |
|
267 | + } |
|
268 | 268 | |
269 | - /** |
|
270 | - * Gets altitude & speed information based on a particular id |
|
271 | - * |
|
272 | - * @return Array the spotter information |
|
273 | - * |
|
274 | - */ |
|
275 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
276 | - { |
|
269 | + /** |
|
270 | + * Gets altitude & speed information based on a particular id |
|
271 | + * |
|
272 | + * @return Array the spotter information |
|
273 | + * |
|
274 | + */ |
|
275 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
276 | + { |
|
277 | 277 | |
278 | - date_default_timezone_set('UTC'); |
|
278 | + date_default_timezone_set('UTC'); |
|
279 | 279 | |
280 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
281 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
280 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
281 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
282 | 282 | |
283 | - try { |
|
284 | - $sth = $this->db->prepare($query); |
|
285 | - $sth->execute(array(':id' => $id)); |
|
286 | - } catch(PDOException $e) { |
|
287 | - echo $e->getMessage(); |
|
288 | - die; |
|
289 | - } |
|
290 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
283 | + try { |
|
284 | + $sth = $this->db->prepare($query); |
|
285 | + $sth->execute(array(':id' => $id)); |
|
286 | + } catch(PDOException $e) { |
|
287 | + echo $e->getMessage(); |
|
288 | + die; |
|
289 | + } |
|
290 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
291 | 291 | |
292 | - return $spotter_array; |
|
293 | - } |
|
292 | + return $spotter_array; |
|
293 | + } |
|
294 | 294 | |
295 | 295 | |
296 | - /** |
|
297 | - * Gets altitude information based on a particular callsign |
|
298 | - * |
|
299 | - * @return Array the spotter information |
|
300 | - * |
|
301 | - */ |
|
302 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
303 | - { |
|
296 | + /** |
|
297 | + * Gets altitude information based on a particular callsign |
|
298 | + * |
|
299 | + * @return Array the spotter information |
|
300 | + * |
|
301 | + */ |
|
302 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
303 | + { |
|
304 | 304 | |
305 | - date_default_timezone_set('UTC'); |
|
305 | + date_default_timezone_set('UTC'); |
|
306 | 306 | |
307 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
308 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
307 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
308 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
309 | 309 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
310 | 310 | |
311 | - try { |
|
312 | - $sth = $this->db->prepare($query); |
|
313 | - $sth->execute(array(':ident' => $ident)); |
|
314 | - } catch(PDOException $e) { |
|
315 | - echo $e->getMessage(); |
|
316 | - die; |
|
317 | - } |
|
318 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
311 | + try { |
|
312 | + $sth = $this->db->prepare($query); |
|
313 | + $sth->execute(array(':ident' => $ident)); |
|
314 | + } catch(PDOException $e) { |
|
315 | + echo $e->getMessage(); |
|
316 | + die; |
|
317 | + } |
|
318 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
319 | 319 | |
320 | - return $spotter_array; |
|
321 | - } |
|
320 | + return $spotter_array; |
|
321 | + } |
|
322 | 322 | |
323 | 323 | |
324 | 324 | |
325 | - /** |
|
326 | - * Gets all the archive spotter information |
|
327 | - * |
|
328 | - * @return Array the spotter information |
|
329 | - * |
|
330 | - */ |
|
331 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
332 | - { |
|
333 | - $Spotter = new Spotter($this->db); |
|
334 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
335 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
325 | + /** |
|
326 | + * Gets all the archive spotter information |
|
327 | + * |
|
328 | + * @return Array the spotter information |
|
329 | + * |
|
330 | + */ |
|
331 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
332 | + { |
|
333 | + $Spotter = new Spotter($this->db); |
|
334 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
335 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
336 | 336 | |
337 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
337 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
338 | 338 | |
339 | - return $spotter_array; |
|
340 | - } |
|
339 | + return $spotter_array; |
|
340 | + } |
|
341 | 341 | |
342 | - public function deleteSpotterArchiveTrackData() |
|
343 | - { |
|
342 | + public function deleteSpotterArchiveTrackData() |
|
343 | + { |
|
344 | 344 | global $globalArchiveKeepTrackMonths; |
345 | - date_default_timezone_set('UTC'); |
|
345 | + date_default_timezone_set('UTC'); |
|
346 | 346 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
347 | - try { |
|
348 | - $sth = $this->db->prepare($query); |
|
349 | - $sth->execute(); |
|
350 | - } catch(PDOException $e) { |
|
351 | - echo $e->getMessage(); |
|
352 | - die; |
|
353 | - } |
|
347 | + try { |
|
348 | + $sth = $this->db->prepare($query); |
|
349 | + $sth->execute(); |
|
350 | + } catch(PDOException $e) { |
|
351 | + echo $e->getMessage(); |
|
352 | + die; |
|
353 | + } |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | - * Gets Minimal Live Spotter data |
|
358 | - * |
|
359 | - * @return Array the spotter information |
|
360 | - * |
|
361 | - */ |
|
362 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
363 | - { |
|
364 | - global $globalDBdriver, $globalLiveInterval; |
|
365 | - date_default_timezone_set('UTC'); |
|
366 | - |
|
367 | - $filter_query = ''; |
|
368 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
369 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
370 | - } |
|
371 | - // Use spotter_output also ? |
|
372 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
373 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
374 | - } |
|
375 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
376 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
377 | - } |
|
378 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
379 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
380 | - } |
|
381 | - |
|
382 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
383 | - if ($globalDBdriver == 'mysql') { |
|
384 | - /* |
|
357 | + * Gets Minimal Live Spotter data |
|
358 | + * |
|
359 | + * @return Array the spotter information |
|
360 | + * |
|
361 | + */ |
|
362 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
363 | + { |
|
364 | + global $globalDBdriver, $globalLiveInterval; |
|
365 | + date_default_timezone_set('UTC'); |
|
366 | + |
|
367 | + $filter_query = ''; |
|
368 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
369 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
370 | + } |
|
371 | + // Use spotter_output also ? |
|
372 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
373 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
374 | + } |
|
375 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
376 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
377 | + } |
|
378 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
379 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
380 | + } |
|
381 | + |
|
382 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
383 | + if ($globalDBdriver == 'mysql') { |
|
384 | + /* |
|
385 | 385 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
386 | 386 | FROM spotter_archive |
387 | 387 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -400,56 +400,56 @@ discard block |
||
400 | 400 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
401 | 401 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
402 | 402 | '.$filter_query.' ORDER BY flightaware_id'; |
403 | - } else { |
|
404 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
405 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
403 | + } else { |
|
404 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
405 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
406 | 406 | FROM spotter_archive |
407 | 407 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
408 | 408 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
409 | 409 | '.$filter_query.' ORDER BY flightaware_id'; |
410 | - } |
|
411 | - //echo $query; |
|
412 | - try { |
|
413 | - $sth = $this->db->prepare($query); |
|
414 | - $sth->execute(); |
|
415 | - } catch(PDOException $e) { |
|
416 | - echo $e->getMessage(); |
|
417 | - die; |
|
418 | - } |
|
419 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
420 | - |
|
421 | - return $spotter_array; |
|
422 | - } |
|
410 | + } |
|
411 | + //echo $query; |
|
412 | + try { |
|
413 | + $sth = $this->db->prepare($query); |
|
414 | + $sth->execute(); |
|
415 | + } catch(PDOException $e) { |
|
416 | + echo $e->getMessage(); |
|
417 | + die; |
|
418 | + } |
|
419 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
420 | + |
|
421 | + return $spotter_array; |
|
422 | + } |
|
423 | 423 | |
424 | 424 | /** |
425 | - * Gets Minimal Live Spotter data |
|
426 | - * |
|
427 | - * @return Array the spotter information |
|
428 | - * |
|
429 | - */ |
|
430 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
431 | - { |
|
432 | - global $globalDBdriver, $globalLiveInterval; |
|
433 | - date_default_timezone_set('UTC'); |
|
434 | - |
|
435 | - $filter_query = ''; |
|
436 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
437 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
438 | - } |
|
439 | - // Should use spotter_output also ? |
|
440 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
441 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
442 | - } |
|
443 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
444 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
445 | - } |
|
446 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
447 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
448 | - } |
|
449 | - |
|
450 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
451 | - if ($globalDBdriver == 'mysql') { |
|
452 | - /* |
|
425 | + * Gets Minimal Live Spotter data |
|
426 | + * |
|
427 | + * @return Array the spotter information |
|
428 | + * |
|
429 | + */ |
|
430 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
431 | + { |
|
432 | + global $globalDBdriver, $globalLiveInterval; |
|
433 | + date_default_timezone_set('UTC'); |
|
434 | + |
|
435 | + $filter_query = ''; |
|
436 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
437 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
438 | + } |
|
439 | + // Should use spotter_output also ? |
|
440 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
441 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
442 | + } |
|
443 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
444 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
445 | + } |
|
446 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
447 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
448 | + } |
|
449 | + |
|
450 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
451 | + if ($globalDBdriver == 'mysql') { |
|
452 | + /* |
|
453 | 453 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
454 | 454 | FROM spotter_archive |
455 | 455 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -460,95 +460,95 @@ discard block |
||
460 | 460 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
461 | 461 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
462 | 462 | |
463 | - } else { |
|
464 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
465 | - /* |
|
463 | + } else { |
|
464 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
465 | + /* |
|
466 | 466 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
467 | 467 | FROM spotter_archive_output |
468 | 468 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
469 | 469 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
470 | 470 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
471 | 471 | */ |
472 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
472 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
473 | 473 | FROM spotter_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
477 | 477 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
478 | 478 | |
479 | - } |
|
480 | - //echo $query; |
|
481 | - try { |
|
482 | - $sth = $this->db->prepare($query); |
|
483 | - $sth->execute(); |
|
484 | - } catch(PDOException $e) { |
|
485 | - echo $e->getMessage(); |
|
486 | - die; |
|
487 | - } |
|
488 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
489 | - |
|
490 | - return $spotter_array; |
|
491 | - } |
|
479 | + } |
|
480 | + //echo $query; |
|
481 | + try { |
|
482 | + $sth = $this->db->prepare($query); |
|
483 | + $sth->execute(); |
|
484 | + } catch(PDOException $e) { |
|
485 | + echo $e->getMessage(); |
|
486 | + die; |
|
487 | + } |
|
488 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
489 | + |
|
490 | + return $spotter_array; |
|
491 | + } |
|
492 | 492 | |
493 | 493 | /** |
494 | - * Gets count Live Spotter data |
|
495 | - * |
|
496 | - * @return Array the spotter information |
|
497 | - * |
|
498 | - */ |
|
499 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
500 | - { |
|
501 | - global $globalDBdriver, $globalLiveInterval; |
|
502 | - date_default_timezone_set('UTC'); |
|
503 | - |
|
504 | - $filter_query = ''; |
|
505 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
506 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
507 | - } |
|
508 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
509 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
510 | - } |
|
511 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
512 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
513 | - } |
|
514 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
515 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
516 | - } |
|
517 | - |
|
518 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
519 | - if ($globalDBdriver == 'mysql') { |
|
494 | + * Gets count Live Spotter data |
|
495 | + * |
|
496 | + * @return Array the spotter information |
|
497 | + * |
|
498 | + */ |
|
499 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
500 | + { |
|
501 | + global $globalDBdriver, $globalLiveInterval; |
|
502 | + date_default_timezone_set('UTC'); |
|
503 | + |
|
504 | + $filter_query = ''; |
|
505 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
506 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
507 | + } |
|
508 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
509 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
510 | + } |
|
511 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
512 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
513 | + } |
|
514 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
515 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
516 | + } |
|
517 | + |
|
518 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
519 | + if ($globalDBdriver == 'mysql') { |
|
520 | 520 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
521 | 521 | FROM spotter_archive l |
522 | 522 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
523 | - } else { |
|
523 | + } else { |
|
524 | 524 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
525 | - } |
|
526 | - //echo $query; |
|
527 | - try { |
|
528 | - $sth = $this->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - echo $e->getMessage(); |
|
532 | - die; |
|
533 | - } |
|
525 | + } |
|
526 | + //echo $query; |
|
527 | + try { |
|
528 | + $sth = $this->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + echo $e->getMessage(); |
|
532 | + die; |
|
533 | + } |
|
534 | 534 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
535 | 535 | $sth->closeCursor(); |
536 | - return $result['nb']; |
|
536 | + return $result['nb']; |
|
537 | 537 | |
538 | - } |
|
538 | + } |
|
539 | 539 | |
540 | 540 | |
541 | 541 | |
542 | 542 | // Spotter_Archive_output |
543 | 543 | |
544 | - /** |
|
545 | - * Gets all the spotter information |
|
546 | - * |
|
547 | - * @return Array the spotter information |
|
548 | - * |
|
549 | - */ |
|
550 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
551 | - { |
|
544 | + /** |
|
545 | + * Gets all the spotter information |
|
546 | + * |
|
547 | + * @return Array the spotter information |
|
548 | + * |
|
549 | + */ |
|
550 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
551 | + { |
|
552 | 552 | global $globalTimezone, $globalDBdriver; |
553 | 553 | require_once(dirname(__FILE__).'/class.Translation.php'); |
554 | 554 | $Translation = new Translation(); |
@@ -562,159 +562,159 @@ discard block |
||
562 | 562 | $filter_query = $this->getFilter($filters); |
563 | 563 | if ($q != "") |
564 | 564 | { |
565 | - if (!is_string($q)) |
|
566 | - { |
|
565 | + if (!is_string($q)) |
|
566 | + { |
|
567 | 567 | return false; |
568 | - } else { |
|
568 | + } else { |
|
569 | 569 | |
570 | 570 | $q_array = explode(" ", $q); |
571 | 571 | |
572 | 572 | foreach ($q_array as $q_item){ |
573 | - $additional_query .= " AND ("; |
|
574 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
575 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
576 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
577 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
578 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
579 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
580 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
594 | - $translate = $Translation->ident2icao($q_item); |
|
595 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
596 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
597 | - $additional_query .= ")"; |
|
573 | + $additional_query .= " AND ("; |
|
574 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
575 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
576 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
577 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
578 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
579 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
580 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
594 | + $translate = $Translation->ident2icao($q_item); |
|
595 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
596 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
597 | + $additional_query .= ")"; |
|
598 | + } |
|
598 | 599 | } |
599 | - } |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | if ($registration != "") |
603 | 603 | { |
604 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
605 | - if (!is_string($registration)) |
|
606 | - { |
|
604 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
605 | + if (!is_string($registration)) |
|
606 | + { |
|
607 | 607 | return false; |
608 | - } else { |
|
608 | + } else { |
|
609 | 609 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
610 | - } |
|
610 | + } |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | if ($aircraft_icao != "") |
614 | 614 | { |
615 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
616 | - if (!is_string($aircraft_icao)) |
|
617 | - { |
|
615 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
616 | + if (!is_string($aircraft_icao)) |
|
617 | + { |
|
618 | 618 | return false; |
619 | - } else { |
|
619 | + } else { |
|
620 | 620 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
621 | - } |
|
621 | + } |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | if ($aircraft_manufacturer != "") |
625 | 625 | { |
626 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
627 | - if (!is_string($aircraft_manufacturer)) |
|
628 | - { |
|
626 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
627 | + if (!is_string($aircraft_manufacturer)) |
|
628 | + { |
|
629 | 629 | return false; |
630 | - } else { |
|
630 | + } else { |
|
631 | 631 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
632 | - } |
|
632 | + } |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | if ($highlights == "true") |
636 | 636 | { |
637 | - if (!is_string($highlights)) |
|
638 | - { |
|
637 | + if (!is_string($highlights)) |
|
638 | + { |
|
639 | 639 | return false; |
640 | - } else { |
|
640 | + } else { |
|
641 | 641 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
642 | - } |
|
642 | + } |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | if ($airline_icao != "") |
646 | 646 | { |
647 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
648 | - if (!is_string($airline_icao)) |
|
649 | - { |
|
647 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
648 | + if (!is_string($airline_icao)) |
|
649 | + { |
|
650 | 650 | return false; |
651 | - } else { |
|
651 | + } else { |
|
652 | 652 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
653 | - } |
|
653 | + } |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | if ($airline_country != "") |
657 | 657 | { |
658 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
659 | - if (!is_string($airline_country)) |
|
660 | - { |
|
658 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
659 | + if (!is_string($airline_country)) |
|
660 | + { |
|
661 | 661 | return false; |
662 | - } else { |
|
662 | + } else { |
|
663 | 663 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
664 | - } |
|
664 | + } |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | if ($airline_type != "") |
668 | 668 | { |
669 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
670 | - if (!is_string($airline_type)) |
|
671 | - { |
|
669 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
670 | + if (!is_string($airline_type)) |
|
671 | + { |
|
672 | 672 | return false; |
673 | - } else { |
|
673 | + } else { |
|
674 | 674 | if ($airline_type == "passenger") |
675 | 675 | { |
676 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
676 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
677 | 677 | } |
678 | 678 | if ($airline_type == "cargo") |
679 | 679 | { |
680 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
680 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
681 | 681 | } |
682 | 682 | if ($airline_type == "military") |
683 | 683 | { |
684 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
684 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
685 | + } |
|
685 | 686 | } |
686 | - } |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | if ($airport != "") |
690 | 690 | { |
691 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
692 | - if (!is_string($airport)) |
|
693 | - { |
|
691 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
692 | + if (!is_string($airport)) |
|
693 | + { |
|
694 | 694 | return false; |
695 | - } else { |
|
695 | + } else { |
|
696 | 696 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
697 | - } |
|
697 | + } |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | if ($airport_country != "") |
701 | 701 | { |
702 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
703 | - if (!is_string($airport_country)) |
|
704 | - { |
|
702 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
703 | + if (!is_string($airport_country)) |
|
704 | + { |
|
705 | 705 | return false; |
706 | - } else { |
|
706 | + } else { |
|
707 | 707 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
708 | - } |
|
708 | + } |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | if ($callsign != "") |
712 | 712 | { |
713 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
714 | - if (!is_string($callsign)) |
|
715 | - { |
|
713 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
714 | + if (!is_string($callsign)) |
|
715 | + { |
|
716 | 716 | return false; |
717 | - } else { |
|
717 | + } else { |
|
718 | 718 | $translate = $Translation->ident2icao($callsign); |
719 | 719 | if ($translate != $callsign) { |
720 | 720 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -722,99 +722,99 @@ discard block |
||
722 | 722 | } else { |
723 | 723 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
724 | 724 | } |
725 | - } |
|
725 | + } |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | if ($owner != "") |
729 | 729 | { |
730 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
731 | - if (!is_string($owner)) |
|
732 | - { |
|
730 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
731 | + if (!is_string($owner)) |
|
732 | + { |
|
733 | 733 | return false; |
734 | - } else { |
|
734 | + } else { |
|
735 | 735 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
736 | - } |
|
736 | + } |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | if ($pilot_name != "") |
740 | 740 | { |
741 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
742 | - if (!is_string($pilot_name)) |
|
743 | - { |
|
741 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
742 | + if (!is_string($pilot_name)) |
|
743 | + { |
|
744 | 744 | return false; |
745 | - } else { |
|
745 | + } else { |
|
746 | 746 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
747 | - } |
|
747 | + } |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | if ($pilot_id != "") |
751 | 751 | { |
752 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
753 | - if (!is_string($pilot_id)) |
|
754 | - { |
|
752 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
753 | + if (!is_string($pilot_id)) |
|
754 | + { |
|
755 | 755 | return false; |
756 | - } else { |
|
756 | + } else { |
|
757 | 757 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
758 | - } |
|
758 | + } |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | if ($departure_airport_route != "") |
762 | 762 | { |
763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
764 | - if (!is_string($departure_airport_route)) |
|
765 | - { |
|
763 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
764 | + if (!is_string($departure_airport_route)) |
|
765 | + { |
|
766 | 766 | return false; |
767 | - } else { |
|
767 | + } else { |
|
768 | 768 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
769 | - } |
|
769 | + } |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | if ($arrival_airport_route != "") |
773 | 773 | { |
774 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
775 | - if (!is_string($arrival_airport_route)) |
|
776 | - { |
|
774 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
775 | + if (!is_string($arrival_airport_route)) |
|
776 | + { |
|
777 | 777 | return false; |
778 | - } else { |
|
778 | + } else { |
|
779 | 779 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
780 | - } |
|
780 | + } |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | if ($altitude != "") |
784 | 784 | { |
785 | - $altitude_array = explode(",", $altitude); |
|
785 | + $altitude_array = explode(",", $altitude); |
|
786 | 786 | |
787 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | 789 | |
790 | 790 | |
791 | - if ($altitude_array[1] != "") |
|
792 | - { |
|
791 | + if ($altitude_array[1] != "") |
|
792 | + { |
|
793 | 793 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
794 | 794 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
795 | 795 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
796 | - } else { |
|
796 | + } else { |
|
797 | 797 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
798 | 798 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
799 | - } |
|
799 | + } |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | if ($date_posted != "") |
803 | 803 | { |
804 | - $date_array = explode(",", $date_posted); |
|
804 | + $date_array = explode(",", $date_posted); |
|
805 | 805 | |
806 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
808 | 808 | |
809 | - if ($globalTimezone != '') { |
|
809 | + if ($globalTimezone != '') { |
|
810 | 810 | date_default_timezone_set($globalTimezone); |
811 | 811 | $datetime = new DateTime(); |
812 | 812 | $offset = $datetime->format('P'); |
813 | - } else $offset = '+00:00'; |
|
813 | + } else $offset = '+00:00'; |
|
814 | 814 | |
815 | 815 | |
816 | - if ($date_array[1] != "") |
|
817 | - { |
|
816 | + if ($date_array[1] != "") |
|
817 | + { |
|
818 | 818 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
819 | 819 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
820 | 820 | if ($globalDBdriver == 'mysql') { |
@@ -822,28 +822,28 @@ discard block |
||
822 | 822 | } else { |
823 | 823 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
824 | 824 | } |
825 | - } else { |
|
825 | + } else { |
|
826 | 826 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
827 | - if ($globalDBdriver == 'mysql') { |
|
827 | + if ($globalDBdriver == 'mysql') { |
|
828 | 828 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
829 | 829 | } else { |
830 | 830 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
831 | 831 | } |
832 | - } |
|
832 | + } |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | if ($limit != "") |
836 | 836 | { |
837 | - $limit_array = explode(",", $limit); |
|
837 | + $limit_array = explode(",", $limit); |
|
838 | 838 | |
839 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
841 | 841 | |
842 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
843 | - { |
|
842 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
843 | + { |
|
844 | 844 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
845 | 845 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
846 | - } |
|
846 | + } |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | |
@@ -874,33 +874,33 @@ discard block |
||
874 | 874 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
875 | 875 | |
876 | 876 | return $spotter_array; |
877 | - } |
|
877 | + } |
|
878 | 878 | |
879 | - public function deleteSpotterArchiveData() |
|
880 | - { |
|
879 | + public function deleteSpotterArchiveData() |
|
880 | + { |
|
881 | 881 | global $globalArchiveKeepMonths, $globalDBdriver; |
882 | - date_default_timezone_set('UTC'); |
|
883 | - if ($globalDBdriver == 'mysql') { |
|
882 | + date_default_timezone_set('UTC'); |
|
883 | + if ($globalDBdriver == 'mysql') { |
|
884 | 884 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
885 | 885 | } else { |
886 | 886 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
887 | 887 | } |
888 | - try { |
|
889 | - $sth = $this->db->prepare($query); |
|
890 | - $sth->execute(); |
|
891 | - } catch(PDOException $e) { |
|
892 | - return "error"; |
|
893 | - } |
|
888 | + try { |
|
889 | + $sth = $this->db->prepare($query); |
|
890 | + $sth->execute(); |
|
891 | + } catch(PDOException $e) { |
|
892 | + return "error"; |
|
893 | + } |
|
894 | 894 | } |
895 | 895 | |
896 | - /** |
|
897 | - * Gets all the spotter information based on the callsign |
|
898 | - * |
|
899 | - * @return Array the spotter information |
|
900 | - * |
|
901 | - */ |
|
902 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
903 | - { |
|
896 | + /** |
|
897 | + * Gets all the spotter information based on the callsign |
|
898 | + * |
|
899 | + * @return Array the spotter information |
|
900 | + * |
|
901 | + */ |
|
902 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
903 | + { |
|
904 | 904 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
905 | 905 | |
906 | 906 | date_default_timezone_set('UTC'); |
@@ -912,35 +912,35 @@ discard block |
||
912 | 912 | |
913 | 913 | if ($ident != "") |
914 | 914 | { |
915 | - if (!is_string($ident)) |
|
916 | - { |
|
915 | + if (!is_string($ident)) |
|
916 | + { |
|
917 | 917 | return false; |
918 | - } else { |
|
918 | + } else { |
|
919 | 919 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
920 | 920 | $query_values = array(':ident' => $ident); |
921 | - } |
|
921 | + } |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | if ($limit != "") |
925 | 925 | { |
926 | - $limit_array = explode(",", $limit); |
|
926 | + $limit_array = explode(",", $limit); |
|
927 | 927 | |
928 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
930 | 930 | |
931 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
932 | - { |
|
931 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
932 | + { |
|
933 | 933 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
934 | 934 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
935 | - } |
|
935 | + } |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | if ($sort != "") |
939 | 939 | { |
940 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
941 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
940 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
941 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
942 | 942 | } else { |
943 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
943 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -948,17 +948,17 @@ discard block |
||
948 | 948 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
949 | 949 | |
950 | 950 | return $spotter_array; |
951 | - } |
|
951 | + } |
|
952 | 952 | |
953 | 953 | |
954 | - /** |
|
955 | - * Gets all the spotter information based on the owner |
|
956 | - * |
|
957 | - * @return Array the spotter information |
|
958 | - * |
|
959 | - */ |
|
960 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '') |
|
961 | - { |
|
954 | + /** |
|
955 | + * Gets all the spotter information based on the owner |
|
956 | + * |
|
957 | + * @return Array the spotter information |
|
958 | + * |
|
959 | + */ |
|
960 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '') |
|
961 | + { |
|
962 | 962 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
963 | 963 | |
964 | 964 | date_default_timezone_set('UTC'); |
@@ -970,35 +970,35 @@ discard block |
||
970 | 970 | |
971 | 971 | if ($owner != "") |
972 | 972 | { |
973 | - if (!is_string($owner)) |
|
974 | - { |
|
973 | + if (!is_string($owner)) |
|
974 | + { |
|
975 | 975 | return false; |
976 | - } else { |
|
976 | + } else { |
|
977 | 977 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
978 | 978 | $query_values = array(':owner' => $owner); |
979 | - } |
|
979 | + } |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | if ($limit != "") |
983 | 983 | { |
984 | - $limit_array = explode(",", $limit); |
|
984 | + $limit_array = explode(",", $limit); |
|
985 | 985 | |
986 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
987 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
986 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
988 | 988 | |
989 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
990 | - { |
|
989 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
990 | + { |
|
991 | 991 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
992 | 992 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
993 | - } |
|
993 | + } |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | if ($sort != "") |
997 | 997 | { |
998 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
999 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
998 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
999 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1000 | 1000 | } else { |
1001 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1001 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | $query = $global_query." WHERE spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1006,16 +1006,16 @@ discard block |
||
1006 | 1006 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1007 | 1007 | |
1008 | 1008 | return $spotter_array; |
1009 | - } |
|
1010 | - |
|
1011 | - /** |
|
1012 | - * Gets all the spotter information based on the pilot |
|
1013 | - * |
|
1014 | - * @return Array the spotter information |
|
1015 | - * |
|
1016 | - */ |
|
1017 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '') |
|
1018 | - { |
|
1009 | + } |
|
1010 | + |
|
1011 | + /** |
|
1012 | + * Gets all the spotter information based on the pilot |
|
1013 | + * |
|
1014 | + * @return Array the spotter information |
|
1015 | + * |
|
1016 | + */ |
|
1017 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '') |
|
1018 | + { |
|
1019 | 1019 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1020 | 1020 | |
1021 | 1021 | date_default_timezone_set('UTC'); |
@@ -1033,24 +1033,24 @@ discard block |
||
1033 | 1033 | |
1034 | 1034 | if ($limit != "") |
1035 | 1035 | { |
1036 | - $limit_array = explode(",", $limit); |
|
1036 | + $limit_array = explode(",", $limit); |
|
1037 | 1037 | |
1038 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1039 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1038 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1039 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | 1040 | |
1041 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1042 | - { |
|
1041 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1042 | + { |
|
1043 | 1043 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1044 | 1044 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1045 | - } |
|
1045 | + } |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | if ($sort != "") |
1049 | 1049 | { |
1050 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1051 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1050 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1051 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1052 | 1052 | } else { |
1053 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1053 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | $query = $global_query." WHERE spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1058,16 +1058,16 @@ discard block |
||
1058 | 1058 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1059 | 1059 | |
1060 | 1060 | return $spotter_array; |
1061 | - } |
|
1062 | - |
|
1063 | - /** |
|
1064 | - * Gets all number of flight over countries |
|
1065 | - * |
|
1066 | - * @return Array the airline country list |
|
1067 | - * |
|
1068 | - */ |
|
1069 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1070 | - { |
|
1061 | + } |
|
1062 | + |
|
1063 | + /** |
|
1064 | + * Gets all number of flight over countries |
|
1065 | + * |
|
1066 | + * @return Array the airline country list |
|
1067 | + * |
|
1068 | + */ |
|
1069 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1070 | + { |
|
1071 | 1071 | global $globalDBdriver; |
1072 | 1072 | /* |
1073 | 1073 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1077,14 +1077,14 @@ discard block |
||
1077 | 1077 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1078 | 1078 | FROM countries c, spotter_archive s |
1079 | 1079 | WHERE c.iso2 = s.over_country "; |
1080 | - if ($olderthanmonths > 0) { |
|
1081 | - if ($globalDBdriver == 'mysql') { |
|
1080 | + if ($olderthanmonths > 0) { |
|
1081 | + if ($globalDBdriver == 'mysql') { |
|
1082 | 1082 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1083 | 1083 | } else { |
1084 | 1084 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1085 | 1085 | } |
1086 | 1086 | } |
1087 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1087 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1088 | 1088 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1089 | 1089 | if ($limit) $query .= " LIMIT 0,10"; |
1090 | 1090 | |
@@ -1097,23 +1097,23 @@ discard block |
||
1097 | 1097 | |
1098 | 1098 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1099 | 1099 | { |
1100 | - $temp_array['flight_count'] = $row['nb']; |
|
1101 | - $temp_array['flight_country'] = $row['name']; |
|
1102 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1103 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1104 | - $flight_array[] = $temp_array; |
|
1100 | + $temp_array['flight_count'] = $row['nb']; |
|
1101 | + $temp_array['flight_country'] = $row['name']; |
|
1102 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1103 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1104 | + $flight_array[] = $temp_array; |
|
1105 | 1105 | } |
1106 | 1106 | return $flight_array; |
1107 | - } |
|
1108 | - |
|
1109 | - /** |
|
1110 | - * Gets all number of flight over countries |
|
1111 | - * |
|
1112 | - * @return Array the airline country list |
|
1113 | - * |
|
1114 | - */ |
|
1115 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1116 | - { |
|
1107 | + } |
|
1108 | + |
|
1109 | + /** |
|
1110 | + * Gets all number of flight over countries |
|
1111 | + * |
|
1112 | + * @return Array the airline country list |
|
1113 | + * |
|
1114 | + */ |
|
1115 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1116 | + { |
|
1117 | 1117 | global $globalDBdriver; |
1118 | 1118 | /* |
1119 | 1119 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1123,14 +1123,14 @@ discard block |
||
1123 | 1123 | $query = "SELECT s.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1124 | 1124 | FROM countries c, spotter_archive s |
1125 | 1125 | WHERE c.iso2 = s.over_country "; |
1126 | - if ($olderthanmonths > 0) { |
|
1127 | - if ($globalDBdriver == 'mysql') { |
|
1126 | + if ($olderthanmonths > 0) { |
|
1127 | + if ($globalDBdriver == 'mysql') { |
|
1128 | 1128 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1129 | 1129 | } else { |
1130 | 1130 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1131 | 1131 | } |
1132 | 1132 | } |
1133 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1133 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1134 | 1134 | $query .= "GROUP BY s.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1135 | 1135 | if ($limit) $query .= " LIMIT 0,10"; |
1136 | 1136 | |
@@ -1143,24 +1143,24 @@ discard block |
||
1143 | 1143 | |
1144 | 1144 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1145 | 1145 | { |
1146 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1147 | - $temp_array['flight_count'] = $row['nb']; |
|
1148 | - $temp_array['flight_country'] = $row['name']; |
|
1149 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1150 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1151 | - $flight_array[] = $temp_array; |
|
1146 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1147 | + $temp_array['flight_count'] = $row['nb']; |
|
1148 | + $temp_array['flight_country'] = $row['name']; |
|
1149 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1150 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1151 | + $flight_array[] = $temp_array; |
|
1152 | 1152 | } |
1153 | 1153 | return $flight_array; |
1154 | - } |
|
1155 | - |
|
1156 | - /** |
|
1157 | - * Gets last spotter information based on a particular callsign |
|
1158 | - * |
|
1159 | - * @return Array the spotter information |
|
1160 | - * |
|
1161 | - */ |
|
1162 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1163 | - { |
|
1154 | + } |
|
1155 | + |
|
1156 | + /** |
|
1157 | + * Gets last spotter information based on a particular callsign |
|
1158 | + * |
|
1159 | + * @return Array the spotter information |
|
1160 | + * |
|
1161 | + */ |
|
1162 | + public function getDateArchiveSpotterDataById($id,$date) |
|
1163 | + { |
|
1164 | 1164 | $Spotter = new Spotter($this->db); |
1165 | 1165 | date_default_timezone_set('UTC'); |
1166 | 1166 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1168,16 +1168,16 @@ discard block |
||
1168 | 1168 | $date = date('c',$date); |
1169 | 1169 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1170 | 1170 | return $spotter_array; |
1171 | - } |
|
1172 | - |
|
1173 | - /** |
|
1174 | - * Gets all the spotter information based on a particular callsign |
|
1175 | - * |
|
1176 | - * @return Array the spotter information |
|
1177 | - * |
|
1178 | - */ |
|
1179 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1180 | - { |
|
1171 | + } |
|
1172 | + |
|
1173 | + /** |
|
1174 | + * Gets all the spotter information based on a particular callsign |
|
1175 | + * |
|
1176 | + * @return Array the spotter information |
|
1177 | + * |
|
1178 | + */ |
|
1179 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1180 | + { |
|
1181 | 1181 | $Spotter = new Spotter($this->db); |
1182 | 1182 | date_default_timezone_set('UTC'); |
1183 | 1183 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1185,16 +1185,16 @@ discard block |
||
1185 | 1185 | $date = date('c',$date); |
1186 | 1186 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1187 | 1187 | return $spotter_array; |
1188 | - } |
|
1189 | - |
|
1190 | - /** |
|
1191 | - * Gets all the spotter information based on the airport |
|
1192 | - * |
|
1193 | - * @return Array the spotter information |
|
1194 | - * |
|
1195 | - */ |
|
1196 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1197 | - { |
|
1188 | + } |
|
1189 | + |
|
1190 | + /** |
|
1191 | + * Gets all the spotter information based on the airport |
|
1192 | + * |
|
1193 | + * @return Array the spotter information |
|
1194 | + * |
|
1195 | + */ |
|
1196 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1197 | + { |
|
1198 | 1198 | global $global_query; |
1199 | 1199 | $Spotter = new Spotter(); |
1200 | 1200 | date_default_timezone_set('UTC'); |
@@ -1205,35 +1205,35 @@ discard block |
||
1205 | 1205 | |
1206 | 1206 | if ($airport != "") |
1207 | 1207 | { |
1208 | - if (!is_string($airport)) |
|
1209 | - { |
|
1208 | + if (!is_string($airport)) |
|
1209 | + { |
|
1210 | 1210 | return false; |
1211 | - } else { |
|
1211 | + } else { |
|
1212 | 1212 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
1213 | 1213 | $query_values = array(':airport' => $airport); |
1214 | - } |
|
1214 | + } |
|
1215 | 1215 | } |
1216 | 1216 | |
1217 | 1217 | if ($limit != "") |
1218 | 1218 | { |
1219 | - $limit_array = explode(",", $limit); |
|
1219 | + $limit_array = explode(",", $limit); |
|
1220 | 1220 | |
1221 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1222 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1221 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1222 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | 1223 | |
1224 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1225 | - { |
|
1224 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1225 | + { |
|
1226 | 1226 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1227 | 1227 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1228 | - } |
|
1228 | + } |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | if ($sort != "") |
1232 | 1232 | { |
1233 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1234 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1233 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1234 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1235 | 1235 | } else { |
1236 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1236 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1241,6 +1241,6 @@ discard block |
||
1241 | 1241 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1242 | 1242 | |
1243 | 1243 | return $spotter_array; |
1244 | - } |
|
1244 | + } |
|
1245 | 1245 | } |
1246 | 1246 | ?> |
1247 | 1247 | \ No newline at end of file |
@@ -15,33 +15,33 @@ discard block |
||
15 | 15 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
16 | 16 | $Connection = new Connection($dbc); |
17 | 17 | $this->db = $Connection->db(); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function addLastStatsUpdate($type,$stats_date) { |
21 | - $query = "DELETE FROM config WHERE name = :type; |
|
21 | + $query = "DELETE FROM config WHERE name = :type; |
|
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | - try { |
|
25 | - $sth = $this->db->prepare($query); |
|
26 | - $sth->execute($query_values); |
|
27 | - } catch(PDOException $e) { |
|
28 | - return "error : ".$e->getMessage(); |
|
29 | - } |
|
30 | - } |
|
23 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | + try { |
|
25 | + $sth = $this->db->prepare($query); |
|
26 | + $sth->execute($query_values); |
|
27 | + } catch(PDOException $e) { |
|
28 | + return "error : ".$e->getMessage(); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | 32 | public function getLastStatsUpdate($type = 'last_update_stats') { |
33 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | - try { |
|
35 | - $sth = $this->db->prepare($query); |
|
36 | - $sth->execute(array(':type' => $type)); |
|
37 | - } catch(PDOException $e) { |
|
38 | - echo "error : ".$e->getMessage(); |
|
39 | - } |
|
40 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | - return $all; |
|
42 | - } |
|
43 | - public function deleteStats($filter_name = '') { |
|
44 | - /* |
|
33 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | + try { |
|
35 | + $sth = $this->db->prepare($query); |
|
36 | + $sth->execute(array(':type' => $type)); |
|
37 | + } catch(PDOException $e) { |
|
38 | + echo "error : ".$e->getMessage(); |
|
39 | + } |
|
40 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | + return $all; |
|
42 | + } |
|
43 | + public function deleteStats($filter_name = '') { |
|
44 | + /* |
|
45 | 45 | $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
46 | 46 | try { |
47 | 47 | $sth = $this->db->prepare($query); |
@@ -50,106 +50,106 @@ discard block |
||
50 | 50 | return "error : ".$e->getMessage(); |
51 | 51 | } |
52 | 52 | */ |
53 | - $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | - try { |
|
55 | - $sth = $this->db->prepare($query); |
|
56 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | - } catch(PDOException $e) { |
|
58 | - return "error : ".$e->getMessage(); |
|
59 | - } |
|
60 | - } |
|
61 | - public function deleteOldStats($filter_name = '') { |
|
53 | + $query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
54 | + try { |
|
55 | + $sth = $this->db->prepare($query); |
|
56 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
57 | + } catch(PDOException $e) { |
|
58 | + return "error : ".$e->getMessage(); |
|
59 | + } |
|
60 | + } |
|
61 | + public function deleteOldStats($filter_name = '') { |
|
62 | 62 | |
63 | - $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
64 | - try { |
|
65 | - $sth = $this->db->prepare($query); |
|
66 | - $sth->execute(); |
|
67 | - } catch(PDOException $e) { |
|
68 | - return "error : ".$e->getMessage(); |
|
69 | - } |
|
63 | + $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
64 | + try { |
|
65 | + $sth = $this->db->prepare($query); |
|
66 | + $sth->execute(); |
|
67 | + } catch(PDOException $e) { |
|
68 | + return "error : ".$e->getMessage(); |
|
69 | + } |
|
70 | 70 | |
71 | - $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
72 | - try { |
|
73 | - $sth = $this->db->prepare($query); |
|
74 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
75 | - } catch(PDOException $e) { |
|
76 | - return "error : ".$e->getMessage(); |
|
77 | - } |
|
78 | - } |
|
71 | + $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
|
72 | + try { |
|
73 | + $sth = $this->db->prepare($query); |
|
74 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
75 | + } catch(PDOException $e) { |
|
76 | + return "error : ".$e->getMessage(); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | public function getAllAirlineNames($filter_name = '') { |
80 | 80 | if ($filter_name == '') $filter_name = $this->filter_name; |
81 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
82 | - try { |
|
83 | - $sth = $this->db->prepare($query); |
|
84 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
85 | - } catch(PDOException $e) { |
|
86 | - echo "error : ".$e->getMessage(); |
|
87 | - } |
|
88 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
89 | - return $all; |
|
90 | - } |
|
81 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
82 | + try { |
|
83 | + $sth = $this->db->prepare($query); |
|
84 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
85 | + } catch(PDOException $e) { |
|
86 | + echo "error : ".$e->getMessage(); |
|
87 | + } |
|
88 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
89 | + return $all; |
|
90 | + } |
|
91 | 91 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
92 | 92 | if ($filter_name == '') $filter_name = $this->filter_name; |
93 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
94 | - try { |
|
95 | - $sth = $this->db->prepare($query); |
|
96 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | - } catch(PDOException $e) { |
|
98 | - echo "error : ".$e->getMessage(); |
|
99 | - } |
|
100 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
101 | - return $all; |
|
102 | - } |
|
93 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
94 | + try { |
|
95 | + $sth = $this->db->prepare($query); |
|
96 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | + } catch(PDOException $e) { |
|
98 | + echo "error : ".$e->getMessage(); |
|
99 | + } |
|
100 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
101 | + return $all; |
|
102 | + } |
|
103 | 103 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
104 | 104 | if ($filter_name == '') $filter_name = $this->filter_name; |
105 | - $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
106 | - try { |
|
107 | - $sth = $this->db->prepare($query); |
|
108 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | - } catch(PDOException $e) { |
|
110 | - echo "error : ".$e->getMessage(); |
|
111 | - } |
|
112 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
113 | - return $all; |
|
114 | - } |
|
105 | + $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
|
106 | + try { |
|
107 | + $sth = $this->db->prepare($query); |
|
108 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | + } catch(PDOException $e) { |
|
110 | + echo "error : ".$e->getMessage(); |
|
111 | + } |
|
112 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
113 | + return $all; |
|
114 | + } |
|
115 | 115 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
116 | 116 | if ($filter_name == '') $filter_name = $this->filter_name; |
117 | - $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
118 | - try { |
|
119 | - $sth = $this->db->prepare($query); |
|
120 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | - } catch(PDOException $e) { |
|
122 | - echo "error : ".$e->getMessage(); |
|
123 | - } |
|
124 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
125 | - return $all; |
|
126 | - } |
|
117 | + $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
118 | + try { |
|
119 | + $sth = $this->db->prepare($query); |
|
120 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | + } catch(PDOException $e) { |
|
122 | + echo "error : ".$e->getMessage(); |
|
123 | + } |
|
124 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
125 | + return $all; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
129 | 129 | if ($filter_name == '') $filter_name = $this->filter_name; |
130 | - $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
|
131 | - try { |
|
132 | - $sth = $this->db->prepare($query); |
|
133 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
134 | - } catch(PDOException $e) { |
|
135 | - echo "error : ".$e->getMessage(); |
|
136 | - } |
|
137 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
138 | - return $all; |
|
139 | - } |
|
130 | + $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
|
131 | + try { |
|
132 | + $sth = $this->db->prepare($query); |
|
133 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
134 | + } catch(PDOException $e) { |
|
135 | + echo "error : ".$e->getMessage(); |
|
136 | + } |
|
137 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
138 | + return $all; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
142 | 142 | if ($filter_name == '') $filter_name = $this->filter_name; |
143 | - $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
|
144 | - try { |
|
145 | - $sth = $this->db->prepare($query); |
|
146 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
147 | - } catch(PDOException $e) { |
|
148 | - echo "error : ".$e->getMessage(); |
|
149 | - } |
|
150 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
151 | - return $all; |
|
152 | - } |
|
143 | + $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
|
144 | + try { |
|
145 | + $sth = $this->db->prepare($query); |
|
146 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
147 | + } catch(PDOException $e) { |
|
148 | + echo "error : ".$e->getMessage(); |
|
149 | + } |
|
150 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
151 | + return $all; |
|
152 | + } |
|
153 | 153 | |
154 | 154 | |
155 | 155 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | } |
167 | 167 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
168 | 168 | } else $all = array(); |
169 | - if (empty($all)) { |
|
170 | - $filters = array('airlines' => array($stats_airline)); |
|
171 | - if ($filter_name != '') { |
|
172 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
173 | - } |
|
174 | - $Spotter = new Spotter($this->db); |
|
175 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
176 | - } |
|
177 | - return $all; |
|
169 | + if (empty($all)) { |
|
170 | + $filters = array('airlines' => array($stats_airline)); |
|
171 | + if ($filter_name != '') { |
|
172 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
173 | + } |
|
174 | + $Spotter = new Spotter($this->db); |
|
175 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
176 | + } |
|
177 | + return $all; |
|
178 | 178 | } |
179 | 179 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
180 | 180 | global $globalStatsFilters; |
@@ -190,15 +190,15 @@ discard block |
||
190 | 190 | } |
191 | 191 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
192 | 192 | } else $all = array(); |
193 | - if (empty($all)) { |
|
194 | - $Spotter = new Spotter($this->db); |
|
195 | - $filters = array(); |
|
196 | - if ($filter_name != '') { |
|
197 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
193 | + if (empty($all)) { |
|
194 | + $Spotter = new Spotter($this->db); |
|
195 | + $filters = array(); |
|
196 | + if ($filter_name != '') { |
|
197 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
198 | 198 | } |
199 | - $all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
200 | - } |
|
201 | - return $all; |
|
199 | + $all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
200 | + } |
|
201 | + return $all; |
|
202 | 202 | } |
203 | 203 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
204 | 204 | global $globalStatsFilters; |
@@ -239,37 +239,37 @@ discard block |
||
239 | 239 | } |
240 | 240 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
241 | 241 | } else $all = array(); |
242 | - if (empty($all)) { |
|
242 | + if (empty($all)) { |
|
243 | 243 | $filters = array('airlines' => array($stats_airline)); |
244 | 244 | if ($filter_name != '') { |
245 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
245 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
246 | 246 | } |
247 | 247 | $Spotter = new Spotter($this->db); |
248 | 248 | $all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
249 | - } |
|
250 | - return $all; |
|
249 | + } |
|
250 | + return $all; |
|
251 | 251 | } |
252 | 252 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
253 | 253 | global $globalStatsFilters; |
254 | 254 | if ($filter_name == '') $filter_name = $this->filter_name; |
255 | 255 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
256 | 256 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
257 | - try { |
|
258 | - $sth = $this->db->prepare($query); |
|
259 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
260 | - } catch(PDOException $e) { |
|
261 | - echo "error : ".$e->getMessage(); |
|
262 | - } |
|
263 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
264 | - if (empty($all)) { |
|
257 | + try { |
|
258 | + $sth = $this->db->prepare($query); |
|
259 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
260 | + } catch(PDOException $e) { |
|
261 | + echo "error : ".$e->getMessage(); |
|
262 | + } |
|
263 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
264 | + if (empty($all)) { |
|
265 | 265 | $filters = array('airlines' => array($stats_airline)); |
266 | 266 | if ($filter_name != '') { |
267 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
267 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
268 | 268 | } |
269 | 269 | $Spotter = new Spotter($this->db); |
270 | 270 | $all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
271 | - } |
|
272 | - return $all; |
|
271 | + } |
|
272 | + return $all; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
@@ -286,16 +286,16 @@ discard block |
||
286 | 286 | } |
287 | 287 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
288 | 288 | } else $all = array(); |
289 | - if (empty($all)) { |
|
290 | - $Spotter = new Spotter($this->db); |
|
291 | - $filters = array(); |
|
292 | - if ($filter_name != '') { |
|
293 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
289 | + if (empty($all)) { |
|
290 | + $Spotter = new Spotter($this->db); |
|
291 | + $filters = array(); |
|
292 | + if ($filter_name != '') { |
|
293 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
294 | 294 | } |
295 | 295 | |
296 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
|
297 | - } |
|
298 | - return $all; |
|
296 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
|
297 | + } |
|
298 | + return $all; |
|
299 | 299 | } |
300 | 300 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
301 | 301 | global $globalStatsFilters; |
@@ -311,15 +311,15 @@ discard block |
||
311 | 311 | } |
312 | 312 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
313 | 313 | } else $all = array(); |
314 | - if (empty($all)) { |
|
314 | + if (empty($all)) { |
|
315 | 315 | $filters = array('airlines' => array($stats_airline)); |
316 | 316 | if ($filter_name != '') { |
317 | 317 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
318 | 318 | } |
319 | - $Spotter = new Spotter($this->db); |
|
320 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
321 | - } |
|
322 | - return $all; |
|
319 | + $Spotter = new Spotter($this->db); |
|
320 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
321 | + } |
|
322 | + return $all; |
|
323 | 323 | } |
324 | 324 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
325 | 325 | global $globalStatsFilters; |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | echo "error : ".$e->getMessage(); |
360 | 360 | } |
361 | 361 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
362 | - /* |
|
362 | + /* |
|
363 | 363 | if (empty($all)) { |
364 | 364 | $Spotter = new Spotter($this->db); |
365 | 365 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -410,15 +410,15 @@ discard block |
||
410 | 410 | } |
411 | 411 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
412 | 412 | } else $all = array(); |
413 | - if (empty($all)) { |
|
413 | + if (empty($all)) { |
|
414 | 414 | $filters = array('airlines' => array($stats_airline)); |
415 | 415 | if ($filter_name != '') { |
416 | 416 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
417 | 417 | } |
418 | - $Spotter = new Spotter($this->db); |
|
419 | - $all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
420 | - } |
|
421 | - return $all; |
|
418 | + $Spotter = new Spotter($this->db); |
|
419 | + $all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
420 | + } |
|
421 | + return $all; |
|
422 | 422 | } |
423 | 423 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
424 | 424 | global $globalStatsFilters; |
@@ -434,33 +434,33 @@ discard block |
||
434 | 434 | } |
435 | 435 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
436 | 436 | } else $all = array(); |
437 | - if (empty($all)) { |
|
437 | + if (empty($all)) { |
|
438 | 438 | $filters = array('airlines' => array($stats_airline)); |
439 | - if ($filter_name != '') { |
|
440 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
441 | - } |
|
442 | - $Spotter = new Spotter($this->db); |
|
443 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
|
444 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
|
445 | - $all = array(); |
|
446 | - foreach ($pall as $value) { |
|
447 | - $icao = $value['airport_departure_icao']; |
|
448 | - $all[$icao] = $value; |
|
449 | - } |
|
439 | + if ($filter_name != '') { |
|
440 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
441 | + } |
|
442 | + $Spotter = new Spotter($this->db); |
|
443 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
|
444 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
|
445 | + $all = array(); |
|
446 | + foreach ($pall as $value) { |
|
447 | + $icao = $value['airport_departure_icao']; |
|
448 | + $all[$icao] = $value; |
|
449 | + } |
|
450 | 450 | |
451 | - foreach ($dall as $value) { |
|
452 | - $icao = $value['airport_departure_icao']; |
|
453 | - if (isset($all[$icao])) { |
|
454 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
455 | - } else $all[$icao] = $value; |
|
456 | - } |
|
457 | - $count = array(); |
|
458 | - foreach ($all as $key => $row) { |
|
459 | - $count[$key] = $row['airport_departure_icao_count']; |
|
460 | - } |
|
461 | - array_multisort($count,SORT_DESC,$all); |
|
462 | - } |
|
463 | - return $all; |
|
451 | + foreach ($dall as $value) { |
|
452 | + $icao = $value['airport_departure_icao']; |
|
453 | + if (isset($all[$icao])) { |
|
454 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
455 | + } else $all[$icao] = $value; |
|
456 | + } |
|
457 | + $count = array(); |
|
458 | + foreach ($all as $key => $row) { |
|
459 | + $count[$key] = $row['airport_departure_icao_count']; |
|
460 | + } |
|
461 | + array_multisort($count,SORT_DESC,$all); |
|
462 | + } |
|
463 | + return $all; |
|
464 | 464 | } |
465 | 465 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
466 | 466 | global $globalStatsFilters; |
@@ -484,26 +484,26 @@ discard block |
||
484 | 484 | $Spotter = new Spotter($this->db); |
485 | 485 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
486 | 486 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
487 | - $all = array(); |
|
488 | - foreach ($pall as $value) { |
|
489 | - $icao = $value['airport_arrival_icao']; |
|
490 | - $all[$icao] = $value; |
|
491 | - } |
|
487 | + $all = array(); |
|
488 | + foreach ($pall as $value) { |
|
489 | + $icao = $value['airport_arrival_icao']; |
|
490 | + $all[$icao] = $value; |
|
491 | + } |
|
492 | 492 | |
493 | - foreach ($dall as $value) { |
|
494 | - $icao = $value['airport_arrival_icao']; |
|
495 | - if (isset($all[$icao])) { |
|
496 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
497 | - } else $all[$icao] = $value; |
|
498 | - } |
|
499 | - $count = array(); |
|
500 | - foreach ($all as $key => $row) { |
|
501 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
502 | - } |
|
503 | - array_multisort($count,SORT_DESC,$all); |
|
504 | - } |
|
493 | + foreach ($dall as $value) { |
|
494 | + $icao = $value['airport_arrival_icao']; |
|
495 | + if (isset($all[$icao])) { |
|
496 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
497 | + } else $all[$icao] = $value; |
|
498 | + } |
|
499 | + $count = array(); |
|
500 | + foreach ($all as $key => $row) { |
|
501 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
502 | + } |
|
503 | + array_multisort($count,SORT_DESC,$all); |
|
504 | + } |
|
505 | 505 | |
506 | - return $all; |
|
506 | + return $all; |
|
507 | 507 | } |
508 | 508 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
509 | 509 | global $globalDBdriver, $globalStatsFilters; |
@@ -516,23 +516,23 @@ discard block |
||
516 | 516 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
517 | 517 | } |
518 | 518 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
519 | - try { |
|
520 | - $sth = $this->db->prepare($query); |
|
521 | - $sth->execute($query_data); |
|
522 | - } catch(PDOException $e) { |
|
523 | - echo "error : ".$e->getMessage(); |
|
524 | - } |
|
525 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
526 | - if (empty($all)) { |
|
519 | + try { |
|
520 | + $sth = $this->db->prepare($query); |
|
521 | + $sth->execute($query_data); |
|
522 | + } catch(PDOException $e) { |
|
523 | + echo "error : ".$e->getMessage(); |
|
524 | + } |
|
525 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
526 | + if (empty($all)) { |
|
527 | 527 | $filters = array('airlines' => array($stats_airline)); |
528 | 528 | if ($filter_name != '') { |
529 | 529 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
530 | 530 | } |
531 | - $Spotter = new Spotter($this->db); |
|
532 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
533 | - } |
|
531 | + $Spotter = new Spotter($this->db); |
|
532 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
533 | + } |
|
534 | 534 | |
535 | - return $all; |
|
535 | + return $all; |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -540,22 +540,22 @@ discard block |
||
540 | 540 | if ($filter_name == '') $filter_name = $this->filter_name; |
541 | 541 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
542 | 542 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
543 | - try { |
|
544 | - $sth = $this->db->prepare($query); |
|
545 | - $sth->execute($query_data); |
|
546 | - } catch(PDOException $e) { |
|
547 | - echo "error : ".$e->getMessage(); |
|
548 | - } |
|
549 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
550 | - if (empty($all)) { |
|
543 | + try { |
|
544 | + $sth = $this->db->prepare($query); |
|
545 | + $sth->execute($query_data); |
|
546 | + } catch(PDOException $e) { |
|
547 | + echo "error : ".$e->getMessage(); |
|
548 | + } |
|
549 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
550 | + if (empty($all)) { |
|
551 | 551 | $filters = array('airlines' => array($stats_airline)); |
552 | 552 | if ($filter_name != '') { |
553 | 553 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
554 | 554 | } |
555 | - $Spotter = new Spotter($this->db); |
|
556 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
557 | - } |
|
558 | - return $all; |
|
555 | + $Spotter = new Spotter($this->db); |
|
556 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
557 | + } |
|
558 | + return $all; |
|
559 | 559 | } |
560 | 560 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
561 | 561 | global $globalDBdriver, $globalStatsFilters; |
@@ -566,110 +566,110 @@ discard block |
||
566 | 566 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
567 | 567 | } |
568 | 568 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
569 | - try { |
|
570 | - $sth = $this->db->prepare($query); |
|
571 | - $sth->execute($query_data); |
|
572 | - } catch(PDOException $e) { |
|
573 | - echo "error : ".$e->getMessage(); |
|
574 | - } |
|
575 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
576 | - if (empty($all)) { |
|
569 | + try { |
|
570 | + $sth = $this->db->prepare($query); |
|
571 | + $sth->execute($query_data); |
|
572 | + } catch(PDOException $e) { |
|
573 | + echo "error : ".$e->getMessage(); |
|
574 | + } |
|
575 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
576 | + if (empty($all)) { |
|
577 | 577 | $filters = array('airlines' => array($stats_airline)); |
578 | 578 | if ($filter_name != '') { |
579 | 579 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
580 | 580 | } |
581 | - $Spotter = new Spotter($this->db); |
|
582 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
583 | - } |
|
584 | - return $all; |
|
581 | + $Spotter = new Spotter($this->db); |
|
582 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
583 | + } |
|
584 | + return $all; |
|
585 | 585 | } |
586 | 586 | public function countAllDates($stats_airline = '',$filter_name = '') { |
587 | 587 | global $globalStatsFilters; |
588 | 588 | if ($filter_name == '') $filter_name = $this->filter_name; |
589 | 589 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
590 | 590 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
591 | - try { |
|
592 | - $sth = $this->db->prepare($query); |
|
593 | - $sth->execute($query_data); |
|
594 | - } catch(PDOException $e) { |
|
595 | - echo "error : ".$e->getMessage(); |
|
596 | - } |
|
597 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
598 | - if (empty($all)) { |
|
591 | + try { |
|
592 | + $sth = $this->db->prepare($query); |
|
593 | + $sth->execute($query_data); |
|
594 | + } catch(PDOException $e) { |
|
595 | + echo "error : ".$e->getMessage(); |
|
596 | + } |
|
597 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
598 | + if (empty($all)) { |
|
599 | 599 | $filters = array('airlines' => array($stats_airline)); |
600 | 600 | if ($filter_name != '') { |
601 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
601 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
602 | 602 | } |
603 | - $Spotter = new Spotter($this->db); |
|
604 | - $all = $Spotter->countAllDates($filters); |
|
605 | - } |
|
606 | - return $all; |
|
603 | + $Spotter = new Spotter($this->db); |
|
604 | + $all = $Spotter->countAllDates($filters); |
|
605 | + } |
|
606 | + return $all; |
|
607 | 607 | } |
608 | 608 | public function countAllDatesByAirlines($filter_name = '') { |
609 | 609 | global $globalStatsFilters; |
610 | 610 | if ($filter_name == '') $filter_name = $this->filter_name; |
611 | 611 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
612 | 612 | $query_data = array('filter_name' => $filter_name); |
613 | - try { |
|
614 | - $sth = $this->db->prepare($query); |
|
615 | - $sth->execute($query_data); |
|
616 | - } catch(PDOException $e) { |
|
617 | - echo "error : ".$e->getMessage(); |
|
618 | - } |
|
619 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
620 | - if (empty($all)) { |
|
621 | - $filters = array(); |
|
622 | - if ($filter_name != '') { |
|
623 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
613 | + try { |
|
614 | + $sth = $this->db->prepare($query); |
|
615 | + $sth->execute($query_data); |
|
616 | + } catch(PDOException $e) { |
|
617 | + echo "error : ".$e->getMessage(); |
|
618 | + } |
|
619 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
620 | + if (empty($all)) { |
|
621 | + $filters = array(); |
|
622 | + if ($filter_name != '') { |
|
623 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
624 | 624 | } |
625 | - $Spotter = new Spotter($this->db); |
|
626 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
627 | - } |
|
628 | - return $all; |
|
625 | + $Spotter = new Spotter($this->db); |
|
626 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
627 | + } |
|
628 | + return $all; |
|
629 | 629 | } |
630 | 630 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
631 | 631 | global $globalStatsFilters; |
632 | 632 | if ($filter_name == '') $filter_name = $this->filter_name; |
633 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
634 | - try { |
|
635 | - $sth = $this->db->prepare($query); |
|
636 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
637 | - } catch(PDOException $e) { |
|
638 | - echo "error : ".$e->getMessage(); |
|
639 | - } |
|
640 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
633 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
634 | + try { |
|
635 | + $sth = $this->db->prepare($query); |
|
636 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
637 | + } catch(PDOException $e) { |
|
638 | + echo "error : ".$e->getMessage(); |
|
639 | + } |
|
640 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
641 | 641 | |
642 | - if (empty($all)) { |
|
642 | + if (empty($all)) { |
|
643 | 643 | $filters = array('airlines' => array($stats_airline)); |
644 | 644 | if ($filter_name != '') { |
645 | 645 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
646 | 646 | } |
647 | - $Spotter = new Spotter($this->db); |
|
648 | - $all = $Spotter->countAllMonths($filters); |
|
649 | - } |
|
647 | + $Spotter = new Spotter($this->db); |
|
648 | + $all = $Spotter->countAllMonths($filters); |
|
649 | + } |
|
650 | 650 | |
651 | - return $all; |
|
651 | + return $all; |
|
652 | 652 | } |
653 | 653 | public function countAllMilitaryMonths($filter_name = '') { |
654 | 654 | global $globalStatsFilters; |
655 | 655 | if ($filter_name == '') $filter_name = $this->filter_name; |
656 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
657 | - try { |
|
658 | - $sth = $this->db->prepare($query); |
|
659 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
660 | - } catch(PDOException $e) { |
|
661 | - echo "error : ".$e->getMessage(); |
|
662 | - } |
|
663 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
664 | - if (empty($all)) { |
|
665 | - $filters = array(); |
|
666 | - if ($filter_name != '') { |
|
667 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
656 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
657 | + try { |
|
658 | + $sth = $this->db->prepare($query); |
|
659 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
660 | + } catch(PDOException $e) { |
|
661 | + echo "error : ".$e->getMessage(); |
|
662 | + } |
|
663 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
664 | + if (empty($all)) { |
|
665 | + $filters = array(); |
|
666 | + if ($filter_name != '') { |
|
667 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
668 | 668 | } |
669 | - $Spotter = new Spotter($this->db); |
|
670 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
671 | - } |
|
672 | - return $all; |
|
669 | + $Spotter = new Spotter($this->db); |
|
670 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
671 | + } |
|
672 | + return $all; |
|
673 | 673 | } |
674 | 674 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
675 | 675 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -685,22 +685,22 @@ discard block |
||
685 | 685 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
686 | 686 | } |
687 | 687 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
688 | - try { |
|
689 | - $sth = $this->db->prepare($query); |
|
690 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
691 | - } catch(PDOException $e) { |
|
692 | - echo "error : ".$e->getMessage(); |
|
693 | - } |
|
694 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
695 | - if (empty($all)) { |
|
688 | + try { |
|
689 | + $sth = $this->db->prepare($query); |
|
690 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
691 | + } catch(PDOException $e) { |
|
692 | + echo "error : ".$e->getMessage(); |
|
693 | + } |
|
694 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
695 | + if (empty($all)) { |
|
696 | 696 | $filters = array('airlines' => array($stats_airline)); |
697 | 697 | if ($filter_name != '') { |
698 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
698 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
699 | 699 | } |
700 | - $Spotter = new Spotter($this->db); |
|
701 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
702 | - } |
|
703 | - return $all; |
|
700 | + $Spotter = new Spotter($this->db); |
|
701 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
702 | + } |
|
703 | + return $all; |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
@@ -724,9 +724,9 @@ discard block |
||
724 | 724 | if ($year == '') $year = date('Y'); |
725 | 725 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
726 | 726 | if (empty($all)) { |
727 | - $filters = array(); |
|
728 | - if ($filter_name != '') { |
|
729 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
727 | + $filters = array(); |
|
728 | + if ($filter_name != '') { |
|
729 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
730 | 730 | } |
731 | 731 | $Spotter = new Spotter($this->db); |
732 | 732 | $all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -778,9 +778,9 @@ discard block |
||
778 | 778 | $all = $result[0]['nb_airline']; |
779 | 779 | } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
780 | 780 | if (empty($all)) { |
781 | - $filters = array(); |
|
782 | - if ($filter_name != '') { |
|
783 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
781 | + $filters = array(); |
|
782 | + if ($filter_name != '') { |
|
783 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
784 | 784 | } |
785 | 785 | $Spotter = new Spotter($this->db); |
786 | 786 | $all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -833,33 +833,33 @@ discard block |
||
833 | 833 | if ($filter_name == '') $filter_name = $this->filter_name; |
834 | 834 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
835 | 835 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
836 | - try { |
|
837 | - $sth = $this->db->prepare($query); |
|
838 | - $sth->execute($query_values); |
|
839 | - } catch(PDOException $e) { |
|
840 | - echo "error : ".$e->getMessage(); |
|
841 | - } |
|
842 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
843 | - return $all; |
|
836 | + try { |
|
837 | + $sth = $this->db->prepare($query); |
|
838 | + $sth->execute($query_values); |
|
839 | + } catch(PDOException $e) { |
|
840 | + echo "error : ".$e->getMessage(); |
|
841 | + } |
|
842 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
843 | + return $all; |
|
844 | 844 | } |
845 | 845 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
846 | 846 | if ($filter_name == '') $filter_name = $this->filter_name; |
847 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
848 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
849 | - try { |
|
850 | - $sth = $this->db->prepare($query); |
|
851 | - $sth->execute($query_values); |
|
852 | - } catch(PDOException $e) { |
|
853 | - echo "error : ".$e->getMessage(); |
|
854 | - } |
|
855 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
856 | - return $all; |
|
857 | - } |
|
847 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
848 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
849 | + try { |
|
850 | + $sth = $this->db->prepare($query); |
|
851 | + $sth->execute($query_values); |
|
852 | + } catch(PDOException $e) { |
|
853 | + echo "error : ".$e->getMessage(); |
|
854 | + } |
|
855 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
856 | + return $all; |
|
857 | + } |
|
858 | 858 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
859 | 859 | if ($filter_name == '') $filter_name = $this->filter_name; |
860 | - global $globalArchiveMonths, $globalDBdriver; |
|
861 | - if ($globalDBdriver == 'mysql') { |
|
862 | - if ($month == '') { |
|
860 | + global $globalArchiveMonths, $globalDBdriver; |
|
861 | + if ($globalDBdriver == 'mysql') { |
|
862 | + if ($month == '') { |
|
863 | 863 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
864 | 864 | $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
865 | 865 | } else { |
@@ -874,137 +874,137 @@ discard block |
||
874 | 874 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
875 | 875 | $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
876 | 876 | } |
877 | - } |
|
878 | - try { |
|
879 | - $sth = $this->db->prepare($query); |
|
880 | - $sth->execute($query_values); |
|
881 | - } catch(PDOException $e) { |
|
882 | - echo "error : ".$e->getMessage(); |
|
883 | - } |
|
884 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
885 | - return $all[0]['total']; |
|
886 | - } |
|
877 | + } |
|
878 | + try { |
|
879 | + $sth = $this->db->prepare($query); |
|
880 | + $sth->execute($query_values); |
|
881 | + } catch(PDOException $e) { |
|
882 | + echo "error : ".$e->getMessage(); |
|
883 | + } |
|
884 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
885 | + return $all[0]['total']; |
|
886 | + } |
|
887 | 887 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
888 | - global $globalArchiveMonths, $globalDBdriver; |
|
888 | + global $globalArchiveMonths, $globalDBdriver; |
|
889 | 889 | if ($filter_name == '') $filter_name = $this->filter_name; |
890 | - if ($globalDBdriver == 'mysql') { |
|
890 | + if ($globalDBdriver == 'mysql') { |
|
891 | 891 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
892 | 892 | } else { |
893 | 893 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
894 | - } |
|
895 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
896 | - try { |
|
897 | - $sth = $this->db->prepare($query); |
|
898 | - $sth->execute($query_values); |
|
899 | - } catch(PDOException $e) { |
|
900 | - echo "error : ".$e->getMessage(); |
|
901 | - } |
|
902 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
903 | - return $all[0]['total']; |
|
904 | - } |
|
894 | + } |
|
895 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
896 | + try { |
|
897 | + $sth = $this->db->prepare($query); |
|
898 | + $sth->execute($query_values); |
|
899 | + } catch(PDOException $e) { |
|
900 | + echo "error : ".$e->getMessage(); |
|
901 | + } |
|
902 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
903 | + return $all[0]['total']; |
|
904 | + } |
|
905 | 905 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
906 | - global $globalArchiveMonths, $globalDBdriver; |
|
906 | + global $globalArchiveMonths, $globalDBdriver; |
|
907 | 907 | if ($filter_name == '') $filter_name = $this->filter_name; |
908 | - if ($globalDBdriver == 'mysql') { |
|
908 | + if ($globalDBdriver == 'mysql') { |
|
909 | 909 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
910 | - } else { |
|
910 | + } else { |
|
911 | 911 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
912 | - } |
|
913 | - try { |
|
914 | - $sth = $this->db->prepare($query); |
|
915 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
916 | - } catch(PDOException $e) { |
|
917 | - echo "error : ".$e->getMessage(); |
|
918 | - } |
|
919 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
920 | - return $all[0]['total']; |
|
921 | - } |
|
912 | + } |
|
913 | + try { |
|
914 | + $sth = $this->db->prepare($query); |
|
915 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
916 | + } catch(PDOException $e) { |
|
917 | + echo "error : ".$e->getMessage(); |
|
918 | + } |
|
919 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
920 | + return $all[0]['total']; |
|
921 | + } |
|
922 | 922 | public function getStatsAirlineTotal($filter_name = '') { |
923 | - global $globalArchiveMonths, $globalDBdriver; |
|
923 | + global $globalArchiveMonths, $globalDBdriver; |
|
924 | 924 | if ($filter_name == '') $filter_name = $this->filter_name; |
925 | - if ($globalDBdriver == 'mysql') { |
|
925 | + if ($globalDBdriver == 'mysql') { |
|
926 | 926 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
927 | - } else { |
|
927 | + } else { |
|
928 | 928 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
929 | - } |
|
930 | - try { |
|
931 | - $sth = $this->db->prepare($query); |
|
932 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
933 | - } catch(PDOException $e) { |
|
934 | - echo "error : ".$e->getMessage(); |
|
935 | - } |
|
936 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
937 | - return $all[0]['total']; |
|
938 | - } |
|
929 | + } |
|
930 | + try { |
|
931 | + $sth = $this->db->prepare($query); |
|
932 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
933 | + } catch(PDOException $e) { |
|
934 | + echo "error : ".$e->getMessage(); |
|
935 | + } |
|
936 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
937 | + return $all[0]['total']; |
|
938 | + } |
|
939 | 939 | public function getStatsOwnerTotal($filter_name = '') { |
940 | - global $globalArchiveMonths, $globalDBdriver; |
|
940 | + global $globalArchiveMonths, $globalDBdriver; |
|
941 | 941 | if ($filter_name == '') $filter_name = $this->filter_name; |
942 | - if ($globalDBdriver == 'mysql') { |
|
942 | + if ($globalDBdriver == 'mysql') { |
|
943 | 943 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
944 | 944 | } else { |
945 | 945 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
946 | - } |
|
947 | - try { |
|
948 | - $sth = $this->db->prepare($query); |
|
949 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
950 | - } catch(PDOException $e) { |
|
951 | - echo "error : ".$e->getMessage(); |
|
952 | - } |
|
953 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
954 | - return $all[0]['total']; |
|
955 | - } |
|
946 | + } |
|
947 | + try { |
|
948 | + $sth = $this->db->prepare($query); |
|
949 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
950 | + } catch(PDOException $e) { |
|
951 | + echo "error : ".$e->getMessage(); |
|
952 | + } |
|
953 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
954 | + return $all[0]['total']; |
|
955 | + } |
|
956 | 956 | public function getStatsPilotTotal($filter_name = '') { |
957 | - global $globalArchiveMonths, $globalDBdriver; |
|
957 | + global $globalArchiveMonths, $globalDBdriver; |
|
958 | 958 | if ($filter_name == '') $filter_name = $this->filter_name; |
959 | - if ($globalDBdriver == 'mysql') { |
|
960 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
961 | - } else { |
|
962 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
963 | - } |
|
964 | - try { |
|
965 | - $sth = $this->db->prepare($query); |
|
966 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
967 | - } catch(PDOException $e) { |
|
968 | - echo "error : ".$e->getMessage(); |
|
969 | - } |
|
970 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
971 | - return $all[0]['total']; |
|
972 | - } |
|
959 | + if ($globalDBdriver == 'mysql') { |
|
960 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
961 | + } else { |
|
962 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
963 | + } |
|
964 | + try { |
|
965 | + $sth = $this->db->prepare($query); |
|
966 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
967 | + } catch(PDOException $e) { |
|
968 | + echo "error : ".$e->getMessage(); |
|
969 | + } |
|
970 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
971 | + return $all[0]['total']; |
|
972 | + } |
|
973 | 973 | |
974 | 974 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
975 | 975 | global $globalDBdriver; |
976 | 976 | if ($filter_name == '') $filter_name = $this->filter_name; |
977 | 977 | if ($globalDBdriver == 'mysql') { |
978 | 978 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
979 | - } else { |
|
979 | + } else { |
|
980 | 980 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
981 | 981 | } |
982 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
983 | - try { |
|
984 | - $sth = $this->db->prepare($query); |
|
985 | - $sth->execute($query_values); |
|
986 | - } catch(PDOException $e) { |
|
987 | - return "error : ".$e->getMessage(); |
|
988 | - } |
|
989 | - } |
|
982 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
983 | + try { |
|
984 | + $sth = $this->db->prepare($query); |
|
985 | + $sth->execute($query_values); |
|
986 | + } catch(PDOException $e) { |
|
987 | + return "error : ".$e->getMessage(); |
|
988 | + } |
|
989 | + } |
|
990 | 990 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
991 | 991 | global $globalDBdriver; |
992 | 992 | if ($filter_name == '') $filter_name = $this->filter_name; |
993 | 993 | if ($globalDBdriver == 'mysql') { |
994 | 994 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
995 | 995 | } else { |
996 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
996 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
997 | 997 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
998 | - } |
|
999 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1000 | - try { |
|
1001 | - $sth = $this->db->prepare($query); |
|
1002 | - $sth->execute($query_values); |
|
1003 | - } catch(PDOException $e) { |
|
1004 | - return "error : ".$e->getMessage(); |
|
1005 | - } |
|
1006 | - } |
|
1007 | - /* |
|
998 | + } |
|
999 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1000 | + try { |
|
1001 | + $sth = $this->db->prepare($query); |
|
1002 | + $sth->execute($query_values); |
|
1003 | + } catch(PDOException $e) { |
|
1004 | + return "error : ".$e->getMessage(); |
|
1005 | + } |
|
1006 | + } |
|
1007 | + /* |
|
1008 | 1008 | public function getStatsSource($date,$stats_type = '') { |
1009 | 1009 | if ($stats_type == '') { |
1010 | 1010 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -1073,25 +1073,25 @@ discard block |
||
1073 | 1073 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
1074 | 1074 | } else { |
1075 | 1075 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
1076 | - } |
|
1077 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1078 | - try { |
|
1079 | - $sth = $this->db->prepare($query); |
|
1080 | - $sth->execute($query_values); |
|
1081 | - } catch(PDOException $e) { |
|
1082 | - return "error : ".$e->getMessage(); |
|
1083 | - } |
|
1084 | - } |
|
1085 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1086 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
1087 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1088 | - try { |
|
1089 | - $sth = $this->db->prepare($query); |
|
1090 | - $sth->execute($query_values); |
|
1091 | - } catch(PDOException $e) { |
|
1092 | - return "error : ".$e->getMessage(); |
|
1093 | - } |
|
1094 | - } |
|
1076 | + } |
|
1077 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1078 | + try { |
|
1079 | + $sth = $this->db->prepare($query); |
|
1080 | + $sth->execute($query_values); |
|
1081 | + } catch(PDOException $e) { |
|
1082 | + return "error : ".$e->getMessage(); |
|
1083 | + } |
|
1084 | + } |
|
1085 | + public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1086 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
1087 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1088 | + try { |
|
1089 | + $sth = $this->db->prepare($query); |
|
1090 | + $sth->execute($query_values); |
|
1091 | + } catch(PDOException $e) { |
|
1092 | + return "error : ".$e->getMessage(); |
|
1093 | + } |
|
1094 | + } |
|
1095 | 1095 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
1096 | 1096 | global $globalDBdriver; |
1097 | 1097 | if ($globalDBdriver == 'mysql') { |
@@ -1107,14 +1107,14 @@ discard block |
||
1107 | 1107 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1108 | 1108 | } |
1109 | 1109 | } |
1110 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1111 | - try { |
|
1112 | - $sth = $this->db->prepare($query); |
|
1113 | - $sth->execute($query_values); |
|
1114 | - } catch(PDOException $e) { |
|
1115 | - return "error : ".$e->getMessage(); |
|
1116 | - } |
|
1117 | - } |
|
1110 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1111 | + try { |
|
1112 | + $sth = $this->db->prepare($query); |
|
1113 | + $sth->execute($query_values); |
|
1114 | + } catch(PDOException $e) { |
|
1115 | + return "error : ".$e->getMessage(); |
|
1116 | + } |
|
1117 | + } |
|
1118 | 1118 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | if ($globalDBdriver == 'mysql') { |
@@ -1130,14 +1130,14 @@ discard block |
||
1130 | 1130 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1131 | 1131 | } |
1132 | 1132 | } |
1133 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1134 | - try { |
|
1135 | - $sth = $this->db->prepare($query); |
|
1136 | - $sth->execute($query_values); |
|
1137 | - } catch(PDOException $e) { |
|
1138 | - return "error : ".$e->getMessage(); |
|
1139 | - } |
|
1140 | - } |
|
1133 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1134 | + try { |
|
1135 | + $sth = $this->db->prepare($query); |
|
1136 | + $sth->execute($query_values); |
|
1137 | + } catch(PDOException $e) { |
|
1138 | + return "error : ".$e->getMessage(); |
|
1139 | + } |
|
1140 | + } |
|
1141 | 1141 | public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
1142 | 1142 | global $globalDBdriver; |
1143 | 1143 | if ($globalDBdriver == 'mysql') { |
@@ -1153,14 +1153,14 @@ discard block |
||
1153 | 1153 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
1154 | 1154 | } |
1155 | 1155 | } |
1156 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1157 | - try { |
|
1158 | - $sth = $this->db->prepare($query); |
|
1159 | - $sth->execute($query_values); |
|
1160 | - } catch(PDOException $e) { |
|
1161 | - return "error : ".$e->getMessage(); |
|
1162 | - } |
|
1163 | - } |
|
1156 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1157 | + try { |
|
1158 | + $sth = $this->db->prepare($query); |
|
1159 | + $sth->execute($query_values); |
|
1160 | + } catch(PDOException $e) { |
|
1161 | + return "error : ".$e->getMessage(); |
|
1162 | + } |
|
1163 | + } |
|
1164 | 1164 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
1165 | 1165 | global $globalDBdriver; |
1166 | 1166 | if ($globalDBdriver == 'mysql') { |
@@ -1176,14 +1176,14 @@ discard block |
||
1176 | 1176 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1177 | 1177 | } |
1178 | 1178 | } |
1179 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1180 | - try { |
|
1181 | - $sth = $this->db->prepare($query); |
|
1182 | - $sth->execute($query_values); |
|
1183 | - } catch(PDOException $e) { |
|
1184 | - return "error : ".$e->getMessage(); |
|
1185 | - } |
|
1186 | - } |
|
1179 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1180 | + try { |
|
1181 | + $sth = $this->db->prepare($query); |
|
1182 | + $sth->execute($query_values); |
|
1183 | + } catch(PDOException $e) { |
|
1184 | + return "error : ".$e->getMessage(); |
|
1185 | + } |
|
1186 | + } |
|
1187 | 1187 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
1188 | 1188 | global $globalDBdriver; |
1189 | 1189 | if ($globalDBdriver == 'mysql') { |
@@ -1199,14 +1199,14 @@ discard block |
||
1199 | 1199 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1200 | 1200 | } |
1201 | 1201 | } |
1202 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1203 | - try { |
|
1204 | - $sth = $this->db->prepare($query); |
|
1205 | - $sth->execute($query_values); |
|
1206 | - } catch(PDOException $e) { |
|
1207 | - return "error : ".$e->getMessage(); |
|
1208 | - } |
|
1209 | - } |
|
1202 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1203 | + try { |
|
1204 | + $sth = $this->db->prepare($query); |
|
1205 | + $sth->execute($query_values); |
|
1206 | + } catch(PDOException $e) { |
|
1207 | + return "error : ".$e->getMessage(); |
|
1208 | + } |
|
1209 | + } |
|
1210 | 1210 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
1211 | 1211 | global $globalDBdriver; |
1212 | 1212 | if ($globalDBdriver == 'mysql') { |
@@ -1222,14 +1222,14 @@ discard block |
||
1222 | 1222 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1223 | 1223 | } |
1224 | 1224 | } |
1225 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1226 | - try { |
|
1227 | - $sth = $this->db->prepare($query); |
|
1228 | - $sth->execute($query_values); |
|
1229 | - } catch(PDOException $e) { |
|
1230 | - return "error : ".$e->getMessage(); |
|
1231 | - } |
|
1232 | - } |
|
1225 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1226 | + try { |
|
1227 | + $sth = $this->db->prepare($query); |
|
1228 | + $sth->execute($query_values); |
|
1229 | + } catch(PDOException $e) { |
|
1230 | + return "error : ".$e->getMessage(); |
|
1231 | + } |
|
1232 | + } |
|
1233 | 1233 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
1234 | 1234 | global $globalDBdriver; |
1235 | 1235 | if ($globalDBdriver == 'mysql') { |
@@ -1245,14 +1245,14 @@ discard block |
||
1245 | 1245 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1246 | 1246 | } |
1247 | 1247 | } |
1248 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1249 | - try { |
|
1250 | - $sth = $this->db->prepare($query); |
|
1251 | - $sth->execute($query_values); |
|
1252 | - } catch(PDOException $e) { |
|
1253 | - return "error : ".$e->getMessage(); |
|
1254 | - } |
|
1255 | - } |
|
1248 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1249 | + try { |
|
1250 | + $sth = $this->db->prepare($query); |
|
1251 | + $sth->execute($query_values); |
|
1252 | + } catch(PDOException $e) { |
|
1253 | + return "error : ".$e->getMessage(); |
|
1254 | + } |
|
1255 | + } |
|
1256 | 1256 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
1257 | 1257 | global $globalDBdriver; |
1258 | 1258 | if ($airport_icao != '') { |
@@ -1276,8 +1276,8 @@ discard block |
||
1276 | 1276 | } catch(PDOException $e) { |
1277 | 1277 | return "error : ".$e->getMessage(); |
1278 | 1278 | } |
1279 | - } |
|
1280 | - } |
|
1279 | + } |
|
1280 | + } |
|
1281 | 1281 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1282 | 1282 | global $globalDBdriver; |
1283 | 1283 | if ($airport_icao != '') { |
@@ -1293,8 +1293,8 @@ discard block |
||
1293 | 1293 | } catch(PDOException $e) { |
1294 | 1294 | return "error : ".$e->getMessage(); |
1295 | 1295 | } |
1296 | - } |
|
1297 | - } |
|
1296 | + } |
|
1297 | + } |
|
1298 | 1298 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
1299 | 1299 | global $globalDBdriver; |
1300 | 1300 | if ($airport_icao != '') { |
@@ -1311,15 +1311,15 @@ discard block |
||
1311 | 1311 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1312 | 1312 | } |
1313 | 1313 | } |
1314 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1314 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1315 | 1315 | try { |
1316 | - $sth = $this->db->prepare($query); |
|
1317 | - $sth->execute($query_values); |
|
1318 | - } catch(PDOException $e) { |
|
1319 | - return "error : ".$e->getMessage(); |
|
1320 | - } |
|
1321 | - } |
|
1322 | - } |
|
1316 | + $sth = $this->db->prepare($query); |
|
1317 | + $sth->execute($query_values); |
|
1318 | + } catch(PDOException $e) { |
|
1319 | + return "error : ".$e->getMessage(); |
|
1320 | + } |
|
1321 | + } |
|
1322 | + } |
|
1323 | 1323 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1324 | 1324 | global $globalDBdriver; |
1325 | 1325 | if ($airport_icao != '') { |
@@ -1335,46 +1335,46 @@ discard block |
||
1335 | 1335 | } catch(PDOException $e) { |
1336 | 1336 | return "error : ".$e->getMessage(); |
1337 | 1337 | } |
1338 | - } |
|
1339 | - } |
|
1338 | + } |
|
1339 | + } |
|
1340 | 1340 | |
1341 | 1341 | public function deleteStat($id) { |
1342 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1343 | - $query_values = array(':id' => $id); |
|
1344 | - try { |
|
1345 | - $sth = $this->db->prepare($query); |
|
1346 | - $sth->execute($query_values); |
|
1347 | - } catch(PDOException $e) { |
|
1348 | - return "error : ".$e->getMessage(); |
|
1349 | - } |
|
1350 | - } |
|
1342 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1343 | + $query_values = array(':id' => $id); |
|
1344 | + try { |
|
1345 | + $sth = $this->db->prepare($query); |
|
1346 | + $sth->execute($query_values); |
|
1347 | + } catch(PDOException $e) { |
|
1348 | + return "error : ".$e->getMessage(); |
|
1349 | + } |
|
1350 | + } |
|
1351 | 1351 | public function deleteStatFlight($type) { |
1352 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1353 | - $query_values = array(':type' => $type); |
|
1354 | - try { |
|
1355 | - $sth = $this->db->prepare($query); |
|
1356 | - $sth->execute($query_values); |
|
1357 | - } catch(PDOException $e) { |
|
1358 | - return "error : ".$e->getMessage(); |
|
1359 | - } |
|
1360 | - } |
|
1352 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1353 | + $query_values = array(':type' => $type); |
|
1354 | + try { |
|
1355 | + $sth = $this->db->prepare($query); |
|
1356 | + $sth->execute($query_values); |
|
1357 | + } catch(PDOException $e) { |
|
1358 | + return "error : ".$e->getMessage(); |
|
1359 | + } |
|
1360 | + } |
|
1361 | 1361 | public function deleteStatAirport($type) { |
1362 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1363 | - $query_values = array(':type' => $type); |
|
1364 | - try { |
|
1365 | - $sth = $this->db->prepare($query); |
|
1366 | - $sth->execute($query_values); |
|
1367 | - } catch(PDOException $e) { |
|
1368 | - return "error : ".$e->getMessage(); |
|
1369 | - } |
|
1370 | - } |
|
1362 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1363 | + $query_values = array(':type' => $type); |
|
1364 | + try { |
|
1365 | + $sth = $this->db->prepare($query); |
|
1366 | + $sth->execute($query_values); |
|
1367 | + } catch(PDOException $e) { |
|
1368 | + return "error : ".$e->getMessage(); |
|
1369 | + } |
|
1370 | + } |
|
1371 | 1371 | |
1372 | - public function addOldStats() { |
|
1373 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear; |
|
1374 | - $Common = new Common(); |
|
1375 | - $Connection = new Connection(); |
|
1376 | - date_default_timezone_set('UTC'); |
|
1377 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1372 | + public function addOldStats() { |
|
1373 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear; |
|
1374 | + $Common = new Common(); |
|
1375 | + $Connection = new Connection(); |
|
1376 | + date_default_timezone_set('UTC'); |
|
1377 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1378 | 1378 | if ($globalDebug) echo 'Update stats !'."\n"; |
1379 | 1379 | if (isset($last_update[0]['value'])) { |
1380 | 1380 | $last_update_day = $last_update[0]['value']; |
@@ -1420,24 +1420,24 @@ discard block |
||
1420 | 1420 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1421 | 1421 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1422 | 1422 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1423 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1423 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1424 | 1424 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1425 | - $alldata = array(); |
|
1425 | + $alldata = array(); |
|
1426 | 1426 | |
1427 | - foreach ($pall as $value) { |
|
1428 | - $icao = $value['airport_departure_icao']; |
|
1429 | - $alldata[$icao] = $value; |
|
1430 | - } |
|
1431 | - foreach ($dall as $value) { |
|
1432 | - $icao = $value['airport_departure_icao']; |
|
1433 | - if (isset($alldata[$icao])) { |
|
1434 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1435 | - } else $alldata[$icao] = $value; |
|
1436 | - } |
|
1437 | - $count = array(); |
|
1438 | - foreach ($alldata as $key => $row) { |
|
1439 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1440 | - } |
|
1427 | + foreach ($pall as $value) { |
|
1428 | + $icao = $value['airport_departure_icao']; |
|
1429 | + $alldata[$icao] = $value; |
|
1430 | + } |
|
1431 | + foreach ($dall as $value) { |
|
1432 | + $icao = $value['airport_departure_icao']; |
|
1433 | + if (isset($alldata[$icao])) { |
|
1434 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1435 | + } else $alldata[$icao] = $value; |
|
1436 | + } |
|
1437 | + $count = array(); |
|
1438 | + foreach ($alldata as $key => $row) { |
|
1439 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1440 | + } |
|
1441 | 1441 | array_multisort($count,SORT_DESC,$alldata); |
1442 | 1442 | foreach ($alldata as $number) { |
1443 | 1443 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
@@ -1445,25 +1445,25 @@ discard block |
||
1445 | 1445 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1446 | 1446 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1447 | 1447 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1448 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1448 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1449 | 1449 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1450 | - $alldata = array(); |
|
1451 | - foreach ($pall as $value) { |
|
1452 | - $icao = $value['airport_arrival_icao']; |
|
1453 | - $alldata[$icao] = $value; |
|
1454 | - } |
|
1455 | - foreach ($dall as $value) { |
|
1456 | - $icao = $value['airport_arrival_icao']; |
|
1457 | - if (isset($alldata[$icao])) { |
|
1458 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1459 | - } else $alldata[$icao] = $value; |
|
1460 | - } |
|
1461 | - $count = array(); |
|
1462 | - foreach ($alldata as $key => $row) { |
|
1463 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1464 | - } |
|
1465 | - array_multisort($count,SORT_DESC,$alldata); |
|
1466 | - foreach ($alldata as $number) { |
|
1450 | + $alldata = array(); |
|
1451 | + foreach ($pall as $value) { |
|
1452 | + $icao = $value['airport_arrival_icao']; |
|
1453 | + $alldata[$icao] = $value; |
|
1454 | + } |
|
1455 | + foreach ($dall as $value) { |
|
1456 | + $icao = $value['airport_arrival_icao']; |
|
1457 | + if (isset($alldata[$icao])) { |
|
1458 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1459 | + } else $alldata[$icao] = $value; |
|
1460 | + } |
|
1461 | + $count = array(); |
|
1462 | + foreach ($alldata as $key => $row) { |
|
1463 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1464 | + } |
|
1465 | + array_multisort($count,SORT_DESC,$alldata); |
|
1466 | + foreach ($alldata as $number) { |
|
1467 | 1467 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
1468 | 1468 | } |
1469 | 1469 | if ($Connection->tableExists('countries')) { |
@@ -1523,8 +1523,8 @@ discard block |
||
1523 | 1523 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1524 | 1524 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1525 | 1525 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1526 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1527 | - /* |
|
1526 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1527 | + /* |
|
1528 | 1528 | $alldata = array(); |
1529 | 1529 | foreach ($pall as $value) { |
1530 | 1530 | $icao = $value['departure_airport_icao']; |
@@ -1543,29 +1543,29 @@ discard block |
||
1543 | 1543 | } |
1544 | 1544 | array_multisort($count,SORT_DESC,$alldata); |
1545 | 1545 | */ |
1546 | - foreach ($dall as $value) { |
|
1547 | - $icao = $value['departure_airport_icao']; |
|
1548 | - $ddate = $value['date']; |
|
1549 | - $find = false; |
|
1550 | - foreach ($pall as $pvalue) { |
|
1551 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1552 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1553 | - $find = true; |
|
1554 | - break; |
|
1555 | - } |
|
1556 | - } |
|
1557 | - if ($find === false) { |
|
1558 | - $pall[] = $value; |
|
1559 | - } |
|
1560 | - } |
|
1561 | - $alldata = $pall; |
|
1546 | + foreach ($dall as $value) { |
|
1547 | + $icao = $value['departure_airport_icao']; |
|
1548 | + $ddate = $value['date']; |
|
1549 | + $find = false; |
|
1550 | + foreach ($pall as $pvalue) { |
|
1551 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1552 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1553 | + $find = true; |
|
1554 | + break; |
|
1555 | + } |
|
1556 | + } |
|
1557 | + if ($find === false) { |
|
1558 | + $pall[] = $value; |
|
1559 | + } |
|
1560 | + } |
|
1561 | + $alldata = $pall; |
|
1562 | 1562 | foreach ($alldata as $number) { |
1563 | 1563 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1564 | 1564 | } |
1565 | 1565 | echo '...Arrival'."\n"; |
1566 | 1566 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1567 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1568 | - /* |
|
1567 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1568 | + /* |
|
1569 | 1569 | $alldata = array(); |
1570 | 1570 | foreach ($pall as $value) { |
1571 | 1571 | $icao = $value['arrival_airport_icao']; |
@@ -1585,22 +1585,22 @@ discard block |
||
1585 | 1585 | */ |
1586 | 1586 | |
1587 | 1587 | |
1588 | - foreach ($dall as $value) { |
|
1589 | - $icao = $value['arrival_airport_icao']; |
|
1590 | - $ddate = $value['date']; |
|
1591 | - $find = false; |
|
1592 | - foreach ($pall as $pvalue) { |
|
1593 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1594 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1595 | - $find = true; |
|
1596 | - break; |
|
1597 | - } |
|
1598 | - } |
|
1599 | - if ($find === false) { |
|
1600 | - $pall[] = $value; |
|
1601 | - } |
|
1602 | - } |
|
1603 | - $alldata = $pall; |
|
1588 | + foreach ($dall as $value) { |
|
1589 | + $icao = $value['arrival_airport_icao']; |
|
1590 | + $ddate = $value['date']; |
|
1591 | + $find = false; |
|
1592 | + foreach ($pall as $pvalue) { |
|
1593 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1594 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1595 | + $find = true; |
|
1596 | + break; |
|
1597 | + } |
|
1598 | + } |
|
1599 | + if ($find === false) { |
|
1600 | + $pall[] = $value; |
|
1601 | + } |
|
1602 | + } |
|
1603 | + $alldata = $pall; |
|
1604 | 1604 | foreach ($alldata as $number) { |
1605 | 1605 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1606 | 1606 | } |
@@ -1675,51 +1675,51 @@ discard block |
||
1675 | 1675 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1676 | 1676 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1677 | 1677 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1678 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1678 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1679 | 1679 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1680 | - //$alldata = array(); |
|
1681 | - foreach ($dall as $value) { |
|
1682 | - $icao = $value['airport_departure_icao']; |
|
1683 | - $dicao = $value['airline_icao']; |
|
1684 | - $find = false; |
|
1685 | - foreach ($pall as $pvalue) { |
|
1686 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1687 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1688 | - $find = true; |
|
1689 | - break; |
|
1690 | - } |
|
1691 | - } |
|
1692 | - if ($find === false) { |
|
1693 | - $pall[] = $value; |
|
1694 | - } |
|
1695 | - } |
|
1696 | - $alldata = $pall; |
|
1680 | + //$alldata = array(); |
|
1681 | + foreach ($dall as $value) { |
|
1682 | + $icao = $value['airport_departure_icao']; |
|
1683 | + $dicao = $value['airline_icao']; |
|
1684 | + $find = false; |
|
1685 | + foreach ($pall as $pvalue) { |
|
1686 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1687 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1688 | + $find = true; |
|
1689 | + break; |
|
1690 | + } |
|
1691 | + } |
|
1692 | + if ($find === false) { |
|
1693 | + $pall[] = $value; |
|
1694 | + } |
|
1695 | + } |
|
1696 | + $alldata = $pall; |
|
1697 | 1697 | foreach ($alldata as $number) { |
1698 | 1698 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
1699 | 1699 | } |
1700 | 1700 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1701 | 1701 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1702 | 1702 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1703 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1703 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1704 | 1704 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1705 | - //$alldata = array(); |
|
1706 | - foreach ($dall as $value) { |
|
1707 | - $icao = $value['airport_arrival_icao']; |
|
1708 | - $dicao = $value['airline_icao']; |
|
1709 | - $find = false; |
|
1710 | - foreach ($pall as $pvalue) { |
|
1711 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1712 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1713 | - $find = true; |
|
1714 | - break; |
|
1715 | - } |
|
1716 | - } |
|
1717 | - if ($find === false) { |
|
1718 | - $pall[] = $value; |
|
1719 | - } |
|
1720 | - } |
|
1721 | - $alldata = $pall; |
|
1722 | - foreach ($alldata as $number) { |
|
1705 | + //$alldata = array(); |
|
1706 | + foreach ($dall as $value) { |
|
1707 | + $icao = $value['airport_arrival_icao']; |
|
1708 | + $dicao = $value['airline_icao']; |
|
1709 | + $find = false; |
|
1710 | + foreach ($pall as $pvalue) { |
|
1711 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1712 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1713 | + $find = true; |
|
1714 | + break; |
|
1715 | + } |
|
1716 | + } |
|
1717 | + if ($find === false) { |
|
1718 | + $pall[] = $value; |
|
1719 | + } |
|
1720 | + } |
|
1721 | + $alldata = $pall; |
|
1722 | + foreach ($alldata as $number) { |
|
1723 | 1723 | if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
1724 | 1724 | } |
1725 | 1725 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
@@ -1752,47 +1752,47 @@ discard block |
||
1752 | 1752 | } |
1753 | 1753 | if ($globalDebug) echo '...Departure'."\n"; |
1754 | 1754 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1755 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1756 | - foreach ($dall as $value) { |
|
1757 | - $icao = $value['departure_airport_icao']; |
|
1758 | - $airline = $value['airline_icao']; |
|
1759 | - $ddate = $value['date']; |
|
1760 | - $find = false; |
|
1761 | - foreach ($pall as $pvalue) { |
|
1762 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1763 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1764 | - $find = true; |
|
1765 | - break; |
|
1766 | - } |
|
1767 | - } |
|
1768 | - if ($find === false) { |
|
1769 | - $pall[] = $value; |
|
1770 | - } |
|
1771 | - } |
|
1772 | - $alldata = $pall; |
|
1755 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1756 | + foreach ($dall as $value) { |
|
1757 | + $icao = $value['departure_airport_icao']; |
|
1758 | + $airline = $value['airline_icao']; |
|
1759 | + $ddate = $value['date']; |
|
1760 | + $find = false; |
|
1761 | + foreach ($pall as $pvalue) { |
|
1762 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1763 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1764 | + $find = true; |
|
1765 | + break; |
|
1766 | + } |
|
1767 | + } |
|
1768 | + if ($find === false) { |
|
1769 | + $pall[] = $value; |
|
1770 | + } |
|
1771 | + } |
|
1772 | + $alldata = $pall; |
|
1773 | 1773 | foreach ($alldata as $number) { |
1774 | 1774 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
1775 | 1775 | } |
1776 | 1776 | if ($globalDebug) echo '...Arrival'."\n"; |
1777 | 1777 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1778 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1779 | - foreach ($dall as $value) { |
|
1780 | - $icao = $value['arrival_airport_icao']; |
|
1781 | - $airline = $value['airline_icao']; |
|
1782 | - $ddate = $value['date']; |
|
1783 | - $find = false; |
|
1784 | - foreach ($pall as $pvalue) { |
|
1785 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1786 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1787 | - $find = true; |
|
1788 | - break; |
|
1789 | - } |
|
1790 | - } |
|
1791 | - if ($find === false) { |
|
1792 | - $pall[] = $value; |
|
1793 | - } |
|
1794 | - } |
|
1795 | - $alldata = $pall; |
|
1778 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1779 | + foreach ($dall as $value) { |
|
1780 | + $icao = $value['arrival_airport_icao']; |
|
1781 | + $airline = $value['airline_icao']; |
|
1782 | + $ddate = $value['date']; |
|
1783 | + $find = false; |
|
1784 | + foreach ($pall as $pvalue) { |
|
1785 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1786 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1787 | + $find = true; |
|
1788 | + break; |
|
1789 | + } |
|
1790 | + } |
|
1791 | + if ($find === false) { |
|
1792 | + $pall[] = $value; |
|
1793 | + } |
|
1794 | + } |
|
1795 | + $alldata = $pall; |
|
1796 | 1796 | foreach ($alldata as $number) { |
1797 | 1797 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
1798 | 1798 | } |
@@ -1863,44 +1863,44 @@ discard block |
||
1863 | 1863 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
1864 | 1864 | } |
1865 | 1865 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
1866 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1867 | - $alldata = array(); |
|
1868 | - foreach ($pall as $value) { |
|
1869 | - $icao = $value['airport_departure_icao']; |
|
1870 | - $alldata[$icao] = $value; |
|
1871 | - } |
|
1872 | - foreach ($dall as $value) { |
|
1873 | - $icao = $value['airport_departure_icao']; |
|
1874 | - if (isset($alldata[$icao])) { |
|
1875 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1876 | - } else $alldata[$icao] = $value; |
|
1877 | - } |
|
1878 | - $count = array(); |
|
1879 | - foreach ($alldata as $key => $row) { |
|
1880 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1881 | - } |
|
1866 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1867 | + $alldata = array(); |
|
1868 | + foreach ($pall as $value) { |
|
1869 | + $icao = $value['airport_departure_icao']; |
|
1870 | + $alldata[$icao] = $value; |
|
1871 | + } |
|
1872 | + foreach ($dall as $value) { |
|
1873 | + $icao = $value['airport_departure_icao']; |
|
1874 | + if (isset($alldata[$icao])) { |
|
1875 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1876 | + } else $alldata[$icao] = $value; |
|
1877 | + } |
|
1878 | + $count = array(); |
|
1879 | + foreach ($alldata as $key => $row) { |
|
1880 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1881 | + } |
|
1882 | 1882 | array_multisort($count,SORT_DESC,$alldata); |
1883 | 1883 | foreach ($alldata as $number) { |
1884 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
1884 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
1885 | 1885 | } |
1886 | 1886 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
1887 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1887 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1888 | 1888 | $alldata = array(); |
1889 | - foreach ($pall as $value) { |
|
1890 | - $icao = $value['airport_arrival_icao']; |
|
1891 | - $alldata[$icao] = $value; |
|
1892 | - } |
|
1893 | - foreach ($dall as $value) { |
|
1894 | - $icao = $value['airport_arrival_icao']; |
|
1895 | - if (isset($alldata[$icao])) { |
|
1896 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1897 | - } else $alldata[$icao] = $value; |
|
1898 | - } |
|
1899 | - $count = array(); |
|
1900 | - foreach ($alldata as $key => $row) { |
|
1901 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1902 | - } |
|
1903 | - array_multisort($count,SORT_DESC,$alldata); |
|
1889 | + foreach ($pall as $value) { |
|
1890 | + $icao = $value['airport_arrival_icao']; |
|
1891 | + $alldata[$icao] = $value; |
|
1892 | + } |
|
1893 | + foreach ($dall as $value) { |
|
1894 | + $icao = $value['airport_arrival_icao']; |
|
1895 | + if (isset($alldata[$icao])) { |
|
1896 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1897 | + } else $alldata[$icao] = $value; |
|
1898 | + } |
|
1899 | + $count = array(); |
|
1900 | + foreach ($alldata as $key => $row) { |
|
1901 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1902 | + } |
|
1903 | + array_multisort($count,SORT_DESC,$alldata); |
|
1904 | 1904 | foreach ($alldata as $number) { |
1905 | 1905 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
1906 | 1906 | } |
@@ -1933,45 +1933,45 @@ discard block |
||
1933 | 1933 | } |
1934 | 1934 | echo '...Departure'."\n"; |
1935 | 1935 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
1936 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1936 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1937 | 1937 | foreach ($dall as $value) { |
1938 | - $icao = $value['departure_airport_icao']; |
|
1939 | - $ddate = $value['date']; |
|
1940 | - $find = false; |
|
1941 | - foreach ($pall as $pvalue) { |
|
1942 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1943 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1944 | - $find = true; |
|
1945 | - break; |
|
1946 | - } |
|
1947 | - } |
|
1948 | - if ($find === false) { |
|
1949 | - $pall[] = $value; |
|
1950 | - } |
|
1951 | - } |
|
1952 | - $alldata = $pall; |
|
1938 | + $icao = $value['departure_airport_icao']; |
|
1939 | + $ddate = $value['date']; |
|
1940 | + $find = false; |
|
1941 | + foreach ($pall as $pvalue) { |
|
1942 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1943 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1944 | + $find = true; |
|
1945 | + break; |
|
1946 | + } |
|
1947 | + } |
|
1948 | + if ($find === false) { |
|
1949 | + $pall[] = $value; |
|
1950 | + } |
|
1951 | + } |
|
1952 | + $alldata = $pall; |
|
1953 | 1953 | foreach ($alldata as $number) { |
1954 | 1954 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
1955 | 1955 | } |
1956 | 1956 | echo '...Arrival'."\n"; |
1957 | 1957 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
1958 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1958 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1959 | 1959 | foreach ($dall as $value) { |
1960 | 1960 | $icao = $value['arrival_airport_icao']; |
1961 | 1961 | $ddate = $value['date']; |
1962 | - $find = false; |
|
1962 | + $find = false; |
|
1963 | 1963 | foreach ($pall as $pvalue) { |
1964 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1965 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1966 | - $find = true; |
|
1967 | - break; |
|
1968 | - } |
|
1969 | - } |
|
1970 | - if ($find === false) { |
|
1971 | - $pall[] = $value; |
|
1972 | - } |
|
1973 | - } |
|
1974 | - $alldata = $pall; |
|
1964 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1965 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1966 | + $find = true; |
|
1967 | + break; |
|
1968 | + } |
|
1969 | + } |
|
1970 | + if ($find === false) { |
|
1971 | + $pall[] = $value; |
|
1972 | + } |
|
1973 | + } |
|
1974 | + $alldata = $pall; |
|
1975 | 1975 | foreach ($alldata as $number) { |
1976 | 1976 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
1977 | 1977 | } |