@@ -84,6 +84,10 @@ |
||
| 84 | 84 | 'y' => 'Yagi At QTH'); |
| 85 | 85 | |
| 86 | 86 | |
| 87 | + /** |
|
| 88 | + * @param integer $n |
|
| 89 | + * @param integer $s |
|
| 90 | + */ |
|
| 87 | 91 | private function urshift($n, $s) { |
| 88 | 92 | return ($n >= 0) ? ($n >> $s) : |
| 89 | 93 | (($n & 0x7fffffff) >> $s) | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class aprs { |
| 3 | - protected $symbols = array('!' => 'Police', |
|
| 3 | + protected $symbols = array('!' => 'Police', |
|
| 4 | 4 | '#' => 'DIGI', |
| 5 | 5 | '$' => 'Phone', |
| 6 | 6 | '%' => 'DX Cluster', |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | 'y' => 'Yagi At QTH'); |
| 85 | 85 | |
| 86 | 86 | |
| 87 | - private function urshift($n, $s) { |
|
| 87 | + private function urshift($n, $s) { |
|
| 88 | 88 | return ($n >= 0) ? ($n >> $s) : |
| 89 | - (($n & 0x7fffffff) >> $s) | |
|
| 90 | - (0x40000000 >> ($s - 1)); |
|
| 91 | - } |
|
| 89 | + (($n & 0x7fffffff) >> $s) | |
|
| 90 | + (0x40000000 >> ($s - 1)); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - public function parse($input) { |
|
| 93 | + public function parse($input) { |
|
| 94 | 94 | global $globalDebug; |
| 95 | 95 | $debug = false; |
| 96 | 96 | $result = array(); |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | /* Check that end was found and body has at least one byte. */ |
| 104 | 104 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
| 105 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 106 | - return false; |
|
| 105 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 106 | + return false; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /* Save header and body. */ |
@@ -116,22 +116,22 @@ discard block |
||
| 116 | 116 | /* Parse source, target and path. */ |
| 117 | 117 | //FLRDF0A52>APRS,qAS,LSTB |
| 118 | 118 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
| 119 | - $ident = $matches[1]; |
|
| 120 | - $all_elements = $matches[2]; |
|
| 121 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
| 122 | - $result['ident'] = $ident; |
|
| 119 | + $ident = $matches[1]; |
|
| 120 | + $all_elements = $matches[2]; |
|
| 121 | + if ($debug) echo 'ident : '.$ident."\n"; |
|
| 122 | + $result['ident'] = $ident; |
|
| 123 | 123 | } else return false; |
| 124 | 124 | $elements = explode(',',$all_elements); |
| 125 | 125 | $source = end($elements); |
| 126 | 126 | $result['source'] = $source; |
| 127 | 127 | foreach ($elements as $element) { |
| 128 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
| 129 | - //echo "ok"; |
|
| 130 | - if ($element == 'TCPIP*') return false; |
|
| 131 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
| 128 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
| 129 | + //echo "ok"; |
|
| 130 | + if ($element == 'TCPIP*') return false; |
|
| 131 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
| 132 | 132 | return false; |
| 133 | - } |
|
| 134 | - /* |
|
| 133 | + } |
|
| 134 | + /* |
|
| 135 | 135 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
| 136 | 136 | //echo "ok"; |
| 137 | 137 | } else { |
@@ -144,42 +144,42 @@ discard block |
||
| 144 | 144 | $body_parse = substr($body,1); |
| 145 | 145 | //echo 'Body : '.$body."\n"; |
| 146 | 146 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
| 147 | - $body_parse = substr($body_parse,10); |
|
| 148 | - $find = true; |
|
| 149 | - //echo $body_parse."\n"; |
|
| 147 | + $body_parse = substr($body_parse,10); |
|
| 148 | + $find = true; |
|
| 149 | + //echo $body_parse."\n"; |
|
| 150 | 150 | } |
| 151 | 151 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
| 152 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 153 | - $find = true; |
|
| 154 | - //echo $body_parse."\n"; |
|
| 152 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 153 | + $find = true; |
|
| 154 | + //echo $body_parse."\n"; |
|
| 155 | 155 | } |
| 156 | 156 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
| 157 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 158 | - $find = true; |
|
| 159 | - //echo $body_parse."\n"; |
|
| 157 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 158 | + $find = true; |
|
| 159 | + //echo $body_parse."\n"; |
|
| 160 | 160 | } |
| 161 | 161 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
| 162 | - $find = true; |
|
| 163 | - //print_r($matches); |
|
| 164 | - $timestamp = $matches[0]; |
|
| 165 | - if ($matches[4] == 'h') { |
|
| 162 | + $find = true; |
|
| 163 | + //print_r($matches); |
|
| 164 | + $timestamp = $matches[0]; |
|
| 165 | + if ($matches[4] == 'h') { |
|
| 166 | 166 | $timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]); |
| 167 | 167 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
| 168 | 168 | /* |
| 169 | 169 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
| 170 | 170 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
| 171 | 171 | */ |
| 172 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
| 172 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
| 173 | 173 | // This work or not ? |
| 174 | 174 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
| 175 | - } |
|
| 176 | - $body_parse = substr($body_parse,7); |
|
| 177 | - $result['timestamp'] = $timestamp; |
|
| 178 | - //echo date('Ymd H:i:s',$timestamp); |
|
| 175 | + } |
|
| 176 | + $body_parse = substr($body_parse,7); |
|
| 177 | + $result['timestamp'] = $timestamp; |
|
| 178 | + //echo date('Ymd H:i:s',$timestamp); |
|
| 179 | 179 | } |
| 180 | 180 | //if (strlen($body_parse) > 19) { |
| 181 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
| 182 | - $find = true; |
|
| 181 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
| 182 | + $find = true; |
|
| 183 | 183 | // 4658.70N/00707.78Ez |
| 184 | 184 | //print_r(str_split($body_parse)); |
| 185 | 185 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $lon = intval($lon_deg); |
| 197 | 197 | if ($lat > 89 || $lon > 179) return false; |
| 198 | 198 | |
| 199 | - /* |
|
| 199 | + /* |
|
| 200 | 200 | $tmp_5b = str_replace('.','',$lat_min); |
| 201 | 201 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
| 202 | 202 | print_r($matches); |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | $result['longitude'] = $longitude; |
| 211 | 211 | $body_parse = substr($body_parse,18); |
| 212 | 212 | $body_parse_len = strlen($body_parse); |
| 213 | - } |
|
| 214 | - if ($body_len > 0) { |
|
| 213 | + } |
|
| 214 | + if ($body_len > 0) { |
|
| 215 | 215 | /* |
| 216 | 216 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
| 217 | 217 | $body_split = str_split($body); |
@@ -237,60 +237,60 @@ discard block |
||
| 237 | 237 | $result['symbol_code'] = $symbol_code; |
| 238 | 238 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
| 239 | 239 | if ($symbol_code != '_') { |
| 240 | - //$body_parse = substr($body_parse,1); |
|
| 241 | - //$body_parse = trim($body_parse); |
|
| 242 | - //$body_parse_len = strlen($body_parse); |
|
| 243 | - if ($body_parse_len >= 7) { |
|
| 240 | + //$body_parse = substr($body_parse,1); |
|
| 241 | + //$body_parse = trim($body_parse); |
|
| 242 | + //$body_parse_len = strlen($body_parse); |
|
| 243 | + if ($body_parse_len >= 7) { |
|
| 244 | 244 | |
| 245 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
| 246 | - $course = substr($body_parse,0,3); |
|
| 247 | - $tmp_s = intval($course); |
|
| 248 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 249 | - $speed = substr($body_parse,4,3); |
|
| 250 | - $result['speed'] = round($speed*1.852); |
|
| 251 | - $body_parse = substr($body_parse,7); |
|
| 252 | - } |
|
| 253 | - // Check PHGR, PHG, RNG |
|
| 254 | - } |
|
| 255 | - /* |
|
| 245 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
| 246 | + $course = substr($body_parse,0,3); |
|
| 247 | + $tmp_s = intval($course); |
|
| 248 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 249 | + $speed = substr($body_parse,4,3); |
|
| 250 | + $result['speed'] = round($speed*1.852); |
|
| 251 | + $body_parse = substr($body_parse,7); |
|
| 252 | + } |
|
| 253 | + // Check PHGR, PHG, RNG |
|
| 254 | + } |
|
| 255 | + /* |
|
| 256 | 256 | else if ($body_parse_len > 0) { |
| 257 | 257 | $rest = $body_parse; |
| 258 | 258 | } |
| 259 | 259 | */ |
| 260 | - if (strlen($body_parse) > 0) { |
|
| 261 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
| 262 | - $altitude = intval($matches[1]); |
|
| 263 | - //$result['altitude'] = round($altitude*0.3048); |
|
| 264 | - $result['altitude'] = $altitude; |
|
| 265 | - $body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
| 266 | - } |
|
| 267 | - } |
|
| 260 | + if (strlen($body_parse) > 0) { |
|
| 261 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
| 262 | + $altitude = intval($matches[1]); |
|
| 263 | + //$result['altitude'] = round($altitude*0.3048); |
|
| 264 | + $result['altitude'] = $altitude; |
|
| 265 | + $body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - // Telemetry |
|
| 270 | - /* |
|
| 269 | + // Telemetry |
|
| 270 | + /* |
|
| 271 | 271 | if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
| 272 | 272 | // Nothing yet... |
| 273 | 273 | } |
| 274 | 274 | */ |
| 275 | - // DAO |
|
| 276 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
| 277 | - $dao = $matches[1]; |
|
| 278 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
| 275 | + // DAO |
|
| 276 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
| 277 | + $dao = $matches[1]; |
|
| 278 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
| 279 | 279 | $dao_split = str_split($dao); |
| 280 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
| 281 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
| 280 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
| 281 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
| 282 | 282 | |
| 283 | 283 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
| 284 | 284 | else $result['latitude'] += $lat_off; |
| 285 | 285 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
| 286 | 286 | else $result['longitude'] += $lon_off; |
| 287 | - } |
|
| 288 | - $body_parse = substr($body_parse,6); |
|
| 289 | - } |
|
| 287 | + } |
|
| 288 | + $body_parse = substr($body_parse,6); |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - // OGN comment |
|
| 291 | + // OGN comment |
|
| 292 | 292 | // echo "Before OGN : ".$body_parse."\n"; |
| 293 | - if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
| 293 | + if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
| 294 | 294 | $id = $matches[1]; |
| 295 | 295 | //$mode = substr($id,0,2); |
| 296 | 296 | $address = substr($id,2); |
@@ -320,49 +320,49 @@ discard block |
||
| 320 | 320 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
| 321 | 321 | $result['stealth'] = $stealth; |
| 322 | 322 | $result['address'] = $address; |
| 323 | - } |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - //Comment |
|
| 326 | - $result['comment'] = trim($body_parse); |
|
| 325 | + //Comment |
|
| 326 | + $result['comment'] = trim($body_parse); |
|
| 327 | 327 | } else { |
| 328 | - // parse weather |
|
| 329 | - //$body_parse = substr($body_parse,1); |
|
| 330 | - //$body_parse_len = strlen($body_parse); |
|
| 328 | + // parse weather |
|
| 329 | + //$body_parse = substr($body_parse,1); |
|
| 330 | + //$body_parse_len = strlen($body_parse); |
|
| 331 | 331 | |
| 332 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 333 | - $result['wind_dir'] = intval($matches[1]); |
|
| 334 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
| 335 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
| 336 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
| 337 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 338 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 332 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 333 | + $result['wind_dir'] = intval($matches[1]); |
|
| 334 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
| 335 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
| 336 | + $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
| 337 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 338 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 339 | 339 | $result['wind_dir'] = intval($matches[1]); |
| 340 | 340 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
| 341 | 341 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
| 342 | 342 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
| 343 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 344 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 343 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 344 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 345 | 345 | $result['wind_dir'] = intval($matches[1]); |
| 346 | 346 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
| 347 | 347 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
| 348 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 349 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 348 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 349 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 350 | 350 | $result['wind_dir'] = intval($matches[1]); |
| 351 | 351 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
| 352 | 352 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
| 353 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 354 | - } |
|
| 355 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
| 353 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 354 | + } |
|
| 355 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
| 356 | 356 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
| 357 | - } |
|
| 357 | + } |
|
| 358 | + } |
|
| 358 | 359 | } |
| 359 | - } |
|
| 360 | 360 | //} |
| 361 | 361 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
| 362 | 362 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
| 363 | 363 | //print_r($result); |
| 364 | 364 | return $result; |
| 365 | - } |
|
| 365 | + } |
|
| 366 | 366 | } |
| 367 | 367 | /* |
| 368 | 368 | $aprs = new aprs(); |
@@ -19,47 +19,47 @@ discard block |
||
| 19 | 19 | // Check if schema is at latest version |
| 20 | 20 | $Connection = new Connection(); |
| 21 | 21 | if ($Connection->latest() === false) { |
| 22 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 23 | - exit(); |
|
| 22 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 23 | + exit(); |
|
| 24 | 24 | } |
| 25 | 25 | if (PHP_SAPI != 'cli') { |
| 26 | - echo "This script MUST be called from console, not a web browser."; |
|
| 26 | + echo "This script MUST be called from console, not a web browser."; |
|
| 27 | 27 | // exit(); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // This is to be compatible with old version of settings.php |
| 31 | 31 | if (!isset($globalSources)) { |
| 32 | - if (isset($globalSBS1Hosts)) { |
|
| 33 | - //$hosts = $globalSBS1Hosts; |
|
| 34 | - foreach ($globalSBS1Hosts as $host) { |
|
| 35 | - $globalSources[] = array('host' => $host); |
|
| 36 | - } |
|
| 37 | - } else { |
|
| 38 | - if (!isset($globalSBS1Host)) { |
|
| 39 | - echo '$globalSources MUST be defined !'; |
|
| 40 | - die; |
|
| 32 | + if (isset($globalSBS1Hosts)) { |
|
| 33 | + //$hosts = $globalSBS1Hosts; |
|
| 34 | + foreach ($globalSBS1Hosts as $host) { |
|
| 35 | + $globalSources[] = array('host' => $host); |
|
| 36 | + } |
|
| 37 | + } else { |
|
| 38 | + if (!isset($globalSBS1Host)) { |
|
| 39 | + echo '$globalSources MUST be defined !'; |
|
| 40 | + die; |
|
| 41 | 41 | } |
| 42 | 42 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 43 | 43 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $options = getopt('s::',array('source::','server','idsource::')); |
| 48 | 48 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 49 | 49 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 50 | 50 | if (isset($options['s'])) { |
| 51 | - $globalSources = array(); |
|
| 52 | - $globalSources[] = array('host' => $options['s']); |
|
| 51 | + $globalSources = array(); |
|
| 52 | + $globalSources[] = array('host' => $options['s']); |
|
| 53 | 53 | } elseif (isset($options['source'])) { |
| 54 | - $globalSources = array(); |
|
| 55 | - $globalSources[] = array('host' => $options['source']); |
|
| 54 | + $globalSources = array(); |
|
| 55 | + $globalSources[] = array('host' => $options['source']); |
|
| 56 | 56 | } |
| 57 | 57 | if (isset($options['server'])) $globalServer = TRUE; |
| 58 | 58 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 59 | 59 | else $id_source = 1; |
| 60 | 60 | if (isset($globalServer) && $globalServer) { |
| 61 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 62 | - $SI=new SpotterServer(); |
|
| 61 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 62 | + $SI=new SpotterServer(); |
|
| 63 | 63 | } else $SI=new SpotterImport($Connection->db); |
| 64 | 64 | //$APRS=new APRS($Connection->db); |
| 65 | 65 | $SBS=new SBS(); |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | //$servertz = system('date +%Z'); |
| 70 | 70 | // signal handler - playing nice with sockets and dump1090 |
| 71 | 71 | if (function_exists('pcntl_fork')) { |
| 72 | - pcntl_signal(SIGINT, function() { |
|
| 73 | - global $sockets; |
|
| 74 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 75 | - die("Bye!\n"); |
|
| 76 | - }); |
|
| 77 | - pcntl_signal_dispatch(); |
|
| 72 | + pcntl_signal(SIGINT, function() { |
|
| 73 | + global $sockets; |
|
| 74 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 75 | + die("Bye!\n"); |
|
| 76 | + }); |
|
| 77 | + pcntl_signal_dispatch(); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // let's try and connect |
@@ -84,162 +84,162 @@ discard block |
||
| 84 | 84 | $reset = 0; |
| 85 | 85 | |
| 86 | 86 | function create_socket($host, $port, &$errno, &$errstr) { |
| 87 | - $ip = gethostbyname($host); |
|
| 88 | - $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 89 | - $r = @socket_connect($s, $ip, $port); |
|
| 90 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 91 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 92 | - return $s; |
|
| 93 | - } |
|
| 94 | - $errno = socket_last_error($s); |
|
| 95 | - $errstr = socket_strerror($errno); |
|
| 96 | - socket_close($s); |
|
| 97 | - return false; |
|
| 87 | + $ip = gethostbyname($host); |
|
| 88 | + $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 89 | + $r = @socket_connect($s, $ip, $port); |
|
| 90 | + if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 91 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 92 | + return $s; |
|
| 93 | + } |
|
| 94 | + $errno = socket_last_error($s); |
|
| 95 | + $errstr = socket_strerror($errno); |
|
| 96 | + socket_close($s); |
|
| 97 | + return false; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | function create_socket_udp($host, $port, &$errno, &$errstr) { |
| 101 | - echo "Create an UDP socket...\n"; |
|
| 102 | - $ip = gethostbyname($host); |
|
| 103 | - $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 104 | - $r = @socket_bind($s, $ip, $port); |
|
| 105 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 106 | - return $s; |
|
| 107 | - } |
|
| 108 | - $errno = socket_last_error($s); |
|
| 109 | - $errstr = socket_strerror($errno); |
|
| 110 | - socket_close($s); |
|
| 111 | - return false; |
|
| 101 | + echo "Create an UDP socket...\n"; |
|
| 102 | + $ip = gethostbyname($host); |
|
| 103 | + $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 104 | + $r = @socket_bind($s, $ip, $port); |
|
| 105 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 106 | + return $s; |
|
| 107 | + } |
|
| 108 | + $errno = socket_last_error($s); |
|
| 109 | + $errstr = socket_strerror($errno); |
|
| 110 | + socket_close($s); |
|
| 111 | + return false; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | function connect_all($hosts) { |
| 115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | - $reset++; |
|
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | - foreach ($hosts as $id => $value) { |
|
| 115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | + global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | + $reset++; |
|
| 118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | + foreach ($hosts as $id => $value) { |
|
| 120 | 120 | $host = $value['host']; |
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; |
| 122 | 122 | // Here we check type of source(s) |
| 123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | - //$formats[$id] = 'deltadbtxt'; |
|
| 126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | - //$last_exec['deltadbtxt'] = 0; |
|
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | - //$formats[$id] = 'vatsimtxt'; |
|
| 131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | - //$last_exec['vatsimtxt'] = 0; |
|
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 145 | - //$formats[$id] = 'radarvirtueljson'; |
|
| 146 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 147 | - //$last_exec['radarvirtueljson'] = 0; |
|
| 148 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 149 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | - exit(0); |
|
| 152 | - } |
|
| 153 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 154 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 155 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 156 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 157 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 158 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 159 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 160 | - exit(0); |
|
| 161 | - } |
|
| 162 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 163 | - //$formats[$id] = 'phpvmacars'; |
|
| 164 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 165 | - //$last_exec['phpvmacars'] = 0; |
|
| 166 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 167 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 168 | - //$formats[$id] = 'phpvmacars'; |
|
| 169 | - $globalSources[$id]['format'] = 'vam'; |
|
| 170 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 171 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 172 | - //$formats[$id] = 'whazzup'; |
|
| 173 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 174 | - //$last_exec['whazzup'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 176 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 177 | - //$formats[$id] = 'pirepsjson'; |
|
| 178 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 179 | - //$last_exec['pirepsjson'] = 0; |
|
| 180 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 181 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 182 | - //$formats[$id] = 'fr24json'; |
|
| 183 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 184 | - //$last_exec['fr24json'] = 0; |
|
| 185 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 186 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 187 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 188 | - exit(0); |
|
| 189 | - } |
|
| 190 | - //} else if (preg_match('/10001/',$host)) { |
|
| 191 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | - //$formats[$id] = 'tsv'; |
|
| 193 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 194 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 195 | - } |
|
| 196 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 197 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 198 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | - $hostport = explode(':',$host); |
|
| 200 | - if (isset($hostport[1])) { |
|
| 124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | + //$formats[$id] = 'deltadbtxt'; |
|
| 126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | + //$last_exec['deltadbtxt'] = 0; |
|
| 128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | + //$formats[$id] = 'vatsimtxt'; |
|
| 131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | + //$last_exec['vatsimtxt'] = 0; |
|
| 133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 145 | + //$formats[$id] = 'radarvirtueljson'; |
|
| 146 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 147 | + //$last_exec['radarvirtueljson'] = 0; |
|
| 148 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 149 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | + exit(0); |
|
| 152 | + } |
|
| 153 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 154 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 155 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 156 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 157 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 158 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 159 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 160 | + exit(0); |
|
| 161 | + } |
|
| 162 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 163 | + //$formats[$id] = 'phpvmacars'; |
|
| 164 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 165 | + //$last_exec['phpvmacars'] = 0; |
|
| 166 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 167 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 168 | + //$formats[$id] = 'phpvmacars'; |
|
| 169 | + $globalSources[$id]['format'] = 'vam'; |
|
| 170 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 171 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 172 | + //$formats[$id] = 'whazzup'; |
|
| 173 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 174 | + //$last_exec['whazzup'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 176 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 177 | + //$formats[$id] = 'pirepsjson'; |
|
| 178 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 179 | + //$last_exec['pirepsjson'] = 0; |
|
| 180 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 181 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 182 | + //$formats[$id] = 'fr24json'; |
|
| 183 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 184 | + //$last_exec['fr24json'] = 0; |
|
| 185 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 186 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 187 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 188 | + exit(0); |
|
| 189 | + } |
|
| 190 | + //} else if (preg_match('/10001/',$host)) { |
|
| 191 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | + //$formats[$id] = 'tsv'; |
|
| 193 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 194 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 195 | + } |
|
| 196 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 197 | + if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 198 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | + $hostport = explode(':',$host); |
|
| 200 | + if (isset($hostport[1])) { |
|
| 201 | 201 | $port = $hostport[1]; |
| 202 | 202 | $hostn = $hostport[0]; |
| 203 | - } else { |
|
| 203 | + } else { |
|
| 204 | 204 | $port = $globalSources[$id]['port']; |
| 205 | 205 | $hostn = $globalSources[$id]['host']; |
| 206 | - } |
|
| 207 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 208 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 209 | - } else { |
|
| 210 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 211 | - } |
|
| 212 | - if ($s) { |
|
| 213 | - $sockets[$id] = $s; |
|
| 214 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 215 | - if (preg_match('/aprs/',$hostn)) { |
|
| 206 | + } |
|
| 207 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 208 | + $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 209 | + } else { |
|
| 210 | + $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 211 | + } |
|
| 212 | + if ($s) { |
|
| 213 | + $sockets[$id] = $s; |
|
| 214 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 215 | + if (preg_match('/aprs/',$hostn)) { |
|
| 216 | 216 | //$formats[$id] = 'aprs'; |
| 217 | 217 | $globalSources[$id]['format'] = 'aprs'; |
| 218 | 218 | //$aprs_connect = 0; |
| 219 | 219 | //$use_aprs = true; |
| 220 | - } elseif ($port == '10001') { |
|
| 221 | - //$formats[$id] = 'tsv'; |
|
| 222 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 223 | - } elseif ($port == '30002') { |
|
| 224 | - //$formats[$id] = 'raw'; |
|
| 225 | - $globalSources[$id]['format'] = 'raw'; |
|
| 226 | - } elseif ($port == '5001') { |
|
| 227 | - //$formats[$id] = 'raw'; |
|
| 228 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 229 | - } elseif ($port == '30005') { |
|
| 220 | + } elseif ($port == '10001') { |
|
| 221 | + //$formats[$id] = 'tsv'; |
|
| 222 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 223 | + } elseif ($port == '30002') { |
|
| 224 | + //$formats[$id] = 'raw'; |
|
| 225 | + $globalSources[$id]['format'] = 'raw'; |
|
| 226 | + } elseif ($port == '5001') { |
|
| 227 | + //$formats[$id] = 'raw'; |
|
| 228 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 229 | + } elseif ($port == '30005') { |
|
| 230 | 230 | // Not yet supported |
| 231 | - //$formats[$id] = 'beast'; |
|
| 232 | - $globalSources[$id]['format'] = 'beast'; |
|
| 233 | - //} else $formats[$id] = 'sbs'; |
|
| 234 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 235 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 231 | + //$formats[$id] = 'beast'; |
|
| 232 | + $globalSources[$id]['format'] = 'beast'; |
|
| 233 | + //} else $formats[$id] = 'sbs'; |
|
| 234 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 235 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 236 | 236 | } |
| 237 | 237 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 238 | - } else { |
|
| 238 | + } else { |
|
| 239 | 239 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 240 | - } |
|
| 241 | - } |
|
| 242 | - } |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | 243 | } |
| 244 | 244 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 245 | 245 | |
@@ -266,18 +266,18 @@ discard block |
||
| 266 | 266 | die; |
| 267 | 267 | } |
| 268 | 268 | foreach ($globalSources as $key => $source) { |
| 269 | - if (!isset($source['format'])) { |
|
| 270 | - $globalSources[$key]['format'] = 'auto'; |
|
| 271 | - } |
|
| 269 | + if (!isset($source['format'])) { |
|
| 270 | + $globalSources[$key]['format'] = 'auto'; |
|
| 271 | + } |
|
| 272 | 272 | } |
| 273 | 273 | connect_all($globalSources); |
| 274 | 274 | foreach ($globalSources as $key => $source) { |
| 275 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 275 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 276 | 276 | $aprs_connect = 0; |
| 277 | 277 | $use_aprs = true; |
| 278 | 278 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 279 | 279 | break; |
| 280 | - } |
|
| 280 | + } |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | if ($use_aprs) { |
@@ -316,70 +316,70 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 318 | 318 | while ($i > 0) { |
| 319 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 320 | - // Delete old ATC |
|
| 321 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 319 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 320 | + // Delete old ATC |
|
| 321 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 322 | 322 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 323 | - $ATC->deleteOldATC(); |
|
| 324 | - } |
|
| 323 | + $ATC->deleteOldATC(); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - if (count($last_exec) > 0) { |
|
| 326 | + if (count($last_exec) > 0) { |
|
| 327 | 327 | $max = $globalMinFetch; |
| 328 | 328 | foreach ($last_exec as $last) { |
| 329 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 329 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 330 | 330 | } |
| 331 | 331 | if ($max != $globalMinFetch) { |
| 332 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 333 | - sleep($globalMinFetch-$max+2); |
|
| 332 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 333 | + sleep($globalMinFetch-$max+2); |
|
| 334 | + } |
|
| 334 | 335 | } |
| 335 | - } |
|
| 336 | 336 | |
| 337 | 337 | |
| 338 | - //foreach ($formats as $id => $value) { |
|
| 339 | - foreach ($globalSources as $id => $value) { |
|
| 338 | + //foreach ($formats as $id => $value) { |
|
| 339 | + foreach ($globalSources as $id => $value) { |
|
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 342 | 342 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 343 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 344 | - $buffer = $Common->getData($value['host']); |
|
| 345 | - if ($buffer != '') $reset = 0; |
|
| 346 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | - $buffer = explode('\n',$buffer); |
|
| 348 | - foreach ($buffer as $line) { |
|
| 349 | - if ($line != '' && count($line) > 7) { |
|
| 350 | - $line = explode(',', $line); |
|
| 351 | - $data = array(); |
|
| 352 | - $data['hex'] = $line[1]; // hex |
|
| 353 | - $data['ident'] = $line[2]; // ident |
|
| 354 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 359 | - $data['verticalrate'] = ''; // vertical rate |
|
| 360 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 361 | - $data['emergency'] = ''; // emergency |
|
| 362 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 363 | - $data['format_source'] = 'deltadbtxt'; |
|
| 364 | - $data['id_source'] = $id_source; |
|
| 365 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 367 | - $SI->add($data); |
|
| 368 | - unset($data); |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - $last_exec[$id]['last'] = time(); |
|
| 343 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 344 | + $buffer = $Common->getData($value['host']); |
|
| 345 | + if ($buffer != '') $reset = 0; |
|
| 346 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | + $buffer = explode('\n',$buffer); |
|
| 348 | + foreach ($buffer as $line) { |
|
| 349 | + if ($line != '' && count($line) > 7) { |
|
| 350 | + $line = explode(',', $line); |
|
| 351 | + $data = array(); |
|
| 352 | + $data['hex'] = $line[1]; // hex |
|
| 353 | + $data['ident'] = $line[2]; // ident |
|
| 354 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 359 | + $data['verticalrate'] = ''; // vertical rate |
|
| 360 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 361 | + $data['emergency'] = ''; // emergency |
|
| 362 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 363 | + $data['format_source'] = 'deltadbtxt'; |
|
| 364 | + $data['id_source'] = $id_source; |
|
| 365 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 367 | + $SI->add($data); |
|
| 368 | + unset($data); |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + $last_exec[$id]['last'] = time(); |
|
| 372 | 372 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 373 | 373 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 374 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 375 | - $buffer = $Common->getData($value['host']); |
|
| 376 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | - $buffer = explode('\n',$buffer); |
|
| 378 | - $reset = 0; |
|
| 379 | - foreach ($buffer as $line) { |
|
| 380 | - if ($line != '') { |
|
| 381 | - $line = explode(':', $line); |
|
| 382 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 374 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 375 | + $buffer = $Common->getData($value['host']); |
|
| 376 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | + $buffer = explode('\n',$buffer); |
|
| 378 | + $reset = 0; |
|
| 379 | + foreach ($buffer as $line) { |
|
| 380 | + if ($line != '') { |
|
| 381 | + $line = explode(':', $line); |
|
| 382 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 383 | 383 | $data = array(); |
| 384 | 384 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 385 | 385 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -392,36 +392,36 @@ discard block |
||
| 392 | 392 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 393 | 393 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 394 | 394 | $data['latitude'] = $line[5]; // lat |
| 395 | - $data['longitude'] = $line[6]; // long |
|
| 396 | - $data['verticalrate'] = ''; // vertical rate |
|
| 397 | - $data['squawk'] = ''; // squawk |
|
| 398 | - $data['emergency'] = ''; // emergency |
|
| 399 | - $data['waypoints'] = $line[30]; |
|
| 395 | + $data['longitude'] = $line[6]; // long |
|
| 396 | + $data['verticalrate'] = ''; // vertical rate |
|
| 397 | + $data['squawk'] = ''; // squawk |
|
| 398 | + $data['emergency'] = ''; // emergency |
|
| 399 | + $data['waypoints'] = $line[30]; |
|
| 400 | 400 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 401 | 401 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 402 | 402 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 403 | - $data['departure_airport_icao'] = $line[11]; |
|
| 404 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 405 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 403 | + $data['departure_airport_icao'] = $line[11]; |
|
| 404 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 405 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 406 | 406 | $data['frequency'] = $line[4]; |
| 407 | 407 | $data['type'] = $line[18]; |
| 408 | 408 | $data['range'] = $line[19]; |
| 409 | 409 | if (isset($line[35])) $data['info'] = $line[35]; |
| 410 | - $data['id_source'] = $id_source; |
|
| 411 | - //$data['arrival_airport_time'] = ; |
|
| 412 | - if ($line[9] != '') { |
|
| 413 | - $aircraft_data = explode('/',$line[9]); |
|
| 414 | - if (isset($aircraft_data[1])) { |
|
| 415 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - /* |
|
| 410 | + $data['id_source'] = $id_source; |
|
| 411 | + //$data['arrival_airport_time'] = ; |
|
| 412 | + if ($line[9] != '') { |
|
| 413 | + $aircraft_data = explode('/',$line[9]); |
|
| 414 | + if (isset($aircraft_data[1])) { |
|
| 415 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + /* |
|
| 419 | 419 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 420 | 420 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 421 | 421 | */ |
| 422 | - $data['format_source'] = $value['format']; |
|
| 422 | + $data['format_source'] = $value['format']; |
|
| 423 | 423 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 424 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 424 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 425 | 425 | elseif ($line[3] == 'ATC') { |
| 426 | 426 | //print_r($data); |
| 427 | 427 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -439,247 +439,247 @@ discard block |
||
| 439 | 439 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 440 | 440 | echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
| 441 | 441 | } |
| 442 | - unset($data); |
|
| 443 | - } |
|
| 444 | - } |
|
| 445 | - } |
|
| 446 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 447 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 448 | - $last_exec[$id]['last'] = time(); |
|
| 449 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 450 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 451 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 452 | - if ($buffer != '') { |
|
| 453 | - $all_data = json_decode($buffer,true); |
|
| 454 | - if (isset($all_data['acList'])) { |
|
| 442 | + unset($data); |
|
| 443 | + } |
|
| 444 | + } |
|
| 445 | + } |
|
| 446 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 447 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 448 | + $last_exec[$id]['last'] = time(); |
|
| 449 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 450 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 451 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 452 | + if ($buffer != '') { |
|
| 453 | + $all_data = json_decode($buffer,true); |
|
| 454 | + if (isset($all_data['acList'])) { |
|
| 455 | 455 | $reset = 0; |
| 456 | 456 | foreach ($all_data['acList'] as $line) { |
| 457 | - $data = array(); |
|
| 458 | - $data['hex'] = $line['Icao']; // hex |
|
| 459 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 460 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 461 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 462 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 463 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 464 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 465 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 466 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 467 | - $data['emergency'] = ''; // emergency |
|
| 468 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 469 | - /* |
|
| 457 | + $data = array(); |
|
| 458 | + $data['hex'] = $line['Icao']; // hex |
|
| 459 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 460 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 461 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 462 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 463 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 464 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 465 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 466 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 467 | + $data['emergency'] = ''; // emergency |
|
| 468 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 469 | + /* |
|
| 470 | 470 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 471 | 471 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 472 | 472 | */ |
| 473 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 474 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 475 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 476 | - $data['id_source'] = $id_source; |
|
| 477 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 478 | - if (isset($data['datetime'])) $SI->add($data); |
|
| 479 | - unset($data); |
|
| 473 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 474 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 475 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 476 | + $data['id_source'] = $id_source; |
|
| 477 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 478 | + if (isset($data['datetime'])) $SI->add($data); |
|
| 479 | + unset($data); |
|
| 480 | 480 | } |
| 481 | - } else { |
|
| 481 | + } else { |
|
| 482 | 482 | $reset = 0; |
| 483 | 483 | foreach ($all_data as $line) { |
| 484 | - $data = array(); |
|
| 485 | - $data['hex'] = $line['hex']; // hex |
|
| 486 | - $data['ident'] = $line['flight']; // ident |
|
| 487 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 488 | - $data['speed'] = $line['speed']; // speed |
|
| 489 | - $data['heading'] = $line['track']; // heading |
|
| 490 | - $data['latitude'] = $line['lat']; // lat |
|
| 491 | - $data['longitude'] = $line['lon']; // long |
|
| 492 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 493 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 494 | - $data['emergency'] = ''; // emergency |
|
| 495 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 496 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 497 | - $data['id_source'] = $id_source; |
|
| 498 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 499 | - $SI->add($data); |
|
| 500 | - unset($data); |
|
| 484 | + $data = array(); |
|
| 485 | + $data['hex'] = $line['hex']; // hex |
|
| 486 | + $data['ident'] = $line['flight']; // ident |
|
| 487 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 488 | + $data['speed'] = $line['speed']; // speed |
|
| 489 | + $data['heading'] = $line['track']; // heading |
|
| 490 | + $data['latitude'] = $line['lat']; // lat |
|
| 491 | + $data['longitude'] = $line['lon']; // long |
|
| 492 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 493 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 494 | + $data['emergency'] = ''; // emergency |
|
| 495 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 496 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 497 | + $data['id_source'] = $id_source; |
|
| 498 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 499 | + $SI->add($data); |
|
| 500 | + unset($data); |
|
| 501 | + } |
|
| 501 | 502 | } |
| 502 | - } |
|
| 503 | - } |
|
| 504 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 505 | - $last_exec[$id]['last'] = time(); |
|
| 506 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 507 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 508 | - $buffer = $Common->getData($value['host']); |
|
| 509 | - $all_data = json_decode($buffer,true); |
|
| 510 | - if (isset($all_data['planes'])) { |
|
| 503 | + } |
|
| 504 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 505 | + $last_exec[$id]['last'] = time(); |
|
| 506 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 507 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 508 | + $buffer = $Common->getData($value['host']); |
|
| 509 | + $all_data = json_decode($buffer,true); |
|
| 510 | + if (isset($all_data['planes'])) { |
|
| 511 | 511 | $reset = 0; |
| 512 | 512 | foreach ($all_data['planes'] as $key => $line) { |
| 513 | - $data = array(); |
|
| 514 | - $data['hex'] = $key; // hex |
|
| 515 | - $data['ident'] = $line[3]; // ident |
|
| 516 | - $data['altitude'] = $line[6]; // altitude |
|
| 517 | - $data['speed'] = $line[8]; // speed |
|
| 518 | - $data['heading'] = $line[7]; // heading |
|
| 519 | - $data['latitude'] = $line[4]; // lat |
|
| 520 | - $data['longitude'] = $line[5]; // long |
|
| 521 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 522 | - $data['squawk'] = $line[10]; // squawk |
|
| 523 | - $data['emergency'] = ''; // emergency |
|
| 524 | - $data['registration'] = $line[2]; |
|
| 525 | - $data['aircraft_icao'] = $line[0]; |
|
| 526 | - $deparr = explode('-',$line[1]); |
|
| 527 | - if (count($deparr) == 2) { |
|
| 513 | + $data = array(); |
|
| 514 | + $data['hex'] = $key; // hex |
|
| 515 | + $data['ident'] = $line[3]; // ident |
|
| 516 | + $data['altitude'] = $line[6]; // altitude |
|
| 517 | + $data['speed'] = $line[8]; // speed |
|
| 518 | + $data['heading'] = $line[7]; // heading |
|
| 519 | + $data['latitude'] = $line[4]; // lat |
|
| 520 | + $data['longitude'] = $line[5]; // long |
|
| 521 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 522 | + $data['squawk'] = $line[10]; // squawk |
|
| 523 | + $data['emergency'] = ''; // emergency |
|
| 524 | + $data['registration'] = $line[2]; |
|
| 525 | + $data['aircraft_icao'] = $line[0]; |
|
| 526 | + $deparr = explode('-',$line[1]); |
|
| 527 | + if (count($deparr) == 2) { |
|
| 528 | 528 | $data['departure_airport_icao'] = $deparr[0]; |
| 529 | 529 | $data['arrival_airport_icao'] = $deparr[1]; |
| 530 | - } |
|
| 531 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 532 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 533 | - $data['id_source'] = $id_source; |
|
| 534 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 535 | - $SI->add($data); |
|
| 536 | - unset($data); |
|
| 530 | + } |
|
| 531 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 532 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 533 | + $data['id_source'] = $id_source; |
|
| 534 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 535 | + $SI->add($data); |
|
| 536 | + unset($data); |
|
| 537 | + } |
|
| 537 | 538 | } |
| 538 | - } |
|
| 539 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 540 | - $last_exec[$id]['last'] = time(); |
|
| 541 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 542 | - $buffer = $Common->getData($value['host']); |
|
| 543 | - $all_data = json_decode($buffer,true); |
|
| 544 | - if (isset($all_data['states'])) { |
|
| 539 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 540 | + $last_exec[$id]['last'] = time(); |
|
| 541 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 542 | + $buffer = $Common->getData($value['host']); |
|
| 543 | + $all_data = json_decode($buffer,true); |
|
| 544 | + if (isset($all_data['states'])) { |
|
| 545 | 545 | $reset = 0; |
| 546 | 546 | foreach ($all_data['states'] as $key => $line) { |
| 547 | - $data = array(); |
|
| 548 | - $data['hex'] = $line[0]; // hex |
|
| 549 | - $data['ident'] = trim($line[1]); // ident |
|
| 550 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 551 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 552 | - $data['heading'] = round($line[10]); // heading |
|
| 553 | - $data['latitude'] = $line[5]; // lat |
|
| 554 | - $data['longitude'] = $line[6]; // long |
|
| 555 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 556 | - //$data['squawk'] = $line[10]; // squawk |
|
| 557 | - //$data['emergency'] = ''; // emergency |
|
| 558 | - //$data['registration'] = $line[2]; |
|
| 559 | - //$data['aircraft_icao'] = $line[0]; |
|
| 560 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 561 | - $data['format_source'] = 'opensky'; |
|
| 562 | - $data['id_source'] = $id_source; |
|
| 563 | - $SI->add($data); |
|
| 564 | - unset($data); |
|
| 547 | + $data = array(); |
|
| 548 | + $data['hex'] = $line[0]; // hex |
|
| 549 | + $data['ident'] = trim($line[1]); // ident |
|
| 550 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 551 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 552 | + $data['heading'] = round($line[10]); // heading |
|
| 553 | + $data['latitude'] = $line[5]; // lat |
|
| 554 | + $data['longitude'] = $line[6]; // long |
|
| 555 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 556 | + //$data['squawk'] = $line[10]; // squawk |
|
| 557 | + //$data['emergency'] = ''; // emergency |
|
| 558 | + //$data['registration'] = $line[2]; |
|
| 559 | + //$data['aircraft_icao'] = $line[0]; |
|
| 560 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 561 | + $data['format_source'] = 'opensky'; |
|
| 562 | + $data['id_source'] = $id_source; |
|
| 563 | + $SI->add($data); |
|
| 564 | + unset($data); |
|
| 565 | + } |
|
| 565 | 566 | } |
| 566 | - } |
|
| 567 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 568 | - $last_exec[$id]['last'] = time(); |
|
| 569 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 570 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 571 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 572 | - $buffer = $Common->getData($value['host']); |
|
| 573 | - $all_data = json_decode($buffer,true); |
|
| 574 | - if (!empty($all_data)) $reset = 0; |
|
| 575 | - foreach ($all_data as $key => $line) { |
|
| 567 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 568 | + $last_exec[$id]['last'] = time(); |
|
| 569 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 570 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 571 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 572 | + $buffer = $Common->getData($value['host']); |
|
| 573 | + $all_data = json_decode($buffer,true); |
|
| 574 | + if (!empty($all_data)) $reset = 0; |
|
| 575 | + foreach ($all_data as $key => $line) { |
|
| 576 | 576 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 577 | - $data = array(); |
|
| 578 | - $data['hex'] = $line[0]; |
|
| 579 | - $data['ident'] = $line[16]; //$line[13] |
|
| 580 | - $data['altitude'] = $line[4]; // altitude |
|
| 581 | - $data['speed'] = $line[5]; // speed |
|
| 582 | - $data['heading'] = $line[3]; // heading |
|
| 583 | - $data['latitude'] = $line[1]; // lat |
|
| 584 | - $data['longitude'] = $line[2]; // long |
|
| 585 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 586 | - $data['squawk'] = $line[6]; // squawk |
|
| 587 | - $data['aircraft_icao'] = $line[8]; |
|
| 588 | - $data['registration'] = $line[9]; |
|
| 589 | - $data['departure_airport_iata'] = $line[11]; |
|
| 590 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 591 | - $data['emergency'] = ''; // emergency |
|
| 592 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 593 | - $data['format_source'] = 'fr24json'; |
|
| 594 | - $data['id_source'] = $id_source; |
|
| 595 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 596 | - $SI->add($data); |
|
| 597 | - unset($data); |
|
| 577 | + $data = array(); |
|
| 578 | + $data['hex'] = $line[0]; |
|
| 579 | + $data['ident'] = $line[16]; //$line[13] |
|
| 580 | + $data['altitude'] = $line[4]; // altitude |
|
| 581 | + $data['speed'] = $line[5]; // speed |
|
| 582 | + $data['heading'] = $line[3]; // heading |
|
| 583 | + $data['latitude'] = $line[1]; // lat |
|
| 584 | + $data['longitude'] = $line[2]; // long |
|
| 585 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 586 | + $data['squawk'] = $line[6]; // squawk |
|
| 587 | + $data['aircraft_icao'] = $line[8]; |
|
| 588 | + $data['registration'] = $line[9]; |
|
| 589 | + $data['departure_airport_iata'] = $line[11]; |
|
| 590 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 591 | + $data['emergency'] = ''; // emergency |
|
| 592 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 593 | + $data['format_source'] = 'fr24json'; |
|
| 594 | + $data['id_source'] = $id_source; |
|
| 595 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 596 | + $SI->add($data); |
|
| 597 | + unset($data); |
|
| 598 | + } |
|
| 598 | 599 | } |
| 599 | - } |
|
| 600 | - //$last_exec['fr24json'] = time(); |
|
| 601 | - $last_exec[$id]['last'] = time(); |
|
| 602 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 603 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 604 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 605 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 606 | - //echo $buffer; |
|
| 607 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 608 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 609 | - $all_data = json_decode($buffer,true); |
|
| 610 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 600 | + //$last_exec['fr24json'] = time(); |
|
| 601 | + $last_exec[$id]['last'] = time(); |
|
| 602 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 603 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 604 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 605 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 606 | + //echo $buffer; |
|
| 607 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 608 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 609 | + $all_data = json_decode($buffer,true); |
|
| 610 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 611 | 611 | die(json_last_error_msg()); |
| 612 | - } |
|
| 613 | - if (isset($all_data['mrkrs'])) { |
|
| 612 | + } |
|
| 613 | + if (isset($all_data['mrkrs'])) { |
|
| 614 | 614 | $reset = 0; |
| 615 | 615 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 616 | - if (isset($line['inf'])) { |
|
| 616 | + if (isset($line['inf'])) { |
|
| 617 | 617 | $data = array(); |
| 618 | 618 | $data['hex'] = $line['inf']['ia']; |
| 619 | 619 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 620 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 621 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 622 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 623 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 624 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 625 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 626 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 627 | - //$data['aircraft_icao'] = $line[8]; |
|
| 628 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 620 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 621 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 622 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 623 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 624 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 625 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 626 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 627 | + //$data['aircraft_icao'] = $line[8]; |
|
| 628 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 629 | 629 | //$data['departure_airport_iata'] = $line[11]; |
| 630 | 630 | //$data['arrival_airport_iata'] = $line[12]; |
| 631 | - //$data['emergency'] = ''; // emergency |
|
| 631 | + //$data['emergency'] = ''; // emergency |
|
| 632 | 632 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 633 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 634 | - $data['id_source'] = $id_source; |
|
| 633 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 634 | + $data['id_source'] = $id_source; |
|
| 635 | 635 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 636 | 636 | $SI->add($data); |
| 637 | 637 | unset($data); |
| 638 | - } |
|
| 638 | + } |
|
| 639 | + } |
|
| 639 | 640 | } |
| 640 | - } |
|
| 641 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 642 | - $last_exec[$id]['last'] = time(); |
|
| 643 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 644 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 645 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 646 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 647 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 641 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 642 | + $last_exec[$id]['last'] = time(); |
|
| 643 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 644 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 645 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 646 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 647 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 648 | 648 | |
| 649 | - if (isset($all_data['pireps'])) { |
|
| 649 | + if (isset($all_data['pireps'])) { |
|
| 650 | 650 | $reset = 0; |
| 651 | - foreach ($all_data['pireps'] as $line) { |
|
| 652 | - $data = array(); |
|
| 653 | - $data['id'] = $line['id']; |
|
| 654 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 655 | - $data['ident'] = $line['callsign']; // ident |
|
| 656 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 657 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 658 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 659 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 660 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 661 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 662 | - $data['latitude'] = $line['lat']; // lat |
|
| 663 | - $data['longitude'] = $line['lon']; // long |
|
| 664 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 665 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 666 | - //$data['emergency'] = ''; // emergency |
|
| 667 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 668 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 669 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 670 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 671 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 672 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 673 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 674 | - else $data['info'] = ''; |
|
| 675 | - $data['format_source'] = 'pireps'; |
|
| 676 | - $data['id_source'] = $id_source; |
|
| 677 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 678 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 679 | - if ($line['icon'] == 'plane') { |
|
| 651 | + foreach ($all_data['pireps'] as $line) { |
|
| 652 | + $data = array(); |
|
| 653 | + $data['id'] = $line['id']; |
|
| 654 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 655 | + $data['ident'] = $line['callsign']; // ident |
|
| 656 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 657 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 658 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 659 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 660 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 661 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 662 | + $data['latitude'] = $line['lat']; // lat |
|
| 663 | + $data['longitude'] = $line['lon']; // long |
|
| 664 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 665 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 666 | + //$data['emergency'] = ''; // emergency |
|
| 667 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 668 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 669 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 670 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 671 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 672 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 673 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 674 | + else $data['info'] = ''; |
|
| 675 | + $data['format_source'] = 'pireps'; |
|
| 676 | + $data['id_source'] = $id_source; |
|
| 677 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 678 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 679 | + if ($line['icon'] == 'plane') { |
|
| 680 | 680 | $SI->add($data); |
| 681 | - // print_r($data); |
|
| 682 | - } elseif ($line['icon'] == 'ct') { |
|
| 681 | + // print_r($data); |
|
| 682 | + } elseif ($line['icon'] == 'ct') { |
|
| 683 | 683 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 684 | 684 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 685 | 685 | $typec = substr($data['ident'],-3); |
@@ -694,163 +694,163 @@ discard block |
||
| 694 | 694 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 695 | 695 | else $data['type'] = 'Observer'; |
| 696 | 696 | echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
| 697 | - } |
|
| 698 | - unset($data); |
|
| 697 | + } |
|
| 698 | + unset($data); |
|
| 699 | + } |
|
| 699 | 700 | } |
| 700 | - } |
|
| 701 | - //$last_exec['pirepsjson'] = time(); |
|
| 702 | - $last_exec[$id]['last'] = time(); |
|
| 703 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 704 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 705 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 706 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 707 | - $buffer = $Common->getData($value['host']); |
|
| 708 | - $all_data = json_decode($buffer,true); |
|
| 709 | - if ($buffer != '' && is_array($all_data)) { |
|
| 701 | + //$last_exec['pirepsjson'] = time(); |
|
| 702 | + $last_exec[$id]['last'] = time(); |
|
| 703 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 704 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 705 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 706 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 707 | + $buffer = $Common->getData($value['host']); |
|
| 708 | + $all_data = json_decode($buffer,true); |
|
| 709 | + if ($buffer != '' && is_array($all_data)) { |
|
| 710 | 710 | $reset = 0; |
| 711 | 711 | foreach ($all_data as $line) { |
| 712 | - $data = array(); |
|
| 713 | - //$data['id'] = $line['id']; // id not usable |
|
| 714 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 715 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 716 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 717 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 718 | - $data['ident'] = $line['flightnum']; // ident |
|
| 719 | - $data['altitude'] = $line['alt']; // altitude |
|
| 720 | - $data['speed'] = $line['gs']; // speed |
|
| 721 | - $data['heading'] = $line['heading']; // heading |
|
| 722 | - $data['latitude'] = $line['lat']; // lat |
|
| 723 | - $data['longitude'] = $line['lng']; // long |
|
| 724 | - $data['verticalrate'] = ''; // verticale rate |
|
| 725 | - $data['squawk'] = ''; // squawk |
|
| 726 | - $data['emergency'] = ''; // emergency |
|
| 727 | - //$data['datetime'] = $line['lastupdate']; |
|
| 728 | - $data['last_update'] = $line['lastupdate']; |
|
| 729 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 730 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 731 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 732 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 733 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 734 | - $data['registration'] = $line['aircraft']; |
|
| 735 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 736 | - if (isset($line['aircraftname'])) { |
|
| 712 | + $data = array(); |
|
| 713 | + //$data['id'] = $line['id']; // id not usable |
|
| 714 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 715 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 716 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 717 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 718 | + $data['ident'] = $line['flightnum']; // ident |
|
| 719 | + $data['altitude'] = $line['alt']; // altitude |
|
| 720 | + $data['speed'] = $line['gs']; // speed |
|
| 721 | + $data['heading'] = $line['heading']; // heading |
|
| 722 | + $data['latitude'] = $line['lat']; // lat |
|
| 723 | + $data['longitude'] = $line['lng']; // long |
|
| 724 | + $data['verticalrate'] = ''; // verticale rate |
|
| 725 | + $data['squawk'] = ''; // squawk |
|
| 726 | + $data['emergency'] = ''; // emergency |
|
| 727 | + //$data['datetime'] = $line['lastupdate']; |
|
| 728 | + $data['last_update'] = $line['lastupdate']; |
|
| 729 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 730 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 731 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 732 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 733 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 734 | + $data['registration'] = $line['aircraft']; |
|
| 735 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 736 | + if (isset($line['aircraftname'])) { |
|
| 737 | 737 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 738 | 738 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 739 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 740 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 741 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 742 | - else { |
|
| 743 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 744 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 745 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 749 | - $data['id_source'] = $id_source; |
|
| 750 | - $data['format_source'] = 'phpvmacars'; |
|
| 751 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 752 | - $SI->add($data); |
|
| 753 | - unset($data); |
|
| 739 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 740 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 741 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 742 | + else { |
|
| 743 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 744 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 745 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 749 | + $data['id_source'] = $id_source; |
|
| 750 | + $data['format_source'] = 'phpvmacars'; |
|
| 751 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 752 | + $SI->add($data); |
|
| 753 | + unset($data); |
|
| 754 | 754 | } |
| 755 | 755 | if ($globalDebug) echo 'No more data...'."\n"; |
| 756 | 756 | unset($buffer); |
| 757 | 757 | unset($all_data); |
| 758 | - } |
|
| 759 | - //$last_exec['phpvmacars'] = time(); |
|
| 760 | - $last_exec[$id]['last'] = time(); |
|
| 761 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 762 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 763 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 764 | - $buffer = $Common->getData($value['host']); |
|
| 765 | - $all_data = json_decode($buffer,true); |
|
| 766 | - if ($buffer != '' && is_array($all_data)) { |
|
| 758 | + } |
|
| 759 | + //$last_exec['phpvmacars'] = time(); |
|
| 760 | + $last_exec[$id]['last'] = time(); |
|
| 761 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 762 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 763 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 764 | + $buffer = $Common->getData($value['host']); |
|
| 765 | + $all_data = json_decode($buffer,true); |
|
| 766 | + if ($buffer != '' && is_array($all_data)) { |
|
| 767 | 767 | $reset = 0; |
| 768 | 768 | foreach ($all_data as $line) { |
| 769 | - $data = array(); |
|
| 770 | - //$data['id'] = $line['id']; // id not usable |
|
| 771 | - $data['id'] = trim($line['flight_id']); |
|
| 772 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 773 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 774 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 775 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 776 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 777 | - $data['speed'] = $line['gs']; // speed |
|
| 778 | - $data['heading'] = $line['heading']; // heading |
|
| 779 | - $data['latitude'] = $line['latitude']; // lat |
|
| 780 | - $data['longitude'] = $line['longitude']; // long |
|
| 781 | - $data['verticalrate'] = ''; // verticale rate |
|
| 782 | - $data['squawk'] = ''; // squawk |
|
| 783 | - $data['emergency'] = ''; // emergency |
|
| 784 | - //$data['datetime'] = $line['lastupdate']; |
|
| 785 | - $data['last_update'] = $line['last_update']; |
|
| 786 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 787 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 788 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 789 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 790 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 791 | - //$data['registration'] = $line['aircraft']; |
|
| 792 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 793 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 794 | - $data['id_source'] = $id_source; |
|
| 795 | - $data['format_source'] = 'vam'; |
|
| 796 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 797 | - $SI->add($data); |
|
| 798 | - unset($data); |
|
| 769 | + $data = array(); |
|
| 770 | + //$data['id'] = $line['id']; // id not usable |
|
| 771 | + $data['id'] = trim($line['flight_id']); |
|
| 772 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 773 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 774 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 775 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 776 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 777 | + $data['speed'] = $line['gs']; // speed |
|
| 778 | + $data['heading'] = $line['heading']; // heading |
|
| 779 | + $data['latitude'] = $line['latitude']; // lat |
|
| 780 | + $data['longitude'] = $line['longitude']; // long |
|
| 781 | + $data['verticalrate'] = ''; // verticale rate |
|
| 782 | + $data['squawk'] = ''; // squawk |
|
| 783 | + $data['emergency'] = ''; // emergency |
|
| 784 | + //$data['datetime'] = $line['lastupdate']; |
|
| 785 | + $data['last_update'] = $line['last_update']; |
|
| 786 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 787 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 788 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 789 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 790 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 791 | + //$data['registration'] = $line['aircraft']; |
|
| 792 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 793 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 794 | + $data['id_source'] = $id_source; |
|
| 795 | + $data['format_source'] = 'vam'; |
|
| 796 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 797 | + $SI->add($data); |
|
| 798 | + unset($data); |
|
| 799 | 799 | } |
| 800 | 800 | if ($globalDebug) echo 'No more data...'."\n"; |
| 801 | 801 | unset($buffer); |
| 802 | 802 | unset($all_data); |
| 803 | - } |
|
| 804 | - //$last_exec['phpvmacars'] = time(); |
|
| 805 | - $last_exec[$id]['last'] = time(); |
|
| 803 | + } |
|
| 804 | + //$last_exec['phpvmacars'] = time(); |
|
| 805 | + $last_exec[$id]['last'] = time(); |
|
| 806 | 806 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 807 | 807 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') { |
| 808 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 809 | - //$last_exec[$id]['last'] = time(); |
|
| 808 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 809 | + //$last_exec[$id]['last'] = time(); |
|
| 810 | 810 | |
| 811 | - //$read = array( $sockets[$id] ); |
|
| 812 | - $read = $sockets; |
|
| 813 | - $write = NULL; |
|
| 814 | - $e = NULL; |
|
| 815 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 816 | - if ($e != NULL) var_dump($e); |
|
| 817 | - if ($n > 0) { |
|
| 811 | + //$read = array( $sockets[$id] ); |
|
| 812 | + $read = $sockets; |
|
| 813 | + $write = NULL; |
|
| 814 | + $e = NULL; |
|
| 815 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 816 | + if ($e != NULL) var_dump($e); |
|
| 817 | + if ($n > 0) { |
|
| 818 | 818 | $reset = 0; |
| 819 | 819 | foreach ($read as $nb => $r) { |
| 820 | - //$value = $formats[$nb]; |
|
| 821 | - $format = $globalSources[$nb]['format']; |
|
| 822 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 823 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 824 | - } else { |
|
| 825 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 826 | - } |
|
| 827 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 828 | - //echo $buffer."\n"; |
|
| 829 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 830 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 831 | - $error = false; |
|
| 832 | - //$SI::del(); |
|
| 833 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 834 | - // SBS format is CSV format |
|
| 835 | - if ($buffer != '') { |
|
| 820 | + //$value = $formats[$nb]; |
|
| 821 | + $format = $globalSources[$nb]['format']; |
|
| 822 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 823 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 824 | + } else { |
|
| 825 | + $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 826 | + } |
|
| 827 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 828 | + //echo $buffer."\n"; |
|
| 829 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 830 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 831 | + $error = false; |
|
| 832 | + //$SI::del(); |
|
| 833 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 834 | + // SBS format is CSV format |
|
| 835 | + if ($buffer != '') { |
|
| 836 | 836 | $tt[$format] = 0; |
| 837 | 837 | if ($format == 'acarssbs3') { |
| 838 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 839 | - $ACARS->add(trim($buffer)); |
|
| 840 | - $ACARS->deleteLiveAcarsData(); |
|
| 838 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 839 | + $ACARS->add(trim($buffer)); |
|
| 840 | + $ACARS->deleteLiveAcarsData(); |
|
| 841 | 841 | } elseif ($format == 'raw') { |
| 842 | - // AVR format |
|
| 843 | - $data = $SBS->parse($buffer); |
|
| 844 | - if (is_array($data)) { |
|
| 842 | + // AVR format |
|
| 843 | + $data = $SBS->parse($buffer); |
|
| 844 | + if (is_array($data)) { |
|
| 845 | 845 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 846 | 846 | $data['format_source'] = 'raw'; |
| 847 | 847 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 848 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 849 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 850 | - } |
|
| 851 | - } elseif ($format == 'flightgearsp') { |
|
| 852 | - //echo $buffer."\n"; |
|
| 853 | - if (strlen($buffer) > 5) { |
|
| 848 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 849 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 850 | + } |
|
| 851 | + } elseif ($format == 'flightgearsp') { |
|
| 852 | + //echo $buffer."\n"; |
|
| 853 | + if (strlen($buffer) > 5) { |
|
| 854 | 854 | $line = explode(',',$buffer); |
| 855 | 855 | $data = array(); |
| 856 | 856 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -866,122 +866,122 @@ discard block |
||
| 866 | 866 | $data['format_source'] = 'flightgearsp'; |
| 867 | 867 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 868 | 868 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 869 | - } |
|
| 870 | - } elseif ($format == 'acars') { |
|
| 871 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 872 | - $ACARS->add(trim($buffer)); |
|
| 873 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 874 | - $ACARS->deleteLiveAcarsData(); |
|
| 869 | + } |
|
| 870 | + } elseif ($format == 'acars') { |
|
| 871 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 872 | + $ACARS->add(trim($buffer)); |
|
| 873 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 874 | + $ACARS->deleteLiveAcarsData(); |
|
| 875 | 875 | } elseif ($format == 'flightgearmp') { |
| 876 | - if (substr($buffer,0,1) != '#') { |
|
| 876 | + if (substr($buffer,0,1) != '#') { |
|
| 877 | 877 | $data = array(); |
| 878 | 878 | //echo $buffer."\n"; |
| 879 | 879 | $line = explode(' ',$buffer); |
| 880 | 880 | if (count($line) == 11) { |
| 881 | - $userserver = explode('@',$line[0]); |
|
| 882 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 883 | - $data['ident'] = $userserver[0]; |
|
| 884 | - $data['registration'] = $userserver[0]; |
|
| 885 | - $data['latitude'] = $line[4]; |
|
| 886 | - $data['longitude'] = $line[5]; |
|
| 887 | - $data['altitude'] = $line[6]; |
|
| 888 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 889 | - $aircraft_type = $line[10]; |
|
| 890 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 891 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 892 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 881 | + $userserver = explode('@',$line[0]); |
|
| 882 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 883 | + $data['ident'] = $userserver[0]; |
|
| 884 | + $data['registration'] = $userserver[0]; |
|
| 885 | + $data['latitude'] = $line[4]; |
|
| 886 | + $data['longitude'] = $line[5]; |
|
| 887 | + $data['altitude'] = $line[6]; |
|
| 888 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 889 | + $aircraft_type = $line[10]; |
|
| 890 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 891 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 892 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 893 | + } |
|
| 893 | 894 | } |
| 894 | - } |
|
| 895 | 895 | } elseif ($format == 'beast') { |
| 896 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 897 | - die; |
|
| 896 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 897 | + die; |
|
| 898 | 898 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 899 | - $line = explode("\t", $buffer); |
|
| 900 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 899 | + $line = explode("\t", $buffer); |
|
| 900 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 901 | 901 | $key = $line[$k]; |
| 902 | - $lined[$key] = $line[$k+1]; |
|
| 903 | - } |
|
| 904 | - if (count($lined) > 3) { |
|
| 905 | - $data['hex'] = $lined['hexid']; |
|
| 906 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 907 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 908 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 909 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 910 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 911 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 912 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 913 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 914 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 915 | - $data['id_source'] = $id_source; |
|
| 916 | - $data['format_source'] = 'tsv'; |
|
| 917 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 918 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 919 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 920 | - unset($lined); |
|
| 921 | - unset($data); |
|
| 922 | - } else $error = true; |
|
| 902 | + $lined[$key] = $line[$k+1]; |
|
| 903 | + } |
|
| 904 | + if (count($lined) > 3) { |
|
| 905 | + $data['hex'] = $lined['hexid']; |
|
| 906 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 907 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 908 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 909 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 910 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 911 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 912 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 913 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 914 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 915 | + $data['id_source'] = $id_source; |
|
| 916 | + $data['format_source'] = 'tsv'; |
|
| 917 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 918 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 919 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 920 | + unset($lined); |
|
| 921 | + unset($data); |
|
| 922 | + } else $error = true; |
|
| 923 | 923 | } elseif ($format == 'aprs' && $use_aprs) { |
| 924 | - if ($aprs_connect == 0) { |
|
| 924 | + if ($aprs_connect == 0) { |
|
| 925 | 925 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 926 | 926 | $aprs_connect = 1; |
| 927 | - } |
|
| 927 | + } |
|
| 928 | 928 | |
| 929 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 929 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 930 | 930 | $aprs_last_tx = time(); |
| 931 | 931 | $data_aprs = "# Keep alive"; |
| 932 | 932 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 933 | - } |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 936 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 937 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 938 | - //echo $buffer."\n"; |
|
| 939 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 935 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 936 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 937 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 938 | + //echo $buffer."\n"; |
|
| 939 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 940 | 940 | $line = $APRS->parse($buffer); |
| 941 | 941 | //print_r($line); |
| 942 | 942 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 943 | - $aprs_last_tx = time(); |
|
| 944 | - $data = array(); |
|
| 945 | - //print_r($line); |
|
| 946 | - $data['hex'] = $line['address']; |
|
| 947 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 948 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 949 | - $data['ident'] = $line['ident']; |
|
| 950 | - $data['latitude'] = $line['latitude']; |
|
| 951 | - $data['longitude'] = $line['longitude']; |
|
| 952 | - //$data['verticalrate'] = $line[16]; |
|
| 953 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 954 | - else $data['speed'] = 0; |
|
| 955 | - $data['altitude'] = $line['altitude']; |
|
| 956 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 957 | - //else $data['heading'] = 0; |
|
| 958 | - $data['aircraft_type'] = $line['stealth']; |
|
| 959 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 960 | - $data['id_source'] = $id_source; |
|
| 961 | - $data['format_source'] = 'aprs'; |
|
| 962 | - $data['source_name'] = $line['source']; |
|
| 963 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 964 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 965 | - $aprsdate = strtotime($data['datetime']); |
|
| 966 | - // Accept data if time <= system time + 20s |
|
| 967 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
| 968 | - else { |
|
| 943 | + $aprs_last_tx = time(); |
|
| 944 | + $data = array(); |
|
| 945 | + //print_r($line); |
|
| 946 | + $data['hex'] = $line['address']; |
|
| 947 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 948 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 949 | + $data['ident'] = $line['ident']; |
|
| 950 | + $data['latitude'] = $line['latitude']; |
|
| 951 | + $data['longitude'] = $line['longitude']; |
|
| 952 | + //$data['verticalrate'] = $line[16]; |
|
| 953 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 954 | + else $data['speed'] = 0; |
|
| 955 | + $data['altitude'] = $line['altitude']; |
|
| 956 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 957 | + //else $data['heading'] = 0; |
|
| 958 | + $data['aircraft_type'] = $line['stealth']; |
|
| 959 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 960 | + $data['id_source'] = $id_source; |
|
| 961 | + $data['format_source'] = 'aprs'; |
|
| 962 | + $data['source_name'] = $line['source']; |
|
| 963 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 964 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 965 | + $aprsdate = strtotime($data['datetime']); |
|
| 966 | + // Accept data if time <= system time + 20s |
|
| 967 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
| 968 | + else { |
|
| 969 | 969 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 970 | 970 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 971 | - } |
|
| 972 | - unset($data); |
|
| 971 | + } |
|
| 972 | + unset($data); |
|
| 973 | 973 | } |
| 974 | 974 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
| 975 | 975 | echo '!! Weather Station not yet supported'."\n"; |
| 976 | 976 | } |
| 977 | 977 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 978 | 978 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 979 | - } |
|
| 979 | + } |
|
| 980 | 980 | } else { |
| 981 | - $line = explode(',', $buffer); |
|
| 982 | - if (count($line) > 20) { |
|
| 983 | - $data['hex'] = $line[4]; |
|
| 984 | - /* |
|
| 981 | + $line = explode(',', $buffer); |
|
| 982 | + if (count($line) > 20) { |
|
| 983 | + $data['hex'] = $line[4]; |
|
| 984 | + /* |
|
| 985 | 985 | $data['datetime'] = $line[6].' '.$line[7]; |
| 986 | 986 | date_default_timezone_set($globalTimezone); |
| 987 | 987 | $datetime = new DateTime($data['datetime']); |
@@ -989,29 +989,29 @@ discard block |
||
| 989 | 989 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 990 | 990 | date_default_timezone_set('UTC'); |
| 991 | 991 | */ |
| 992 | - // Force datetime to current UTC datetime |
|
| 993 | - date_default_timezone_set('UTC'); |
|
| 994 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 995 | - $data['ident'] = trim($line[10]); |
|
| 996 | - $data['latitude'] = $line[14]; |
|
| 997 | - $data['longitude'] = $line[15]; |
|
| 998 | - $data['verticalrate'] = $line[16]; |
|
| 999 | - $data['emergency'] = $line[20]; |
|
| 1000 | - $data['speed'] = $line[12]; |
|
| 1001 | - $data['squawk'] = $line[17]; |
|
| 1002 | - $data['altitude'] = $line[11]; |
|
| 1003 | - $data['heading'] = $line[13]; |
|
| 1004 | - $data['ground'] = $line[21]; |
|
| 1005 | - $data['emergency'] = $line[19]; |
|
| 1006 | - $data['format_source'] = 'sbs'; |
|
| 992 | + // Force datetime to current UTC datetime |
|
| 993 | + date_default_timezone_set('UTC'); |
|
| 994 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 995 | + $data['ident'] = trim($line[10]); |
|
| 996 | + $data['latitude'] = $line[14]; |
|
| 997 | + $data['longitude'] = $line[15]; |
|
| 998 | + $data['verticalrate'] = $line[16]; |
|
| 999 | + $data['emergency'] = $line[20]; |
|
| 1000 | + $data['speed'] = $line[12]; |
|
| 1001 | + $data['squawk'] = $line[17]; |
|
| 1002 | + $data['altitude'] = $line[11]; |
|
| 1003 | + $data['heading'] = $line[13]; |
|
| 1004 | + $data['ground'] = $line[21]; |
|
| 1005 | + $data['emergency'] = $line[19]; |
|
| 1006 | + $data['format_source'] = 'sbs'; |
|
| 1007 | 1007 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1008 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1009 | - $data['id_source'] = $id_source; |
|
| 1010 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1011 | - else $error = true; |
|
| 1012 | - unset($data); |
|
| 1013 | - } else $error = true; |
|
| 1014 | - if ($error) { |
|
| 1008 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1009 | + $data['id_source'] = $id_source; |
|
| 1010 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1011 | + else $error = true; |
|
| 1012 | + unset($data); |
|
| 1013 | + } else $error = true; |
|
| 1014 | + if ($error) { |
|
| 1015 | 1015 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1016 | 1016 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1017 | 1017 | } else { |
@@ -1027,13 +1027,13 @@ discard block |
||
| 1027 | 1027 | connect_all($sourceer); |
| 1028 | 1028 | $sourceer = array(); |
| 1029 | 1029 | } |
| 1030 | - } |
|
| 1030 | + } |
|
| 1031 | 1031 | } |
| 1032 | 1032 | // Sleep for xxx microseconds |
| 1033 | 1033 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1034 | - } else { |
|
| 1034 | + } else { |
|
| 1035 | 1035 | if ($format == 'flightgearmp') { |
| 1036 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1036 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1037 | 1037 | //@socket_close($r); |
| 1038 | 1038 | sleep($globalMinFetch); |
| 1039 | 1039 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1042,9 +1042,9 @@ discard block |
||
| 1042 | 1042 | break; |
| 1043 | 1043 | |
| 1044 | 1044 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1045 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1046 | - else $tt[$format] = 0; |
|
| 1047 | - if ($tt[$format] > 30) { |
|
| 1045 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1046 | + else $tt[$format] = 0; |
|
| 1047 | + if ($tt[$format] > 30) { |
|
| 1048 | 1048 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1049 | 1049 | //@socket_close($r); |
| 1050 | 1050 | sleep(2); |
@@ -1055,23 +1055,23 @@ discard block |
||
| 1055 | 1055 | //connect_all($globalSources); |
| 1056 | 1056 | $tt[$format]=0; |
| 1057 | 1057 | break; |
| 1058 | - } |
|
| 1058 | + } |
|
| 1059 | + } |
|
| 1059 | 1060 | } |
| 1060 | - } |
|
| 1061 | 1061 | } |
| 1062 | - } else { |
|
| 1062 | + } else { |
|
| 1063 | 1063 | $error = socket_strerror(socket_last_error()); |
| 1064 | 1064 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1065 | 1065 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
| 1066 | 1066 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1067 | 1067 | // Restart the script if possible |
| 1068 | 1068 | if (is_array($sockets)) { |
| 1069 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1069 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1070 | 1070 | |
| 1071 | - foreach ($sockets as $sock) { |
|
| 1071 | + foreach ($sockets as $sock) { |
|
| 1072 | 1072 | @socket_shutdown($sock,2); |
| 1073 | 1073 | @socket_close($sock); |
| 1074 | - } |
|
| 1074 | + } |
|
| 1075 | 1075 | |
| 1076 | 1076 | } |
| 1077 | 1077 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1082,13 +1082,13 @@ discard block |
||
| 1082 | 1082 | if ($reset > 40) exit('Too many attempts...'); |
| 1083 | 1083 | connect_all($globalSources); |
| 1084 | 1084 | } |
| 1085 | - } |
|
| 1085 | + } |
|
| 1086 | 1086 | } |
| 1087 | 1087 | if ($globalDaemon === false) { |
| 1088 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1089 | - $SI->checkAll(); |
|
| 1088 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1089 | + $SI->checkAll(); |
|
| 1090 | + } |
|
| 1090 | 1091 | } |
| 1091 | - } |
|
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | ?> |
@@ -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,109 +50,109 @@ 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 = '') { |
|
| 62 | - if ($filter_name == '') { |
|
| 63 | - $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
| 64 | - } else { |
|
| 65 | - $query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'"; |
|
| 66 | - } |
|
| 67 | - try { |
|
| 68 | - $sth = $this->db->prepare($query); |
|
| 69 | - $sth->execute(); |
|
| 70 | - } catch(PDOException $e) { |
|
| 71 | - return "error : ".$e->getMessage(); |
|
| 72 | - } |
|
| 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 | + if ($filter_name == '') { |
|
| 63 | + $query = "DELETE FROM config WHERE name = 'last_update_stats'"; |
|
| 64 | + } else { |
|
| 65 | + $query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'"; |
|
| 66 | + } |
|
| 67 | + try { |
|
| 68 | + $sth = $this->db->prepare($query); |
|
| 69 | + $sth->execute(); |
|
| 70 | + } catch(PDOException $e) { |
|
| 71 | + return "error : ".$e->getMessage(); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $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;"; |
|
| 75 | - try { |
|
| 76 | - $sth = $this->db->prepare($query); |
|
| 77 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
| 78 | - } catch(PDOException $e) { |
|
| 79 | - return "error : ".$e->getMessage(); |
|
| 80 | - } |
|
| 81 | - } |
|
| 74 | + $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;"; |
|
| 75 | + try { |
|
| 76 | + $sth = $this->db->prepare($query); |
|
| 77 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
| 78 | + } catch(PDOException $e) { |
|
| 79 | + return "error : ".$e->getMessage(); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | public function getAllAirlineNames($filter_name = '') { |
| 83 | 83 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 84 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
| 85 | - try { |
|
| 86 | - $sth = $this->db->prepare($query); |
|
| 87 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
| 88 | - } catch(PDOException $e) { |
|
| 89 | - echo "error : ".$e->getMessage(); |
|
| 90 | - } |
|
| 91 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 92 | - return $all; |
|
| 93 | - } |
|
| 84 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
| 85 | + try { |
|
| 86 | + $sth = $this->db->prepare($query); |
|
| 87 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
| 88 | + } catch(PDOException $e) { |
|
| 89 | + echo "error : ".$e->getMessage(); |
|
| 90 | + } |
|
| 91 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 92 | + return $all; |
|
| 93 | + } |
|
| 94 | 94 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 95 | 95 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 96 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
| 97 | - try { |
|
| 98 | - $sth = $this->db->prepare($query); |
|
| 99 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 100 | - } catch(PDOException $e) { |
|
| 101 | - echo "error : ".$e->getMessage(); |
|
| 102 | - } |
|
| 103 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 104 | - return $all; |
|
| 105 | - } |
|
| 96 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
| 97 | + try { |
|
| 98 | + $sth = $this->db->prepare($query); |
|
| 99 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 100 | + } catch(PDOException $e) { |
|
| 101 | + echo "error : ".$e->getMessage(); |
|
| 102 | + } |
|
| 103 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 104 | + return $all; |
|
| 105 | + } |
|
| 106 | 106 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 107 | 107 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 108 | - $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"; |
|
| 109 | - try { |
|
| 110 | - $sth = $this->db->prepare($query); |
|
| 111 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 112 | - } catch(PDOException $e) { |
|
| 113 | - echo "error : ".$e->getMessage(); |
|
| 114 | - } |
|
| 115 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 116 | - return $all; |
|
| 117 | - } |
|
| 108 | + $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"; |
|
| 109 | + try { |
|
| 110 | + $sth = $this->db->prepare($query); |
|
| 111 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 112 | + } catch(PDOException $e) { |
|
| 113 | + echo "error : ".$e->getMessage(); |
|
| 114 | + } |
|
| 115 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 116 | + return $all; |
|
| 117 | + } |
|
| 118 | 118 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
| 119 | 119 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 120 | - $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"; |
|
| 121 | - try { |
|
| 122 | - $sth = $this->db->prepare($query); |
|
| 123 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 124 | - } catch(PDOException $e) { |
|
| 125 | - echo "error : ".$e->getMessage(); |
|
| 126 | - } |
|
| 127 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 128 | - return $all; |
|
| 129 | - } |
|
| 120 | + $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"; |
|
| 121 | + try { |
|
| 122 | + $sth = $this->db->prepare($query); |
|
| 123 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 124 | + } catch(PDOException $e) { |
|
| 125 | + echo "error : ".$e->getMessage(); |
|
| 126 | + } |
|
| 127 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 128 | + return $all; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
| 132 | 132 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 133 | - $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
|
| 134 | - try { |
|
| 135 | - $sth = $this->db->prepare($query); |
|
| 136 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 137 | - } catch(PDOException $e) { |
|
| 138 | - echo "error : ".$e->getMessage(); |
|
| 139 | - } |
|
| 140 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 141 | - return $all; |
|
| 142 | - } |
|
| 133 | + $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
|
| 134 | + try { |
|
| 135 | + $sth = $this->db->prepare($query); |
|
| 136 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 137 | + } catch(PDOException $e) { |
|
| 138 | + echo "error : ".$e->getMessage(); |
|
| 139 | + } |
|
| 140 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 141 | + return $all; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
| 145 | 145 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 146 | - $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
|
| 147 | - try { |
|
| 148 | - $sth = $this->db->prepare($query); |
|
| 149 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 150 | - } catch(PDOException $e) { |
|
| 151 | - echo "error : ".$e->getMessage(); |
|
| 152 | - } |
|
| 153 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 154 | - return $all; |
|
| 155 | - } |
|
| 146 | + $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
|
| 147 | + try { |
|
| 148 | + $sth = $this->db->prepare($query); |
|
| 149 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 150 | + } catch(PDOException $e) { |
|
| 151 | + echo "error : ".$e->getMessage(); |
|
| 152 | + } |
|
| 153 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 154 | + return $all; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
@@ -169,16 +169,16 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 171 | 171 | } else $all = array(); |
| 172 | - if (empty($all)) { |
|
| 173 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 174 | - if ($filter_name != '') { |
|
| 175 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 176 | - } |
|
| 177 | - $Spotter = new Spotter($this->db); |
|
| 178 | - //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
| 179 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
| 180 | - } |
|
| 181 | - return $all; |
|
| 172 | + if (empty($all)) { |
|
| 173 | + $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 174 | + if ($filter_name != '') { |
|
| 175 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 176 | + } |
|
| 177 | + $Spotter = new Spotter($this->db); |
|
| 178 | + //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
| 179 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
| 180 | + } |
|
| 181 | + return $all; |
|
| 182 | 182 | } |
| 183 | 183 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
| 184 | 184 | global $globalStatsFilters; |
@@ -194,17 +194,17 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 196 | 196 | } else $all = array(); |
| 197 | - if (empty($all)) { |
|
| 198 | - $Spotter = new Spotter($this->db); |
|
| 199 | - $filters = array(); |
|
| 200 | - $filters = array('year' => $year,'month' => $month); |
|
| 201 | - if ($filter_name != '') { |
|
| 202 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 203 | - } |
|
| 204 | - //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
| 205 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
| 206 | - } |
|
| 207 | - return $all; |
|
| 197 | + if (empty($all)) { |
|
| 198 | + $Spotter = new Spotter($this->db); |
|
| 199 | + $filters = array(); |
|
| 200 | + $filters = array('year' => $year,'month' => $month); |
|
| 201 | + if ($filter_name != '') { |
|
| 202 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 203 | + } |
|
| 204 | + //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
| 205 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
| 206 | + } |
|
| 207 | + return $all; |
|
| 208 | 208 | } |
| 209 | 209 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 210 | 210 | global $globalStatsFilters; |
@@ -246,39 +246,39 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 248 | 248 | } else $all = array(); |
| 249 | - if (empty($all)) { |
|
| 249 | + if (empty($all)) { |
|
| 250 | 250 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 251 | 251 | if ($filter_name != '') { |
| 252 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 252 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 253 | 253 | } |
| 254 | 254 | $Spotter = new Spotter($this->db); |
| 255 | 255 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
| 256 | 256 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
| 257 | - } |
|
| 258 | - return $all; |
|
| 257 | + } |
|
| 258 | + return $all; |
|
| 259 | 259 | } |
| 260 | 260 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 261 | 261 | global $globalStatsFilters; |
| 262 | 262 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 263 | 263 | 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"; |
| 264 | 264 | 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"; |
| 265 | - try { |
|
| 266 | - $sth = $this->db->prepare($query); |
|
| 267 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 268 | - } catch(PDOException $e) { |
|
| 269 | - echo "error : ".$e->getMessage(); |
|
| 270 | - } |
|
| 271 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 272 | - if (empty($all)) { |
|
| 265 | + try { |
|
| 266 | + $sth = $this->db->prepare($query); |
|
| 267 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 268 | + } catch(PDOException $e) { |
|
| 269 | + echo "error : ".$e->getMessage(); |
|
| 270 | + } |
|
| 271 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 272 | + if (empty($all)) { |
|
| 273 | 273 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 274 | 274 | if ($filter_name != '') { |
| 275 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 275 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 276 | 276 | } |
| 277 | 277 | $Spotter = new Spotter($this->db); |
| 278 | 278 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
| 279 | 279 | $all = $Spotter->countAllDepartureCountries($filters); |
| 280 | - } |
|
| 281 | - return $all; |
|
| 280 | + } |
|
| 281 | + return $all; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
@@ -304,17 +304,17 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 306 | 306 | } else $all = array(); |
| 307 | - if (empty($all)) { |
|
| 308 | - $Spotter = new Spotter($this->db); |
|
| 309 | - $filters = array(); |
|
| 307 | + if (empty($all)) { |
|
| 308 | + $Spotter = new Spotter($this->db); |
|
| 309 | + $filters = array(); |
|
| 310 | 310 | $filters = array('year' => $year,'month' => $month); |
| 311 | - if ($filter_name != '') { |
|
| 312 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 311 | + if ($filter_name != '') { |
|
| 312 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 313 | 313 | } |
| 314 | 314 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
| 315 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 316 | - } |
|
| 317 | - return $all; |
|
| 315 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 316 | + } |
|
| 317 | + return $all; |
|
| 318 | 318 | } |
| 319 | 319 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 320 | 320 | global $globalStatsFilters; |
@@ -330,16 +330,16 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 332 | 332 | } else $all = array(); |
| 333 | - if (empty($all)) { |
|
| 333 | + if (empty($all)) { |
|
| 334 | 334 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 335 | 335 | if ($filter_name != '') { |
| 336 | 336 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
| 337 | 337 | } |
| 338 | - $Spotter = new Spotter($this->db); |
|
| 339 | - //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
| 340 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
| 341 | - } |
|
| 342 | - return $all; |
|
| 338 | + $Spotter = new Spotter($this->db); |
|
| 339 | + //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
| 340 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
| 341 | + } |
|
| 342 | + return $all; |
|
| 343 | 343 | } |
| 344 | 344 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 345 | 345 | global $globalStatsFilters; |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | echo "error : ".$e->getMessage(); |
| 381 | 381 | } |
| 382 | 382 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 383 | - /* |
|
| 383 | + /* |
|
| 384 | 384 | if (empty($all)) { |
| 385 | 385 | $Spotter = new Spotter($this->db); |
| 386 | 386 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -432,16 +432,16 @@ discard block |
||
| 432 | 432 | } |
| 433 | 433 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 434 | 434 | } else $all = array(); |
| 435 | - if (empty($all)) { |
|
| 435 | + if (empty($all)) { |
|
| 436 | 436 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 437 | 437 | if ($filter_name != '') { |
| 438 | 438 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
| 439 | 439 | } |
| 440 | - $Spotter = new Spotter($this->db); |
|
| 441 | - //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
| 442 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
| 443 | - } |
|
| 444 | - return $all; |
|
| 440 | + $Spotter = new Spotter($this->db); |
|
| 441 | + //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
| 442 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
| 443 | + } |
|
| 444 | + return $all; |
|
| 445 | 445 | } |
| 446 | 446 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 447 | 447 | global $globalStatsFilters; |
@@ -457,35 +457,35 @@ discard block |
||
| 457 | 457 | } |
| 458 | 458 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 459 | 459 | } else $all = array(); |
| 460 | - if (empty($all)) { |
|
| 460 | + if (empty($all)) { |
|
| 461 | 461 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 462 | - if ($filter_name != '') { |
|
| 463 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 462 | + if ($filter_name != '') { |
|
| 463 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 464 | 464 | } |
| 465 | - $Spotter = new Spotter($this->db); |
|
| 465 | + $Spotter = new Spotter($this->db); |
|
| 466 | 466 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
| 467 | 467 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
| 468 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
| 469 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
| 470 | - $all = array(); |
|
| 471 | - foreach ($pall as $value) { |
|
| 472 | - $icao = $value['airport_departure_icao']; |
|
| 473 | - $all[$icao] = $value; |
|
| 474 | - } |
|
| 468 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
| 469 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
| 470 | + $all = array(); |
|
| 471 | + foreach ($pall as $value) { |
|
| 472 | + $icao = $value['airport_departure_icao']; |
|
| 473 | + $all[$icao] = $value; |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - foreach ($dall as $value) { |
|
| 477 | - $icao = $value['airport_departure_icao']; |
|
| 478 | - if (isset($all[$icao])) { |
|
| 479 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
| 480 | - } else $all[$icao] = $value; |
|
| 481 | - } |
|
| 482 | - $count = array(); |
|
| 483 | - foreach ($all as $key => $row) { |
|
| 484 | - $count[$key] = $row['airport_departure_icao_count']; |
|
| 485 | - } |
|
| 486 | - array_multisort($count,SORT_DESC,$all); |
|
| 487 | - } |
|
| 488 | - return $all; |
|
| 476 | + foreach ($dall as $value) { |
|
| 477 | + $icao = $value['airport_departure_icao']; |
|
| 478 | + if (isset($all[$icao])) { |
|
| 479 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
| 480 | + } else $all[$icao] = $value; |
|
| 481 | + } |
|
| 482 | + $count = array(); |
|
| 483 | + foreach ($all as $key => $row) { |
|
| 484 | + $count[$key] = $row['airport_departure_icao_count']; |
|
| 485 | + } |
|
| 486 | + array_multisort($count,SORT_DESC,$all); |
|
| 487 | + } |
|
| 488 | + return $all; |
|
| 489 | 489 | } |
| 490 | 490 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 491 | 491 | global $globalStatsFilters; |
@@ -511,26 +511,26 @@ discard block |
||
| 511 | 511 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
| 512 | 512 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
| 513 | 513 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
| 514 | - $all = array(); |
|
| 515 | - foreach ($pall as $value) { |
|
| 516 | - $icao = $value['airport_arrival_icao']; |
|
| 517 | - $all[$icao] = $value; |
|
| 518 | - } |
|
| 514 | + $all = array(); |
|
| 515 | + foreach ($pall as $value) { |
|
| 516 | + $icao = $value['airport_arrival_icao']; |
|
| 517 | + $all[$icao] = $value; |
|
| 518 | + } |
|
| 519 | 519 | |
| 520 | - foreach ($dall as $value) { |
|
| 521 | - $icao = $value['airport_arrival_icao']; |
|
| 522 | - if (isset($all[$icao])) { |
|
| 523 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
| 524 | - } else $all[$icao] = $value; |
|
| 525 | - } |
|
| 526 | - $count = array(); |
|
| 527 | - foreach ($all as $key => $row) { |
|
| 528 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
| 529 | - } |
|
| 530 | - array_multisort($count,SORT_DESC,$all); |
|
| 531 | - } |
|
| 520 | + foreach ($dall as $value) { |
|
| 521 | + $icao = $value['airport_arrival_icao']; |
|
| 522 | + if (isset($all[$icao])) { |
|
| 523 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
| 524 | + } else $all[$icao] = $value; |
|
| 525 | + } |
|
| 526 | + $count = array(); |
|
| 527 | + foreach ($all as $key => $row) { |
|
| 528 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
| 529 | + } |
|
| 530 | + array_multisort($count,SORT_DESC,$all); |
|
| 531 | + } |
|
| 532 | 532 | |
| 533 | - return $all; |
|
| 533 | + return $all; |
|
| 534 | 534 | } |
| 535 | 535 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 536 | 536 | global $globalDBdriver, $globalStatsFilters; |
@@ -543,23 +543,23 @@ discard block |
||
| 543 | 543 | 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"; |
| 544 | 544 | } |
| 545 | 545 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 546 | - try { |
|
| 547 | - $sth = $this->db->prepare($query); |
|
| 548 | - $sth->execute($query_data); |
|
| 549 | - } catch(PDOException $e) { |
|
| 550 | - echo "error : ".$e->getMessage(); |
|
| 551 | - } |
|
| 552 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 553 | - if (empty($all)) { |
|
| 546 | + try { |
|
| 547 | + $sth = $this->db->prepare($query); |
|
| 548 | + $sth->execute($query_data); |
|
| 549 | + } catch(PDOException $e) { |
|
| 550 | + echo "error : ".$e->getMessage(); |
|
| 551 | + } |
|
| 552 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 553 | + if (empty($all)) { |
|
| 554 | 554 | $filters = array('airlines' => array($stats_airline)); |
| 555 | 555 | if ($filter_name != '') { |
| 556 | 556 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
| 557 | 557 | } |
| 558 | - $Spotter = new Spotter($this->db); |
|
| 559 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
| 560 | - } |
|
| 558 | + $Spotter = new Spotter($this->db); |
|
| 559 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
| 560 | + } |
|
| 561 | 561 | |
| 562 | - return $all; |
|
| 562 | + return $all; |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -567,22 +567,22 @@ discard block |
||
| 567 | 567 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 568 | 568 | $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"; |
| 569 | 569 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 570 | - try { |
|
| 571 | - $sth = $this->db->prepare($query); |
|
| 572 | - $sth->execute($query_data); |
|
| 573 | - } catch(PDOException $e) { |
|
| 574 | - echo "error : ".$e->getMessage(); |
|
| 575 | - } |
|
| 576 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 577 | - if (empty($all)) { |
|
| 570 | + try { |
|
| 571 | + $sth = $this->db->prepare($query); |
|
| 572 | + $sth->execute($query_data); |
|
| 573 | + } catch(PDOException $e) { |
|
| 574 | + echo "error : ".$e->getMessage(); |
|
| 575 | + } |
|
| 576 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 577 | + if (empty($all)) { |
|
| 578 | 578 | $filters = array('airlines' => array($stats_airline)); |
| 579 | 579 | if ($filter_name != '') { |
| 580 | 580 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
| 581 | 581 | } |
| 582 | - $Spotter = new Spotter($this->db); |
|
| 583 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
| 584 | - } |
|
| 585 | - return $all; |
|
| 582 | + $Spotter = new Spotter($this->db); |
|
| 583 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
| 584 | + } |
|
| 585 | + return $all; |
|
| 586 | 586 | } |
| 587 | 587 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 588 | 588 | global $globalDBdriver, $globalStatsFilters; |
@@ -593,110 +593,110 @@ discard block |
||
| 593 | 593 | $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"; |
| 594 | 594 | } |
| 595 | 595 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 596 | - try { |
|
| 597 | - $sth = $this->db->prepare($query); |
|
| 598 | - $sth->execute($query_data); |
|
| 599 | - } catch(PDOException $e) { |
|
| 600 | - echo "error : ".$e->getMessage(); |
|
| 601 | - } |
|
| 602 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 603 | - if (empty($all)) { |
|
| 596 | + try { |
|
| 597 | + $sth = $this->db->prepare($query); |
|
| 598 | + $sth->execute($query_data); |
|
| 599 | + } catch(PDOException $e) { |
|
| 600 | + echo "error : ".$e->getMessage(); |
|
| 601 | + } |
|
| 602 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 603 | + if (empty($all)) { |
|
| 604 | 604 | $filters = array('airlines' => array($stats_airline)); |
| 605 | 605 | if ($filter_name != '') { |
| 606 | 606 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
| 607 | 607 | } |
| 608 | - $Spotter = new Spotter($this->db); |
|
| 609 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
| 610 | - } |
|
| 611 | - return $all; |
|
| 608 | + $Spotter = new Spotter($this->db); |
|
| 609 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
| 610 | + } |
|
| 611 | + return $all; |
|
| 612 | 612 | } |
| 613 | 613 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 614 | 614 | global $globalStatsFilters; |
| 615 | 615 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 616 | 616 | $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"; |
| 617 | 617 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 618 | - try { |
|
| 619 | - $sth = $this->db->prepare($query); |
|
| 620 | - $sth->execute($query_data); |
|
| 621 | - } catch(PDOException $e) { |
|
| 622 | - echo "error : ".$e->getMessage(); |
|
| 623 | - } |
|
| 624 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 625 | - if (empty($all)) { |
|
| 618 | + try { |
|
| 619 | + $sth = $this->db->prepare($query); |
|
| 620 | + $sth->execute($query_data); |
|
| 621 | + } catch(PDOException $e) { |
|
| 622 | + echo "error : ".$e->getMessage(); |
|
| 623 | + } |
|
| 624 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 625 | + if (empty($all)) { |
|
| 626 | 626 | $filters = array('airlines' => array($stats_airline)); |
| 627 | 627 | if ($filter_name != '') { |
| 628 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 628 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 629 | 629 | } |
| 630 | - $Spotter = new Spotter($this->db); |
|
| 631 | - $all = $Spotter->countAllDates($filters); |
|
| 632 | - } |
|
| 633 | - return $all; |
|
| 630 | + $Spotter = new Spotter($this->db); |
|
| 631 | + $all = $Spotter->countAllDates($filters); |
|
| 632 | + } |
|
| 633 | + return $all; |
|
| 634 | 634 | } |
| 635 | 635 | public function countAllDatesByAirlines($filter_name = '') { |
| 636 | 636 | global $globalStatsFilters; |
| 637 | 637 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 638 | 638 | $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"; |
| 639 | 639 | $query_data = array('filter_name' => $filter_name); |
| 640 | - try { |
|
| 641 | - $sth = $this->db->prepare($query); |
|
| 642 | - $sth->execute($query_data); |
|
| 643 | - } catch(PDOException $e) { |
|
| 644 | - echo "error : ".$e->getMessage(); |
|
| 645 | - } |
|
| 646 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 647 | - if (empty($all)) { |
|
| 648 | - $filters = array(); |
|
| 649 | - if ($filter_name != '') { |
|
| 650 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 640 | + try { |
|
| 641 | + $sth = $this->db->prepare($query); |
|
| 642 | + $sth->execute($query_data); |
|
| 643 | + } catch(PDOException $e) { |
|
| 644 | + echo "error : ".$e->getMessage(); |
|
| 645 | + } |
|
| 646 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 647 | + if (empty($all)) { |
|
| 648 | + $filters = array(); |
|
| 649 | + if ($filter_name != '') { |
|
| 650 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 651 | 651 | } |
| 652 | - $Spotter = new Spotter($this->db); |
|
| 653 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
| 654 | - } |
|
| 655 | - return $all; |
|
| 652 | + $Spotter = new Spotter($this->db); |
|
| 653 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
| 654 | + } |
|
| 655 | + return $all; |
|
| 656 | 656 | } |
| 657 | 657 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 658 | 658 | global $globalStatsFilters; |
| 659 | 659 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 660 | - $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"; |
|
| 661 | - try { |
|
| 662 | - $sth = $this->db->prepare($query); |
|
| 663 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 664 | - } catch(PDOException $e) { |
|
| 665 | - echo "error : ".$e->getMessage(); |
|
| 666 | - } |
|
| 667 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 660 | + $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"; |
|
| 661 | + try { |
|
| 662 | + $sth = $this->db->prepare($query); |
|
| 663 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 664 | + } catch(PDOException $e) { |
|
| 665 | + echo "error : ".$e->getMessage(); |
|
| 666 | + } |
|
| 667 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 668 | 668 | |
| 669 | - if (empty($all)) { |
|
| 669 | + if (empty($all)) { |
|
| 670 | 670 | $filters = array('airlines' => array($stats_airline)); |
| 671 | 671 | if ($filter_name != '') { |
| 672 | 672 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
| 673 | 673 | } |
| 674 | - $Spotter = new Spotter($this->db); |
|
| 675 | - $all = $Spotter->countAllMonths($filters); |
|
| 676 | - } |
|
| 674 | + $Spotter = new Spotter($this->db); |
|
| 675 | + $all = $Spotter->countAllMonths($filters); |
|
| 676 | + } |
|
| 677 | 677 | |
| 678 | - return $all; |
|
| 678 | + return $all; |
|
| 679 | 679 | } |
| 680 | 680 | public function countAllMilitaryMonths($filter_name = '') { |
| 681 | 681 | global $globalStatsFilters; |
| 682 | 682 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 683 | - $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"; |
|
| 684 | - try { |
|
| 685 | - $sth = $this->db->prepare($query); |
|
| 686 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
| 687 | - } catch(PDOException $e) { |
|
| 688 | - echo "error : ".$e->getMessage(); |
|
| 689 | - } |
|
| 690 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 691 | - if (empty($all)) { |
|
| 692 | - $filters = array(); |
|
| 693 | - if ($filter_name != '') { |
|
| 694 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 683 | + $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"; |
|
| 684 | + try { |
|
| 685 | + $sth = $this->db->prepare($query); |
|
| 686 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
| 687 | + } catch(PDOException $e) { |
|
| 688 | + echo "error : ".$e->getMessage(); |
|
| 689 | + } |
|
| 690 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 691 | + if (empty($all)) { |
|
| 692 | + $filters = array(); |
|
| 693 | + if ($filter_name != '') { |
|
| 694 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 695 | 695 | } |
| 696 | - $Spotter = new Spotter($this->db); |
|
| 697 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
| 698 | - } |
|
| 699 | - return $all; |
|
| 696 | + $Spotter = new Spotter($this->db); |
|
| 697 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
| 698 | + } |
|
| 699 | + return $all; |
|
| 700 | 700 | } |
| 701 | 701 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 702 | 702 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -712,22 +712,22 @@ discard block |
||
| 712 | 712 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 713 | 713 | } |
| 714 | 714 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
| 715 | - try { |
|
| 716 | - $sth = $this->db->prepare($query); |
|
| 717 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 718 | - } catch(PDOException $e) { |
|
| 719 | - echo "error : ".$e->getMessage(); |
|
| 720 | - } |
|
| 721 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 722 | - if (empty($all)) { |
|
| 715 | + try { |
|
| 716 | + $sth = $this->db->prepare($query); |
|
| 717 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 718 | + } catch(PDOException $e) { |
|
| 719 | + echo "error : ".$e->getMessage(); |
|
| 720 | + } |
|
| 721 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 722 | + if (empty($all)) { |
|
| 723 | 723 | $filters = array('airlines' => array($stats_airline)); |
| 724 | 724 | if ($filter_name != '') { |
| 725 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 725 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 726 | 726 | } |
| 727 | - $Spotter = new Spotter($this->db); |
|
| 728 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
| 729 | - } |
|
| 730 | - return $all; |
|
| 727 | + $Spotter = new Spotter($this->db); |
|
| 728 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
| 729 | + } |
|
| 730 | + return $all; |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
@@ -752,10 +752,10 @@ discard block |
||
| 752 | 752 | if ($year == '') $year = date('Y'); |
| 753 | 753 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
| 754 | 754 | if (empty($all)) { |
| 755 | - $filters = array(); |
|
| 755 | + $filters = array(); |
|
| 756 | 756 | $filters = array('year' => $year,'month' => $month); |
| 757 | - if ($filter_name != '') { |
|
| 758 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 757 | + if ($filter_name != '') { |
|
| 758 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 759 | 759 | } |
| 760 | 760 | $Spotter = new Spotter($this->db); |
| 761 | 761 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -819,10 +819,10 @@ discard block |
||
| 819 | 819 | $all = $result[0]['nb_airline']; |
| 820 | 820 | } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
| 821 | 821 | if (empty($all)) { |
| 822 | - $filters = array(); |
|
| 822 | + $filters = array(); |
|
| 823 | 823 | $filters = array('year' => $year,'month' => $month); |
| 824 | - if ($filter_name != '') { |
|
| 825 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 824 | + if ($filter_name != '') { |
|
| 825 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 826 | 826 | } |
| 827 | 827 | $Spotter = new Spotter($this->db); |
| 828 | 828 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -892,33 +892,33 @@ discard block |
||
| 892 | 892 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 893 | 893 | $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"; |
| 894 | 894 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 895 | - try { |
|
| 896 | - $sth = $this->db->prepare($query); |
|
| 897 | - $sth->execute($query_values); |
|
| 898 | - } catch(PDOException $e) { |
|
| 899 | - echo "error : ".$e->getMessage(); |
|
| 900 | - } |
|
| 901 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 902 | - return $all; |
|
| 895 | + try { |
|
| 896 | + $sth = $this->db->prepare($query); |
|
| 897 | + $sth->execute($query_values); |
|
| 898 | + } catch(PDOException $e) { |
|
| 899 | + echo "error : ".$e->getMessage(); |
|
| 900 | + } |
|
| 901 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 902 | + return $all; |
|
| 903 | 903 | } |
| 904 | 904 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 905 | 905 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 906 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
| 907 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 908 | - try { |
|
| 909 | - $sth = $this->db->prepare($query); |
|
| 910 | - $sth->execute($query_values); |
|
| 911 | - } catch(PDOException $e) { |
|
| 912 | - echo "error : ".$e->getMessage(); |
|
| 913 | - } |
|
| 914 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 915 | - return $all; |
|
| 916 | - } |
|
| 906 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
| 907 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 908 | + try { |
|
| 909 | + $sth = $this->db->prepare($query); |
|
| 910 | + $sth->execute($query_values); |
|
| 911 | + } catch(PDOException $e) { |
|
| 912 | + echo "error : ".$e->getMessage(); |
|
| 913 | + } |
|
| 914 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 915 | + return $all; |
|
| 916 | + } |
|
| 917 | 917 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
| 918 | 918 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 919 | - global $globalArchiveMonths, $globalDBdriver; |
|
| 920 | - if ($globalDBdriver == 'mysql') { |
|
| 921 | - if ($month == '') { |
|
| 919 | + global $globalArchiveMonths, $globalDBdriver; |
|
| 920 | + if ($globalDBdriver == 'mysql') { |
|
| 921 | + if ($month == '') { |
|
| 922 | 922 | $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"; |
| 923 | 923 | $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 924 | 924 | } else { |
@@ -933,165 +933,165 @@ discard block |
||
| 933 | 933 | $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"; |
| 934 | 934 | $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
| 935 | 935 | } |
| 936 | - } |
|
| 937 | - try { |
|
| 938 | - $sth = $this->db->prepare($query); |
|
| 939 | - $sth->execute($query_values); |
|
| 940 | - } catch(PDOException $e) { |
|
| 941 | - echo "error : ".$e->getMessage(); |
|
| 942 | - } |
|
| 943 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 944 | - return $all[0]['total']; |
|
| 945 | - } |
|
| 936 | + } |
|
| 937 | + try { |
|
| 938 | + $sth = $this->db->prepare($query); |
|
| 939 | + $sth->execute($query_values); |
|
| 940 | + } catch(PDOException $e) { |
|
| 941 | + echo "error : ".$e->getMessage(); |
|
| 942 | + } |
|
| 943 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 944 | + return $all[0]['total']; |
|
| 945 | + } |
|
| 946 | 946 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 947 | - global $globalArchiveMonths, $globalDBdriver; |
|
| 947 | + global $globalArchiveMonths, $globalDBdriver; |
|
| 948 | 948 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 949 | - if ($globalDBdriver == 'mysql') { |
|
| 949 | + if ($globalDBdriver == 'mysql') { |
|
| 950 | 950 | $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"; |
| 951 | 951 | } else { |
| 952 | 952 | $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"; |
| 953 | - } |
|
| 954 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 955 | - try { |
|
| 956 | - $sth = $this->db->prepare($query); |
|
| 957 | - $sth->execute($query_values); |
|
| 958 | - } catch(PDOException $e) { |
|
| 959 | - echo "error : ".$e->getMessage(); |
|
| 960 | - } |
|
| 961 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 962 | - return $all[0]['total']; |
|
| 963 | - } |
|
| 953 | + } |
|
| 954 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 955 | + try { |
|
| 956 | + $sth = $this->db->prepare($query); |
|
| 957 | + $sth->execute($query_values); |
|
| 958 | + } catch(PDOException $e) { |
|
| 959 | + echo "error : ".$e->getMessage(); |
|
| 960 | + } |
|
| 961 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 962 | + return $all[0]['total']; |
|
| 963 | + } |
|
| 964 | 964 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 965 | - global $globalArchiveMonths, $globalDBdriver; |
|
| 965 | + global $globalArchiveMonths, $globalDBdriver; |
|
| 966 | 966 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 967 | - if ($globalDBdriver == 'mysql') { |
|
| 967 | + if ($globalDBdriver == 'mysql') { |
|
| 968 | 968 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 969 | - } else { |
|
| 969 | + } else { |
|
| 970 | 970 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 971 | - } |
|
| 972 | - try { |
|
| 973 | - $sth = $this->db->prepare($query); |
|
| 974 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 975 | - } catch(PDOException $e) { |
|
| 976 | - echo "error : ".$e->getMessage(); |
|
| 977 | - } |
|
| 978 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 979 | - return $all[0]['total']; |
|
| 980 | - } |
|
| 971 | + } |
|
| 972 | + try { |
|
| 973 | + $sth = $this->db->prepare($query); |
|
| 974 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 975 | + } catch(PDOException $e) { |
|
| 976 | + echo "error : ".$e->getMessage(); |
|
| 977 | + } |
|
| 978 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 979 | + return $all[0]['total']; |
|
| 980 | + } |
|
| 981 | 981 | public function getStatsAirlineTotal($filter_name = '') { |
| 982 | - global $globalArchiveMonths, $globalDBdriver; |
|
| 982 | + global $globalArchiveMonths, $globalDBdriver; |
|
| 983 | 983 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 984 | - if ($globalDBdriver == 'mysql') { |
|
| 984 | + if ($globalDBdriver == 'mysql') { |
|
| 985 | 985 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 986 | - } else { |
|
| 986 | + } else { |
|
| 987 | 987 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 988 | - } |
|
| 989 | - try { |
|
| 990 | - $sth = $this->db->prepare($query); |
|
| 991 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
| 992 | - } catch(PDOException $e) { |
|
| 993 | - echo "error : ".$e->getMessage(); |
|
| 994 | - } |
|
| 995 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 996 | - return $all[0]['total']; |
|
| 997 | - } |
|
| 988 | + } |
|
| 989 | + try { |
|
| 990 | + $sth = $this->db->prepare($query); |
|
| 991 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
| 992 | + } catch(PDOException $e) { |
|
| 993 | + echo "error : ".$e->getMessage(); |
|
| 994 | + } |
|
| 995 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 996 | + return $all[0]['total']; |
|
| 997 | + } |
|
| 998 | 998 | public function getStatsOwnerTotal($filter_name = '') { |
| 999 | - global $globalArchiveMonths, $globalDBdriver; |
|
| 999 | + global $globalArchiveMonths, $globalDBdriver; |
|
| 1000 | 1000 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1001 | - if ($globalDBdriver == 'mysql') { |
|
| 1001 | + if ($globalDBdriver == 'mysql') { |
|
| 1002 | 1002 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 1003 | 1003 | } else { |
| 1004 | 1004 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 1005 | - } |
|
| 1006 | - try { |
|
| 1007 | - $sth = $this->db->prepare($query); |
|
| 1008 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
| 1009 | - } catch(PDOException $e) { |
|
| 1010 | - echo "error : ".$e->getMessage(); |
|
| 1011 | - } |
|
| 1012 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 1013 | - return $all[0]['total']; |
|
| 1014 | - } |
|
| 1005 | + } |
|
| 1006 | + try { |
|
| 1007 | + $sth = $this->db->prepare($query); |
|
| 1008 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
| 1009 | + } catch(PDOException $e) { |
|
| 1010 | + echo "error : ".$e->getMessage(); |
|
| 1011 | + } |
|
| 1012 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 1013 | + return $all[0]['total']; |
|
| 1014 | + } |
|
| 1015 | 1015 | public function getStatsOwner($owner_name,$filter_name = '') { |
| 1016 | - global $globalArchiveMonths, $globalDBdriver; |
|
| 1016 | + global $globalArchiveMonths, $globalDBdriver; |
|
| 1017 | 1017 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1018 | 1018 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1019 | - try { |
|
| 1020 | - $sth = $this->db->prepare($query); |
|
| 1021 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
| 1022 | - } catch(PDOException $e) { |
|
| 1023 | - echo "error : ".$e->getMessage(); |
|
| 1024 | - } |
|
| 1025 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 1026 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1027 | - else return 0; |
|
| 1028 | - } |
|
| 1019 | + try { |
|
| 1020 | + $sth = $this->db->prepare($query); |
|
| 1021 | + $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
| 1022 | + } catch(PDOException $e) { |
|
| 1023 | + echo "error : ".$e->getMessage(); |
|
| 1024 | + } |
|
| 1025 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 1026 | + if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1027 | + else return 0; |
|
| 1028 | + } |
|
| 1029 | 1029 | public function getStatsPilotTotal($filter_name = '') { |
| 1030 | - global $globalArchiveMonths, $globalDBdriver; |
|
| 1030 | + global $globalArchiveMonths, $globalDBdriver; |
|
| 1031 | 1031 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1032 | - if ($globalDBdriver == 'mysql') { |
|
| 1033 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
| 1034 | - } else { |
|
| 1035 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
| 1036 | - } |
|
| 1037 | - try { |
|
| 1038 | - $sth = $this->db->prepare($query); |
|
| 1039 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
| 1040 | - } catch(PDOException $e) { |
|
| 1041 | - echo "error : ".$e->getMessage(); |
|
| 1042 | - } |
|
| 1043 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 1044 | - return $all[0]['total']; |
|
| 1045 | - } |
|
| 1032 | + if ($globalDBdriver == 'mysql') { |
|
| 1033 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
| 1034 | + } else { |
|
| 1035 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
| 1036 | + } |
|
| 1037 | + try { |
|
| 1038 | + $sth = $this->db->prepare($query); |
|
| 1039 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
| 1040 | + } catch(PDOException $e) { |
|
| 1041 | + echo "error : ".$e->getMessage(); |
|
| 1042 | + } |
|
| 1043 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 1044 | + return $all[0]['total']; |
|
| 1045 | + } |
|
| 1046 | 1046 | public function getStatsPilot($pilot,$filter_name = '') { |
| 1047 | - global $globalArchiveMonths, $globalDBdriver; |
|
| 1047 | + global $globalArchiveMonths, $globalDBdriver; |
|
| 1048 | 1048 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1049 | 1049 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1050 | - try { |
|
| 1051 | - $sth = $this->db->prepare($query); |
|
| 1052 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
| 1053 | - } catch(PDOException $e) { |
|
| 1054 | - echo "error : ".$e->getMessage(); |
|
| 1055 | - } |
|
| 1056 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 1057 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1058 | - else return 0; |
|
| 1059 | - } |
|
| 1050 | + try { |
|
| 1051 | + $sth = $this->db->prepare($query); |
|
| 1052 | + $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
| 1053 | + } catch(PDOException $e) { |
|
| 1054 | + echo "error : ".$e->getMessage(); |
|
| 1055 | + } |
|
| 1056 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 1057 | + if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1058 | + else return 0; |
|
| 1059 | + } |
|
| 1060 | 1060 | |
| 1061 | 1061 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1062 | 1062 | global $globalDBdriver; |
| 1063 | 1063 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1064 | 1064 | if ($globalDBdriver == 'mysql') { |
| 1065 | 1065 | $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"; |
| 1066 | - } else { |
|
| 1066 | + } else { |
|
| 1067 | 1067 | $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);"; |
| 1068 | 1068 | } |
| 1069 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1070 | - try { |
|
| 1071 | - $sth = $this->db->prepare($query); |
|
| 1072 | - $sth->execute($query_values); |
|
| 1073 | - } catch(PDOException $e) { |
|
| 1074 | - return "error : ".$e->getMessage(); |
|
| 1075 | - } |
|
| 1076 | - } |
|
| 1069 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1070 | + try { |
|
| 1071 | + $sth = $this->db->prepare($query); |
|
| 1072 | + $sth->execute($query_values); |
|
| 1073 | + } catch(PDOException $e) { |
|
| 1074 | + return "error : ".$e->getMessage(); |
|
| 1075 | + } |
|
| 1076 | + } |
|
| 1077 | 1077 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1078 | 1078 | global $globalDBdriver; |
| 1079 | 1079 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1080 | 1080 | if ($globalDBdriver == 'mysql') { |
| 1081 | 1081 | $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"; |
| 1082 | 1082 | } else { |
| 1083 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
| 1083 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
| 1084 | 1084 | $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);"; |
| 1085 | - } |
|
| 1086 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1087 | - try { |
|
| 1088 | - $sth = $this->db->prepare($query); |
|
| 1089 | - $sth->execute($query_values); |
|
| 1090 | - } catch(PDOException $e) { |
|
| 1091 | - return "error : ".$e->getMessage(); |
|
| 1092 | - } |
|
| 1093 | - } |
|
| 1094 | - /* |
|
| 1085 | + } |
|
| 1086 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1087 | + try { |
|
| 1088 | + $sth = $this->db->prepare($query); |
|
| 1089 | + $sth->execute($query_values); |
|
| 1090 | + } catch(PDOException $e) { |
|
| 1091 | + return "error : ".$e->getMessage(); |
|
| 1092 | + } |
|
| 1093 | + } |
|
| 1094 | + /* |
|
| 1095 | 1095 | public function getStatsSource($date,$stats_type = '') { |
| 1096 | 1096 | if ($stats_type == '') { |
| 1097 | 1097 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -1160,25 +1160,25 @@ discard block |
||
| 1160 | 1160 | $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"; |
| 1161 | 1161 | } else { |
| 1162 | 1162 | $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);"; |
| 1163 | - } |
|
| 1164 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
| 1165 | - try { |
|
| 1166 | - $sth = $this->db->prepare($query); |
|
| 1167 | - $sth->execute($query_values); |
|
| 1168 | - } catch(PDOException $e) { |
|
| 1169 | - return "error : ".$e->getMessage(); |
|
| 1170 | - } |
|
| 1171 | - } |
|
| 1172 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
| 1173 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
| 1174 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1175 | - try { |
|
| 1176 | - $sth = $this->db->prepare($query); |
|
| 1177 | - $sth->execute($query_values); |
|
| 1178 | - } catch(PDOException $e) { |
|
| 1179 | - return "error : ".$e->getMessage(); |
|
| 1180 | - } |
|
| 1181 | - } |
|
| 1163 | + } |
|
| 1164 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
| 1165 | + try { |
|
| 1166 | + $sth = $this->db->prepare($query); |
|
| 1167 | + $sth->execute($query_values); |
|
| 1168 | + } catch(PDOException $e) { |
|
| 1169 | + return "error : ".$e->getMessage(); |
|
| 1170 | + } |
|
| 1171 | + } |
|
| 1172 | + public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
| 1173 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
| 1174 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1175 | + try { |
|
| 1176 | + $sth = $this->db->prepare($query); |
|
| 1177 | + $sth->execute($query_values); |
|
| 1178 | + } catch(PDOException $e) { |
|
| 1179 | + return "error : ".$e->getMessage(); |
|
| 1180 | + } |
|
| 1181 | + } |
|
| 1182 | 1182 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
| 1183 | 1183 | global $globalDBdriver; |
| 1184 | 1184 | if ($globalDBdriver == 'mysql') { |
@@ -1194,14 +1194,14 @@ discard block |
||
| 1194 | 1194 | $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);"; |
| 1195 | 1195 | } |
| 1196 | 1196 | } |
| 1197 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1198 | - try { |
|
| 1199 | - $sth = $this->db->prepare($query); |
|
| 1200 | - $sth->execute($query_values); |
|
| 1201 | - } catch(PDOException $e) { |
|
| 1202 | - return "error : ".$e->getMessage(); |
|
| 1203 | - } |
|
| 1204 | - } |
|
| 1197 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1198 | + try { |
|
| 1199 | + $sth = $this->db->prepare($query); |
|
| 1200 | + $sth->execute($query_values); |
|
| 1201 | + } catch(PDOException $e) { |
|
| 1202 | + return "error : ".$e->getMessage(); |
|
| 1203 | + } |
|
| 1204 | + } |
|
| 1205 | 1205 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
| 1206 | 1206 | global $globalDBdriver; |
| 1207 | 1207 | if ($globalDBdriver == 'mysql') { |
@@ -1217,14 +1217,14 @@ discard block |
||
| 1217 | 1217 | $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);"; |
| 1218 | 1218 | } |
| 1219 | 1219 | } |
| 1220 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1221 | - try { |
|
| 1222 | - $sth = $this->db->prepare($query); |
|
| 1223 | - $sth->execute($query_values); |
|
| 1224 | - } catch(PDOException $e) { |
|
| 1225 | - return "error : ".$e->getMessage(); |
|
| 1226 | - } |
|
| 1227 | - } |
|
| 1220 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1221 | + try { |
|
| 1222 | + $sth = $this->db->prepare($query); |
|
| 1223 | + $sth->execute($query_values); |
|
| 1224 | + } catch(PDOException $e) { |
|
| 1225 | + return "error : ".$e->getMessage(); |
|
| 1226 | + } |
|
| 1227 | + } |
|
| 1228 | 1228 | public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
| 1229 | 1229 | global $globalDBdriver; |
| 1230 | 1230 | if ($globalDBdriver == 'mysql') { |
@@ -1240,14 +1240,14 @@ discard block |
||
| 1240 | 1240 | $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);"; |
| 1241 | 1241 | } |
| 1242 | 1242 | } |
| 1243 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
| 1244 | - try { |
|
| 1245 | - $sth = $this->db->prepare($query); |
|
| 1246 | - $sth->execute($query_values); |
|
| 1247 | - } catch(PDOException $e) { |
|
| 1248 | - return "error : ".$e->getMessage(); |
|
| 1249 | - } |
|
| 1250 | - } |
|
| 1243 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
| 1244 | + try { |
|
| 1245 | + $sth = $this->db->prepare($query); |
|
| 1246 | + $sth->execute($query_values); |
|
| 1247 | + } catch(PDOException $e) { |
|
| 1248 | + return "error : ".$e->getMessage(); |
|
| 1249 | + } |
|
| 1250 | + } |
|
| 1251 | 1251 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
| 1252 | 1252 | global $globalDBdriver; |
| 1253 | 1253 | if ($globalDBdriver == 'mysql') { |
@@ -1263,14 +1263,14 @@ discard block |
||
| 1263 | 1263 | $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);"; |
| 1264 | 1264 | } |
| 1265 | 1265 | } |
| 1266 | - $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); |
|
| 1267 | - try { |
|
| 1268 | - $sth = $this->db->prepare($query); |
|
| 1269 | - $sth->execute($query_values); |
|
| 1270 | - } catch(PDOException $e) { |
|
| 1271 | - return "error : ".$e->getMessage(); |
|
| 1272 | - } |
|
| 1273 | - } |
|
| 1266 | + $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); |
|
| 1267 | + try { |
|
| 1268 | + $sth = $this->db->prepare($query); |
|
| 1269 | + $sth->execute($query_values); |
|
| 1270 | + } catch(PDOException $e) { |
|
| 1271 | + return "error : ".$e->getMessage(); |
|
| 1272 | + } |
|
| 1273 | + } |
|
| 1274 | 1274 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
| 1275 | 1275 | global $globalDBdriver; |
| 1276 | 1276 | if ($globalDBdriver == 'mysql') { |
@@ -1286,14 +1286,14 @@ discard block |
||
| 1286 | 1286 | $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);"; |
| 1287 | 1287 | } |
| 1288 | 1288 | } |
| 1289 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 1290 | - try { |
|
| 1291 | - $sth = $this->db->prepare($query); |
|
| 1292 | - $sth->execute($query_values); |
|
| 1293 | - } catch(PDOException $e) { |
|
| 1294 | - return "error : ".$e->getMessage(); |
|
| 1295 | - } |
|
| 1296 | - } |
|
| 1289 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 1290 | + try { |
|
| 1291 | + $sth = $this->db->prepare($query); |
|
| 1292 | + $sth->execute($query_values); |
|
| 1293 | + } catch(PDOException $e) { |
|
| 1294 | + return "error : ".$e->getMessage(); |
|
| 1295 | + } |
|
| 1296 | + } |
|
| 1297 | 1297 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
| 1298 | 1298 | global $globalDBdriver; |
| 1299 | 1299 | if ($globalDBdriver == 'mysql') { |
@@ -1309,14 +1309,14 @@ discard block |
||
| 1309 | 1309 | $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);"; |
| 1310 | 1310 | } |
| 1311 | 1311 | } |
| 1312 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1313 | - try { |
|
| 1314 | - $sth = $this->db->prepare($query); |
|
| 1315 | - $sth->execute($query_values); |
|
| 1316 | - } catch(PDOException $e) { |
|
| 1317 | - return "error : ".$e->getMessage(); |
|
| 1318 | - } |
|
| 1319 | - } |
|
| 1312 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1313 | + try { |
|
| 1314 | + $sth = $this->db->prepare($query); |
|
| 1315 | + $sth->execute($query_values); |
|
| 1316 | + } catch(PDOException $e) { |
|
| 1317 | + return "error : ".$e->getMessage(); |
|
| 1318 | + } |
|
| 1319 | + } |
|
| 1320 | 1320 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
| 1321 | 1321 | global $globalDBdriver; |
| 1322 | 1322 | if ($globalDBdriver == 'mysql') { |
@@ -1332,14 +1332,14 @@ discard block |
||
| 1332 | 1332 | $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);"; |
| 1333 | 1333 | } |
| 1334 | 1334 | } |
| 1335 | - $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); |
|
| 1336 | - try { |
|
| 1337 | - $sth = $this->db->prepare($query); |
|
| 1338 | - $sth->execute($query_values); |
|
| 1339 | - } catch(PDOException $e) { |
|
| 1340 | - return "error : ".$e->getMessage(); |
|
| 1341 | - } |
|
| 1342 | - } |
|
| 1335 | + $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); |
|
| 1336 | + try { |
|
| 1337 | + $sth = $this->db->prepare($query); |
|
| 1338 | + $sth->execute($query_values); |
|
| 1339 | + } catch(PDOException $e) { |
|
| 1340 | + return "error : ".$e->getMessage(); |
|
| 1341 | + } |
|
| 1342 | + } |
|
| 1343 | 1343 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
| 1344 | 1344 | global $globalDBdriver; |
| 1345 | 1345 | if ($airport_icao != '') { |
@@ -1363,8 +1363,8 @@ discard block |
||
| 1363 | 1363 | } catch(PDOException $e) { |
| 1364 | 1364 | return "error : ".$e->getMessage(); |
| 1365 | 1365 | } |
| 1366 | - } |
|
| 1367 | - } |
|
| 1366 | + } |
|
| 1367 | + } |
|
| 1368 | 1368 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
| 1369 | 1369 | global $globalDBdriver; |
| 1370 | 1370 | if ($airport_icao != '') { |
@@ -1380,8 +1380,8 @@ discard block |
||
| 1380 | 1380 | } catch(PDOException $e) { |
| 1381 | 1381 | return "error : ".$e->getMessage(); |
| 1382 | 1382 | } |
| 1383 | - } |
|
| 1384 | - } |
|
| 1383 | + } |
|
| 1384 | + } |
|
| 1385 | 1385 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
| 1386 | 1386 | global $globalDBdriver; |
| 1387 | 1387 | if ($airport_icao != '') { |
@@ -1398,15 +1398,15 @@ discard block |
||
| 1398 | 1398 | $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);"; |
| 1399 | 1399 | } |
| 1400 | 1400 | } |
| 1401 | - $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); |
|
| 1401 | + $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); |
|
| 1402 | 1402 | try { |
| 1403 | - $sth = $this->db->prepare($query); |
|
| 1404 | - $sth->execute($query_values); |
|
| 1405 | - } catch(PDOException $e) { |
|
| 1406 | - return "error : ".$e->getMessage(); |
|
| 1407 | - } |
|
| 1408 | - } |
|
| 1409 | - } |
|
| 1403 | + $sth = $this->db->prepare($query); |
|
| 1404 | + $sth->execute($query_values); |
|
| 1405 | + } catch(PDOException $e) { |
|
| 1406 | + return "error : ".$e->getMessage(); |
|
| 1407 | + } |
|
| 1408 | + } |
|
| 1409 | + } |
|
| 1410 | 1410 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
| 1411 | 1411 | global $globalDBdriver; |
| 1412 | 1412 | if ($airport_icao != '') { |
@@ -1422,46 +1422,46 @@ discard block |
||
| 1422 | 1422 | } catch(PDOException $e) { |
| 1423 | 1423 | return "error : ".$e->getMessage(); |
| 1424 | 1424 | } |
| 1425 | - } |
|
| 1426 | - } |
|
| 1425 | + } |
|
| 1426 | + } |
|
| 1427 | 1427 | |
| 1428 | 1428 | public function deleteStat($id) { |
| 1429 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
| 1430 | - $query_values = array(':id' => $id); |
|
| 1431 | - try { |
|
| 1432 | - $sth = $this->db->prepare($query); |
|
| 1433 | - $sth->execute($query_values); |
|
| 1434 | - } catch(PDOException $e) { |
|
| 1435 | - return "error : ".$e->getMessage(); |
|
| 1436 | - } |
|
| 1437 | - } |
|
| 1429 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
| 1430 | + $query_values = array(':id' => $id); |
|
| 1431 | + try { |
|
| 1432 | + $sth = $this->db->prepare($query); |
|
| 1433 | + $sth->execute($query_values); |
|
| 1434 | + } catch(PDOException $e) { |
|
| 1435 | + return "error : ".$e->getMessage(); |
|
| 1436 | + } |
|
| 1437 | + } |
|
| 1438 | 1438 | public function deleteStatFlight($type) { |
| 1439 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
| 1440 | - $query_values = array(':type' => $type); |
|
| 1441 | - try { |
|
| 1442 | - $sth = $this->db->prepare($query); |
|
| 1443 | - $sth->execute($query_values); |
|
| 1444 | - } catch(PDOException $e) { |
|
| 1445 | - return "error : ".$e->getMessage(); |
|
| 1446 | - } |
|
| 1447 | - } |
|
| 1439 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
| 1440 | + $query_values = array(':type' => $type); |
|
| 1441 | + try { |
|
| 1442 | + $sth = $this->db->prepare($query); |
|
| 1443 | + $sth->execute($query_values); |
|
| 1444 | + } catch(PDOException $e) { |
|
| 1445 | + return "error : ".$e->getMessage(); |
|
| 1446 | + } |
|
| 1447 | + } |
|
| 1448 | 1448 | public function deleteStatAirport($type) { |
| 1449 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
| 1450 | - $query_values = array(':type' => $type); |
|
| 1451 | - try { |
|
| 1452 | - $sth = $this->db->prepare($query); |
|
| 1453 | - $sth->execute($query_values); |
|
| 1454 | - } catch(PDOException $e) { |
|
| 1455 | - return "error : ".$e->getMessage(); |
|
| 1456 | - } |
|
| 1457 | - } |
|
| 1449 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
| 1450 | + $query_values = array(':type' => $type); |
|
| 1451 | + try { |
|
| 1452 | + $sth = $this->db->prepare($query); |
|
| 1453 | + $sth->execute($query_values); |
|
| 1454 | + } catch(PDOException $e) { |
|
| 1455 | + return "error : ".$e->getMessage(); |
|
| 1456 | + } |
|
| 1457 | + } |
|
| 1458 | 1458 | |
| 1459 | - public function addOldStats() { |
|
| 1460 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear; |
|
| 1461 | - $Common = new Common(); |
|
| 1462 | - $Connection = new Connection(); |
|
| 1463 | - date_default_timezone_set('UTC'); |
|
| 1464 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
| 1459 | + public function addOldStats() { |
|
| 1460 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear; |
|
| 1461 | + $Common = new Common(); |
|
| 1462 | + $Connection = new Connection(); |
|
| 1463 | + date_default_timezone_set('UTC'); |
|
| 1464 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
| 1465 | 1465 | if ($globalDebug) echo 'Update stats !'."\n"; |
| 1466 | 1466 | if (isset($last_update[0]['value'])) { |
| 1467 | 1467 | $last_update_day = $last_update[0]['value']; |
@@ -1508,24 +1508,24 @@ discard block |
||
| 1508 | 1508 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
| 1509 | 1509 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 1510 | 1510 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
| 1511 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
| 1511 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
| 1512 | 1512 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
| 1513 | - $alldata = array(); |
|
| 1513 | + $alldata = array(); |
|
| 1514 | 1514 | |
| 1515 | - foreach ($pall as $value) { |
|
| 1516 | - $icao = $value['airport_departure_icao']; |
|
| 1517 | - $alldata[$icao] = $value; |
|
| 1518 | - } |
|
| 1519 | - foreach ($dall as $value) { |
|
| 1520 | - $icao = $value['airport_departure_icao']; |
|
| 1521 | - if (isset($alldata[$icao])) { |
|
| 1522 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
| 1523 | - } else $alldata[$icao] = $value; |
|
| 1524 | - } |
|
| 1525 | - $count = array(); |
|
| 1526 | - foreach ($alldata as $key => $row) { |
|
| 1527 | - $count[$key] = $row['airport_departure_icao_count']; |
|
| 1528 | - } |
|
| 1515 | + foreach ($pall as $value) { |
|
| 1516 | + $icao = $value['airport_departure_icao']; |
|
| 1517 | + $alldata[$icao] = $value; |
|
| 1518 | + } |
|
| 1519 | + foreach ($dall as $value) { |
|
| 1520 | + $icao = $value['airport_departure_icao']; |
|
| 1521 | + if (isset($alldata[$icao])) { |
|
| 1522 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
| 1523 | + } else $alldata[$icao] = $value; |
|
| 1524 | + } |
|
| 1525 | + $count = array(); |
|
| 1526 | + foreach ($alldata as $key => $row) { |
|
| 1527 | + $count[$key] = $row['airport_departure_icao_count']; |
|
| 1528 | + } |
|
| 1529 | 1529 | array_multisort($count,SORT_DESC,$alldata); |
| 1530 | 1530 | foreach ($alldata as $number) { |
| 1531 | 1531 | 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); |
@@ -1533,25 +1533,25 @@ discard block |
||
| 1533 | 1533 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
| 1534 | 1534 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 1535 | 1535 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
| 1536 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
| 1536 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
| 1537 | 1537 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
| 1538 | - $alldata = array(); |
|
| 1539 | - foreach ($pall as $value) { |
|
| 1540 | - $icao = $value['airport_arrival_icao']; |
|
| 1541 | - $alldata[$icao] = $value; |
|
| 1542 | - } |
|
| 1543 | - foreach ($dall as $value) { |
|
| 1544 | - $icao = $value['airport_arrival_icao']; |
|
| 1545 | - if (isset($alldata[$icao])) { |
|
| 1546 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
| 1547 | - } else $alldata[$icao] = $value; |
|
| 1548 | - } |
|
| 1549 | - $count = array(); |
|
| 1550 | - foreach ($alldata as $key => $row) { |
|
| 1551 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
| 1552 | - } |
|
| 1553 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 1554 | - foreach ($alldata as $number) { |
|
| 1538 | + $alldata = array(); |
|
| 1539 | + foreach ($pall as $value) { |
|
| 1540 | + $icao = $value['airport_arrival_icao']; |
|
| 1541 | + $alldata[$icao] = $value; |
|
| 1542 | + } |
|
| 1543 | + foreach ($dall as $value) { |
|
| 1544 | + $icao = $value['airport_arrival_icao']; |
|
| 1545 | + if (isset($alldata[$icao])) { |
|
| 1546 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
| 1547 | + } else $alldata[$icao] = $value; |
|
| 1548 | + } |
|
| 1549 | + $count = array(); |
|
| 1550 | + foreach ($alldata as $key => $row) { |
|
| 1551 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
| 1552 | + } |
|
| 1553 | + array_multisort($count,SORT_DESC,$alldata); |
|
| 1554 | + foreach ($alldata as $number) { |
|
| 1555 | 1555 | 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); |
| 1556 | 1556 | } |
| 1557 | 1557 | if ($Connection->tableExists('countries')) { |
@@ -1611,8 +1611,8 @@ discard block |
||
| 1611 | 1611 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 1612 | 1612 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
| 1613 | 1613 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 1614 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
| 1615 | - /* |
|
| 1614 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
| 1615 | + /* |
|
| 1616 | 1616 | $alldata = array(); |
| 1617 | 1617 | foreach ($pall as $value) { |
| 1618 | 1618 | $icao = $value['departure_airport_icao']; |
@@ -1631,29 +1631,29 @@ discard block |
||
| 1631 | 1631 | } |
| 1632 | 1632 | array_multisort($count,SORT_DESC,$alldata); |
| 1633 | 1633 | */ |
| 1634 | - foreach ($dall as $value) { |
|
| 1635 | - $icao = $value['departure_airport_icao']; |
|
| 1636 | - $ddate = $value['date']; |
|
| 1637 | - $find = false; |
|
| 1638 | - foreach ($pall as $pvalue) { |
|
| 1639 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
| 1640 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
| 1641 | - $find = true; |
|
| 1642 | - break; |
|
| 1643 | - } |
|
| 1644 | - } |
|
| 1645 | - if ($find === false) { |
|
| 1646 | - $pall[] = $value; |
|
| 1647 | - } |
|
| 1648 | - } |
|
| 1649 | - $alldata = $pall; |
|
| 1634 | + foreach ($dall as $value) { |
|
| 1635 | + $icao = $value['departure_airport_icao']; |
|
| 1636 | + $ddate = $value['date']; |
|
| 1637 | + $find = false; |
|
| 1638 | + foreach ($pall as $pvalue) { |
|
| 1639 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
| 1640 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
| 1641 | + $find = true; |
|
| 1642 | + break; |
|
| 1643 | + } |
|
| 1644 | + } |
|
| 1645 | + if ($find === false) { |
|
| 1646 | + $pall[] = $value; |
|
| 1647 | + } |
|
| 1648 | + } |
|
| 1649 | + $alldata = $pall; |
|
| 1650 | 1650 | foreach ($alldata as $number) { |
| 1651 | 1651 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
| 1652 | 1652 | } |
| 1653 | 1653 | echo '...Arrival'."\n"; |
| 1654 | 1654 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
| 1655 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
| 1656 | - /* |
|
| 1655 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
| 1656 | + /* |
|
| 1657 | 1657 | $alldata = array(); |
| 1658 | 1658 | foreach ($pall as $value) { |
| 1659 | 1659 | $icao = $value['arrival_airport_icao']; |
@@ -1673,22 +1673,22 @@ discard block |
||
| 1673 | 1673 | */ |
| 1674 | 1674 | |
| 1675 | 1675 | |
| 1676 | - foreach ($dall as $value) { |
|
| 1677 | - $icao = $value['arrival_airport_icao']; |
|
| 1678 | - $ddate = $value['date']; |
|
| 1679 | - $find = false; |
|
| 1680 | - foreach ($pall as $pvalue) { |
|
| 1681 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
| 1682 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
| 1683 | - $find = true; |
|
| 1684 | - break; |
|
| 1685 | - } |
|
| 1686 | - } |
|
| 1687 | - if ($find === false) { |
|
| 1688 | - $pall[] = $value; |
|
| 1689 | - } |
|
| 1690 | - } |
|
| 1691 | - $alldata = $pall; |
|
| 1676 | + foreach ($dall as $value) { |
|
| 1677 | + $icao = $value['arrival_airport_icao']; |
|
| 1678 | + $ddate = $value['date']; |
|
| 1679 | + $find = false; |
|
| 1680 | + foreach ($pall as $pvalue) { |
|
| 1681 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
| 1682 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
| 1683 | + $find = true; |
|
| 1684 | + break; |
|
| 1685 | + } |
|
| 1686 | + } |
|
| 1687 | + if ($find === false) { |
|
| 1688 | + $pall[] = $value; |
|
| 1689 | + } |
|
| 1690 | + } |
|
| 1691 | + $alldata = $pall; |
|
| 1692 | 1692 | foreach ($alldata as $number) { |
| 1693 | 1693 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
| 1694 | 1694 | } |
@@ -1763,51 +1763,51 @@ discard block |
||
| 1763 | 1763 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
| 1764 | 1764 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 1765 | 1765 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
| 1766 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 1766 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 1767 | 1767 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
| 1768 | - //$alldata = array(); |
|
| 1769 | - foreach ($dall as $value) { |
|
| 1770 | - $icao = $value['airport_departure_icao']; |
|
| 1771 | - $dicao = $value['airline_icao']; |
|
| 1772 | - $find = false; |
|
| 1773 | - foreach ($pall as $pvalue) { |
|
| 1774 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
| 1775 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
| 1776 | - $find = true; |
|
| 1777 | - break; |
|
| 1778 | - } |
|
| 1779 | - } |
|
| 1780 | - if ($find === false) { |
|
| 1781 | - $pall[] = $value; |
|
| 1782 | - } |
|
| 1783 | - } |
|
| 1784 | - $alldata = $pall; |
|
| 1768 | + //$alldata = array(); |
|
| 1769 | + foreach ($dall as $value) { |
|
| 1770 | + $icao = $value['airport_departure_icao']; |
|
| 1771 | + $dicao = $value['airline_icao']; |
|
| 1772 | + $find = false; |
|
| 1773 | + foreach ($pall as $pvalue) { |
|
| 1774 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
| 1775 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
| 1776 | + $find = true; |
|
| 1777 | + break; |
|
| 1778 | + } |
|
| 1779 | + } |
|
| 1780 | + if ($find === false) { |
|
| 1781 | + $pall[] = $value; |
|
| 1782 | + } |
|
| 1783 | + } |
|
| 1784 | + $alldata = $pall; |
|
| 1785 | 1785 | foreach ($alldata as $number) { |
| 1786 | 1786 | 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); |
| 1787 | 1787 | } |
| 1788 | 1788 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
| 1789 | 1789 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 1790 | 1790 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
| 1791 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 1791 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 1792 | 1792 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
| 1793 | - //$alldata = array(); |
|
| 1794 | - foreach ($dall as $value) { |
|
| 1795 | - $icao = $value['airport_arrival_icao']; |
|
| 1796 | - $dicao = $value['airline_icao']; |
|
| 1797 | - $find = false; |
|
| 1798 | - foreach ($pall as $pvalue) { |
|
| 1799 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
| 1800 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
| 1801 | - $find = true; |
|
| 1802 | - break; |
|
| 1803 | - } |
|
| 1804 | - } |
|
| 1805 | - if ($find === false) { |
|
| 1806 | - $pall[] = $value; |
|
| 1807 | - } |
|
| 1808 | - } |
|
| 1809 | - $alldata = $pall; |
|
| 1810 | - foreach ($alldata as $number) { |
|
| 1793 | + //$alldata = array(); |
|
| 1794 | + foreach ($dall as $value) { |
|
| 1795 | + $icao = $value['airport_arrival_icao']; |
|
| 1796 | + $dicao = $value['airline_icao']; |
|
| 1797 | + $find = false; |
|
| 1798 | + foreach ($pall as $pvalue) { |
|
| 1799 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
| 1800 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
| 1801 | + $find = true; |
|
| 1802 | + break; |
|
| 1803 | + } |
|
| 1804 | + } |
|
| 1805 | + if ($find === false) { |
|
| 1806 | + $pall[] = $value; |
|
| 1807 | + } |
|
| 1808 | + } |
|
| 1809 | + $alldata = $pall; |
|
| 1810 | + foreach ($alldata as $number) { |
|
| 1811 | 1811 | 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); |
| 1812 | 1812 | } |
| 1813 | 1813 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
@@ -1840,47 +1840,47 @@ discard block |
||
| 1840 | 1840 | } |
| 1841 | 1841 | if ($globalDebug) echo '...Departure'."\n"; |
| 1842 | 1842 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 1843 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
| 1844 | - foreach ($dall as $value) { |
|
| 1845 | - $icao = $value['departure_airport_icao']; |
|
| 1846 | - $airline = $value['airline_icao']; |
|
| 1847 | - $ddate = $value['date']; |
|
| 1848 | - $find = false; |
|
| 1849 | - foreach ($pall as $pvalue) { |
|
| 1850 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
| 1851 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
| 1852 | - $find = true; |
|
| 1853 | - break; |
|
| 1854 | - } |
|
| 1855 | - } |
|
| 1856 | - if ($find === false) { |
|
| 1857 | - $pall[] = $value; |
|
| 1858 | - } |
|
| 1859 | - } |
|
| 1860 | - $alldata = $pall; |
|
| 1843 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
| 1844 | + foreach ($dall as $value) { |
|
| 1845 | + $icao = $value['departure_airport_icao']; |
|
| 1846 | + $airline = $value['airline_icao']; |
|
| 1847 | + $ddate = $value['date']; |
|
| 1848 | + $find = false; |
|
| 1849 | + foreach ($pall as $pvalue) { |
|
| 1850 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
| 1851 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
| 1852 | + $find = true; |
|
| 1853 | + break; |
|
| 1854 | + } |
|
| 1855 | + } |
|
| 1856 | + if ($find === false) { |
|
| 1857 | + $pall[] = $value; |
|
| 1858 | + } |
|
| 1859 | + } |
|
| 1860 | + $alldata = $pall; |
|
| 1861 | 1861 | foreach ($alldata as $number) { |
| 1862 | 1862 | $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']); |
| 1863 | 1863 | } |
| 1864 | 1864 | if ($globalDebug) echo '...Arrival'."\n"; |
| 1865 | 1865 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 1866 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
| 1867 | - foreach ($dall as $value) { |
|
| 1868 | - $icao = $value['arrival_airport_icao']; |
|
| 1869 | - $airline = $value['airline_icao']; |
|
| 1870 | - $ddate = $value['date']; |
|
| 1871 | - $find = false; |
|
| 1872 | - foreach ($pall as $pvalue) { |
|
| 1873 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
| 1874 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
| 1875 | - $find = true; |
|
| 1876 | - break; |
|
| 1877 | - } |
|
| 1878 | - } |
|
| 1879 | - if ($find === false) { |
|
| 1880 | - $pall[] = $value; |
|
| 1881 | - } |
|
| 1882 | - } |
|
| 1883 | - $alldata = $pall; |
|
| 1866 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
| 1867 | + foreach ($dall as $value) { |
|
| 1868 | + $icao = $value['arrival_airport_icao']; |
|
| 1869 | + $airline = $value['airline_icao']; |
|
| 1870 | + $ddate = $value['date']; |
|
| 1871 | + $find = false; |
|
| 1872 | + foreach ($pall as $pvalue) { |
|
| 1873 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
| 1874 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
| 1875 | + $find = true; |
|
| 1876 | + break; |
|
| 1877 | + } |
|
| 1878 | + } |
|
| 1879 | + if ($find === false) { |
|
| 1880 | + $pall[] = $value; |
|
| 1881 | + } |
|
| 1882 | + } |
|
| 1883 | + $alldata = $pall; |
|
| 1884 | 1884 | foreach ($alldata as $number) { |
| 1885 | 1885 | $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']); |
| 1886 | 1886 | } |
@@ -1963,44 +1963,44 @@ discard block |
||
| 1963 | 1963 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
| 1964 | 1964 | } |
| 1965 | 1965 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
| 1966 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
| 1967 | - $alldata = array(); |
|
| 1968 | - foreach ($pall as $value) { |
|
| 1969 | - $icao = $value['airport_departure_icao']; |
|
| 1970 | - $alldata[$icao] = $value; |
|
| 1971 | - } |
|
| 1972 | - foreach ($dall as $value) { |
|
| 1973 | - $icao = $value['airport_departure_icao']; |
|
| 1974 | - if (isset($alldata[$icao])) { |
|
| 1975 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
| 1976 | - } else $alldata[$icao] = $value; |
|
| 1977 | - } |
|
| 1978 | - $count = array(); |
|
| 1979 | - foreach ($alldata as $key => $row) { |
|
| 1980 | - $count[$key] = $row['airport_departure_icao_count']; |
|
| 1981 | - } |
|
| 1966 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
| 1967 | + $alldata = array(); |
|
| 1968 | + foreach ($pall as $value) { |
|
| 1969 | + $icao = $value['airport_departure_icao']; |
|
| 1970 | + $alldata[$icao] = $value; |
|
| 1971 | + } |
|
| 1972 | + foreach ($dall as $value) { |
|
| 1973 | + $icao = $value['airport_departure_icao']; |
|
| 1974 | + if (isset($alldata[$icao])) { |
|
| 1975 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
| 1976 | + } else $alldata[$icao] = $value; |
|
| 1977 | + } |
|
| 1978 | + $count = array(); |
|
| 1979 | + foreach ($alldata as $key => $row) { |
|
| 1980 | + $count[$key] = $row['airport_departure_icao_count']; |
|
| 1981 | + } |
|
| 1982 | 1982 | array_multisort($count,SORT_DESC,$alldata); |
| 1983 | 1983 | foreach ($alldata as $number) { |
| 1984 | - 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); |
|
| 1984 | + 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); |
|
| 1985 | 1985 | } |
| 1986 | 1986 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
| 1987 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 1987 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 1988 | 1988 | $alldata = array(); |
| 1989 | - foreach ($pall as $value) { |
|
| 1990 | - $icao = $value['airport_arrival_icao']; |
|
| 1991 | - $alldata[$icao] = $value; |
|
| 1992 | - } |
|
| 1993 | - foreach ($dall as $value) { |
|
| 1994 | - $icao = $value['airport_arrival_icao']; |
|
| 1995 | - if (isset($alldata[$icao])) { |
|
| 1996 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
| 1997 | - } else $alldata[$icao] = $value; |
|
| 1998 | - } |
|
| 1999 | - $count = array(); |
|
| 2000 | - foreach ($alldata as $key => $row) { |
|
| 2001 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
| 2002 | - } |
|
| 2003 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 1989 | + foreach ($pall as $value) { |
|
| 1990 | + $icao = $value['airport_arrival_icao']; |
|
| 1991 | + $alldata[$icao] = $value; |
|
| 1992 | + } |
|
| 1993 | + foreach ($dall as $value) { |
|
| 1994 | + $icao = $value['airport_arrival_icao']; |
|
| 1995 | + if (isset($alldata[$icao])) { |
|
| 1996 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
| 1997 | + } else $alldata[$icao] = $value; |
|
| 1998 | + } |
|
| 1999 | + $count = array(); |
|
| 2000 | + foreach ($alldata as $key => $row) { |
|
| 2001 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
| 2002 | + } |
|
| 2003 | + array_multisort($count,SORT_DESC,$alldata); |
|
| 2004 | 2004 | foreach ($alldata as $number) { |
| 2005 | 2005 | 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); |
| 2006 | 2006 | } |
@@ -2033,45 +2033,45 @@ discard block |
||
| 2033 | 2033 | } |
| 2034 | 2034 | echo '...Departure'."\n"; |
| 2035 | 2035 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
| 2036 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
| 2036 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
| 2037 | 2037 | foreach ($dall as $value) { |
| 2038 | - $icao = $value['departure_airport_icao']; |
|
| 2039 | - $ddate = $value['date']; |
|
| 2040 | - $find = false; |
|
| 2041 | - foreach ($pall as $pvalue) { |
|
| 2042 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
| 2043 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
| 2044 | - $find = true; |
|
| 2045 | - break; |
|
| 2046 | - } |
|
| 2047 | - } |
|
| 2048 | - if ($find === false) { |
|
| 2049 | - $pall[] = $value; |
|
| 2050 | - } |
|
| 2051 | - } |
|
| 2052 | - $alldata = $pall; |
|
| 2038 | + $icao = $value['departure_airport_icao']; |
|
| 2039 | + $ddate = $value['date']; |
|
| 2040 | + $find = false; |
|
| 2041 | + foreach ($pall as $pvalue) { |
|
| 2042 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
| 2043 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
| 2044 | + $find = true; |
|
| 2045 | + break; |
|
| 2046 | + } |
|
| 2047 | + } |
|
| 2048 | + if ($find === false) { |
|
| 2049 | + $pall[] = $value; |
|
| 2050 | + } |
|
| 2051 | + } |
|
| 2052 | + $alldata = $pall; |
|
| 2053 | 2053 | foreach ($alldata as $number) { |
| 2054 | 2054 | $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); |
| 2055 | 2055 | } |
| 2056 | 2056 | echo '...Arrival'."\n"; |
| 2057 | 2057 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
| 2058 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
| 2058 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
| 2059 | 2059 | foreach ($dall as $value) { |
| 2060 | 2060 | $icao = $value['arrival_airport_icao']; |
| 2061 | 2061 | $ddate = $value['date']; |
| 2062 | - $find = false; |
|
| 2062 | + $find = false; |
|
| 2063 | 2063 | foreach ($pall as $pvalue) { |
| 2064 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
| 2065 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
| 2066 | - $find = true; |
|
| 2067 | - break; |
|
| 2068 | - } |
|
| 2069 | - } |
|
| 2070 | - if ($find === false) { |
|
| 2071 | - $pall[] = $value; |
|
| 2072 | - } |
|
| 2073 | - } |
|
| 2074 | - $alldata = $pall; |
|
| 2064 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
| 2065 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
| 2066 | + $find = true; |
|
| 2067 | + break; |
|
| 2068 | + } |
|
| 2069 | + } |
|
| 2070 | + if ($find === false) { |
|
| 2071 | + $pall[] = $value; |
|
| 2072 | + } |
|
| 2073 | + } |
|
| 2074 | + $alldata = $pall; |
|
| 2075 | 2075 | foreach ($alldata as $number) { |
| 2076 | 2076 | $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); |
| 2077 | 2077 | } |