@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | //protected $cookies = array(); |
8 | 8 | |
9 | 9 | /** |
10 | - * Get data from form result |
|
11 | - * @param String $url form URL |
|
12 | - * @param String $type type of submit form method (get or post) |
|
13 | - * @param String|Array $data values form post method |
|
14 | - * @param Array $headers header to submit with the form |
|
15 | - * @return String the result |
|
16 | - */ |
|
10 | + * Get data from form result |
|
11 | + * @param String $url form URL |
|
12 | + * @param String $type type of submit form method (get or post) |
|
13 | + * @param String|Array $data values form post method |
|
14 | + * @param Array $headers header to submit with the form |
|
15 | + * @return String the result |
|
16 | + */ |
|
17 | 17 | public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
18 | 18 | global $globalProxy, $globalForceIPv4; |
19 | 19 | $ch = curl_init(); |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | - * Convert a HTML table to an array |
|
111 | - * @param String $data HTML page |
|
112 | - * @return Array array of the tables in HTML page |
|
113 | - */ |
|
110 | + * Convert a HTML table to an array |
|
111 | + * @param String $data HTML page |
|
112 | + * @return Array array of the tables in HTML page |
|
113 | + */ |
|
114 | 114 | public function table2array($data) { |
115 | 115 | if (!is_string($data)) return array(); |
116 | 116 | if ($data == '') return array(); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * Convert <p> part of a HTML page to an array |
|
148 | - * @param String $data HTML page |
|
149 | - * @return Array array of the <p> in HTML page |
|
150 | - */ |
|
147 | + * Convert <p> part of a HTML page to an array |
|
148 | + * @param String $data HTML page |
|
149 | + * @return Array array of the <p> in HTML page |
|
150 | + */ |
|
151 | 151 | public function text2array($data) { |
152 | 152 | $html = str_get_html($data); |
153 | 153 | if ($html === false) return array(); |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | - * Give distance between 2 coordonnates |
|
166 | - * @param Float $lat latitude of first point |
|
167 | - * @param Float $lon longitude of first point |
|
168 | - * @param Float $latc latitude of second point |
|
169 | - * @param Float $lonc longitude of second point |
|
170 | - * @param String $unit km else no unit used |
|
171 | - * @return Float Distance in $unit |
|
172 | - */ |
|
165 | + * Give distance between 2 coordonnates |
|
166 | + * @param Float $lat latitude of first point |
|
167 | + * @param Float $lon longitude of first point |
|
168 | + * @param Float $latc latitude of second point |
|
169 | + * @param Float $lonc longitude of second point |
|
170 | + * @param String $unit km else no unit used |
|
171 | + * @return Float Distance in $unit |
|
172 | + */ |
|
173 | 173 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
174 | 174 | if ($lat == $latc && $lon == $lonc) return 0; |
175 | 175 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | - * Check is distance realistic |
|
191 | - * @param int $timeDifference the time between the reception of both messages |
|
192 | - * @param float $distance distance covered |
|
193 | - * @return whether distance is realistic |
|
194 | - */ |
|
190 | + * Check is distance realistic |
|
191 | + * @param int $timeDifference the time between the reception of both messages |
|
192 | + * @param float $distance distance covered |
|
193 | + * @return whether distance is realistic |
|
194 | + */ |
|
195 | 195 | public function withinThreshold ($timeDifference, $distance) { |
196 | 196 | $x = abs($timeDifference); |
197 | 197 | $d = abs($distance); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | public function isInteger($input){ |
212 | - return(ctype_digit(strval($input))); |
|
212 | + return(ctype_digit(strval($input))); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -240,11 +240,11 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
243 | - * Copy folder contents |
|
244 | - * @param string $source Source path |
|
245 | - * @param string $dest Destination path |
|
246 | - * @return bool Returns true on success, false on failure |
|
247 | - */ |
|
243 | + * Copy folder contents |
|
244 | + * @param string $source Source path |
|
245 | + * @param string $dest Destination path |
|
246 | + * @return bool Returns true on success, false on failure |
|
247 | + */ |
|
248 | 248 | public function xcopy($source, $dest) |
249 | 249 | { |
250 | 250 | $files = glob($source.'*.*'); |
@@ -256,20 +256,20 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | - * Check if an url exist |
|
260 | - * @param String $url url to check |
|
261 | - * @return bool Return true on succes false on failure |
|
262 | - */ |
|
259 | + * Check if an url exist |
|
260 | + * @param String $url url to check |
|
261 | + * @return bool Return true on succes false on failure |
|
262 | + */ |
|
263 | 263 | public function urlexist($url){ |
264 | 264 | $headers=get_headers($url); |
265 | 265 | return stripos($headers[0],"200 OK")?true:false; |
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | - * Convert hexa to string |
|
270 | - * @param String $hex data in hexa |
|
271 | - * @return String Return result |
|
272 | - */ |
|
269 | + * Convert hexa to string |
|
270 | + * @param String $hex data in hexa |
|
271 | + * @return String Return result |
|
272 | + */ |
|
273 | 273 | public function hex2str($hex) { |
274 | 274 | $str = ''; |
275 | 275 | $hexln = strlen($hex); |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
281 | - * Convert hexa color to rgb |
|
282 | - * @param String $hex data in hexa |
|
283 | - * @return String Return result |
|
284 | - */ |
|
281 | + * Convert hexa color to rgb |
|
282 | + * @param String $hex data in hexa |
|
283 | + * @return String Return result |
|
284 | + */ |
|
285 | 285 | public function hex2rgb($hex) { |
286 | 286 | $hex = str_replace('#','',$hex); |
287 | 287 | return sscanf($hex, "%02x%02x%02x"); |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | - * Returns list of available locales |
|
363 | - * |
|
364 | - * @return array |
|
362 | + * Returns list of available locales |
|
363 | + * |
|
364 | + * @return array |
|
365 | 365 | */ |
366 | 366 | public function listLocaleDir() |
367 | 367 | { |
@@ -456,100 +456,100 @@ discard block |
||
456 | 456 | public function remove_accents($string) { |
457 | 457 | if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
458 | 458 | $chars = array( |
459 | - // Decompositions for Latin-1 Supplement |
|
460 | - chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
461 | - chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
462 | - chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
463 | - chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
464 | - chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
465 | - chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
466 | - chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
467 | - chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
468 | - chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
469 | - chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
470 | - chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
471 | - chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
472 | - chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
473 | - chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
474 | - chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
475 | - chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
476 | - chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
477 | - chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
478 | - chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
479 | - chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
480 | - chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
481 | - chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
482 | - chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
483 | - chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
484 | - chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
485 | - chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
486 | - chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
487 | - chr(195).chr(191) => 'y', |
|
488 | - // Decompositions for Latin Extended-A |
|
489 | - chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
490 | - chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
491 | - chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
492 | - chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
493 | - chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
494 | - chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
495 | - chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
496 | - chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
497 | - chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
498 | - chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
499 | - chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
500 | - chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
501 | - chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
502 | - chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
503 | - chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
504 | - chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
505 | - chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
506 | - chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
507 | - chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
508 | - chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
509 | - chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
510 | - chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
511 | - chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
512 | - chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
513 | - chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
514 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
515 | - chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
516 | - chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
517 | - chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
518 | - chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
519 | - chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
520 | - chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
521 | - chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
522 | - chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
523 | - chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
524 | - chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
525 | - chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
526 | - chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
527 | - chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
528 | - chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
529 | - chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
530 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
531 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
532 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
533 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
534 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
535 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
536 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
537 | - chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
538 | - chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
539 | - chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
540 | - chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
541 | - chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
542 | - chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
543 | - chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
544 | - chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
545 | - chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
546 | - chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
547 | - chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
548 | - chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
549 | - chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
550 | - chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
551 | - chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
552 | - chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
459 | + // Decompositions for Latin-1 Supplement |
|
460 | + chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
461 | + chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
462 | + chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
463 | + chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
464 | + chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
465 | + chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
466 | + chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
467 | + chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
468 | + chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
469 | + chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
470 | + chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
471 | + chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
472 | + chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
473 | + chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
474 | + chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
475 | + chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
476 | + chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
477 | + chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
478 | + chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
479 | + chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
480 | + chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
481 | + chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
482 | + chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
483 | + chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
484 | + chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
485 | + chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
486 | + chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
487 | + chr(195).chr(191) => 'y', |
|
488 | + // Decompositions for Latin Extended-A |
|
489 | + chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
490 | + chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
491 | + chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
492 | + chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
493 | + chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
494 | + chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
495 | + chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
496 | + chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
497 | + chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
498 | + chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
499 | + chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
500 | + chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
501 | + chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
502 | + chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
503 | + chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
504 | + chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
505 | + chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
506 | + chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
507 | + chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
508 | + chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
509 | + chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
510 | + chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
511 | + chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
512 | + chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
513 | + chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
514 | + chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
515 | + chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
516 | + chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
517 | + chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
518 | + chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
519 | + chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
520 | + chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
521 | + chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
522 | + chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
523 | + chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
524 | + chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
525 | + chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
526 | + chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
527 | + chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
528 | + chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
529 | + chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
530 | + chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
531 | + chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
532 | + chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
533 | + chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
534 | + chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
535 | + chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
536 | + chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
537 | + chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
538 | + chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
539 | + chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
540 | + chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
541 | + chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
542 | + chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
543 | + chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
544 | + chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
545 | + chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
546 | + chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
547 | + chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
548 | + chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
549 | + chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
550 | + chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
551 | + chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
552 | + chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
553 | 553 | ); |
554 | 554 | $string = strtr($string, $chars); |
555 | 555 | return $string; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | date_default_timezone_set('UTC'); |
28 | 28 | //waypoint plotting |
29 | 29 | $output .= '{"type": "Feature",'; |
30 | - $output .= '"properties": {'; |
|
30 | + $output .= '"properties": {'; |
|
31 | 31 | $output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",'; |
32 | 32 | $output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",'; |
33 | 33 | $output .= '"country": "'.$spotter_item['country'].'",'; |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | $output .= '"homepage": "'.$spotter_item['home_link'].'",'; |
51 | 51 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
52 | 52 | // $output .= '"photo": "'.$spotter_item['image_thumbnail'].'",'; |
53 | - $output .= '},'; |
|
54 | - $output .= '"geometry": {'; |
|
53 | + $output .= '},'; |
|
54 | + $output .= '"geometry": {'; |
|
55 | 55 | $output .= '"type": "Point",'; |
56 | 56 | $output .= '"coordinates": ['; |
57 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
57 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
58 | 58 | $output .= ']'; |
59 | - $output .= '}'; |
|
59 | + $output .= '}'; |
|
60 | 60 | $output .= '},'; |
61 | 61 | } |
62 | 62 | $output = substr($output, 0, -1); |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['airline'])) { |
7 | - header('Location: '.$globalURL.'/airline'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/airline'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 11 | $Spotter = new Spotter(); |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | } |
77 | 77 | $country_data = substr($country_data, 0, -1); |
78 | 78 | print $country_data; |
79 | - print '];'; |
|
80 | - print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
81 | - print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
82 | - print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});'; |
|
83 | - print 'new Datamap({ |
|
79 | + print '];'; |
|
80 | + print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
81 | + print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
82 | + print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});'; |
|
83 | + print 'new Datamap({ |
|
84 | 84 | element: document.getElementById("chartCountry"), |
85 | 85 | projection: "mercator", // big world map |
86 | 86 | fills: { defaultFill: "#F5F5F5" }, |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | print '<div class="select-item">'; |
22 | 22 | print '<form action="'.$globalURL.'/aircraft" method="post">'; |
23 | 23 | print '<select name="aircraft_type" class="selectpicker" data-live-search="true">'; |
24 | - print '<option></option>'; |
|
25 | - $Stats = new Stats(); |
|
26 | - $aircraft_types = $Stats->getAllAircraftTypes(); |
|
27 | - if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
28 | - foreach($aircraft_types as $aircrafttype) |
|
29 | - { |
|
30 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | - { |
|
32 | - print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
33 | - } else { |
|
34 | - print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
35 | - } |
|
24 | + print '<option></option>'; |
|
25 | + $Stats = new Stats(); |
|
26 | + $aircraft_types = $Stats->getAllAircraftTypes(); |
|
27 | + if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
28 | + foreach($aircraft_types as $aircrafttype) |
|
29 | + { |
|
30 | + if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | + { |
|
32 | + print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
33 | + } else { |
|
34 | + print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | print '</select>'; |
38 | 38 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
@@ -61,18 +61,18 @@ discard block |
||
61 | 61 | print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>'; |
62 | 62 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
63 | 63 | print 'var series = ['; |
64 | - $country_data = ''; |
|
64 | + $country_data = ''; |
|
65 | 65 | foreach($airline_array as $airline_item) |
66 | 66 | { |
67 | 67 | $country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],'; |
68 | 68 | } |
69 | - $country_data = substr($country_data, 0, -1); |
|
70 | - print $country_data; |
|
71 | - print '];'; |
|
72 | - print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
73 | - print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
74 | - print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});'; |
|
75 | - print 'new Datamap({ |
|
69 | + $country_data = substr($country_data, 0, -1); |
|
70 | + print $country_data; |
|
71 | + print '];'; |
|
72 | + print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
73 | + print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
74 | + print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});'; |
|
75 | + print 'new Datamap({ |
|
76 | 76 | element: document.getElementById("chartCountry"), |
77 | 77 | projection: "mercator", // big world map |
78 | 78 | fills: { defaultFill: "#F5F5F5" }, |
@@ -75,38 +75,38 @@ discard block |
||
75 | 75 | try { |
76 | 76 | //$Connection = new Connection(); |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | - $sth->execute(array(':source' => $database_file)); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error : ".$e->getMessage(); |
|
81 | - } |
|
78 | + $sth->execute(array(':source' => $database_file)); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error : ".$e->getMessage(); |
|
81 | + } |
|
82 | 82 | |
83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
84 | - update_db::connect_sqlite($database_file); |
|
83 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
84 | + update_db::connect_sqlite($database_file); |
|
85 | 85 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
86 | 86 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
87 | 87 | try { |
88 | - $sth = update_db::$db_sqlite->prepare($query); |
|
89 | - $sth->execute(); |
|
90 | - } catch(PDOException $e) { |
|
91 | - return "error : ".$e->getMessage(); |
|
92 | - } |
|
88 | + $sth = update_db::$db_sqlite->prepare($query); |
|
89 | + $sth->execute(); |
|
90 | + } catch(PDOException $e) { |
|
91 | + return "error : ".$e->getMessage(); |
|
92 | + } |
|
93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
94 | 94 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
95 | 95 | $Connection = new Connection(); |
96 | 96 | $sth_dest = $Connection->db->prepare($query_dest); |
97 | 97 | try { |
98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
99 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
99 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
100 | 100 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
101 | 101 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 102 | $sth_dest->execute($query_dest_values); |
103 | - } |
|
103 | + } |
|
104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
105 | 105 | } catch(PDOException $e) { |
106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
109 | - return ''; |
|
109 | + return ''; |
|
110 | 110 | } |
111 | 111 | public static function retrieve_route_oneworld($database_file) { |
112 | 112 | global $globalDebug, $globalTransaction; |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | try { |
118 | 118 | //$Connection = new Connection(); |
119 | 119 | $sth = $Connection->db->prepare($query); |
120 | - $sth->execute(array(':source' => 'oneworld')); |
|
121 | - } catch(PDOException $e) { |
|
122 | - return "error : ".$e->getMessage(); |
|
123 | - } |
|
120 | + $sth->execute(array(':source' => 'oneworld')); |
|
121 | + } catch(PDOException $e) { |
|
122 | + return "error : ".$e->getMessage(); |
|
123 | + } |
|
124 | 124 | |
125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
125 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 127 | $Spotter = new Spotter(); |
128 | 128 | if ($fh = fopen($database_file,"r")) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | } |
147 | 147 | if ($globalTransaction) $Connection->db->commit(); |
148 | 148 | } |
149 | - return ''; |
|
149 | + return ''; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | public static function retrieve_route_skyteam($database_file) { |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | try { |
159 | 159 | //$Connection = new Connection(); |
160 | 160 | $sth = $Connection->db->prepare($query); |
161 | - $sth->execute(array(':source' => 'skyteam')); |
|
162 | - } catch(PDOException $e) { |
|
163 | - return "error : ".$e->getMessage(); |
|
164 | - } |
|
161 | + $sth->execute(array(':source' => 'skyteam')); |
|
162 | + } catch(PDOException $e) { |
|
163 | + return "error : ".$e->getMessage(); |
|
164 | + } |
|
165 | 165 | |
166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
166 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
167 | 167 | |
168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 169 | $Spotter = new Spotter(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | return "error : ".$e->getMessage(); |
190 | 190 | } |
191 | 191 | } |
192 | - return ''; |
|
192 | + return ''; |
|
193 | 193 | } |
194 | 194 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
195 | 195 | global $globalTransaction; |
@@ -198,27 +198,27 @@ discard block |
||
198 | 198 | try { |
199 | 199 | $Connection = new Connection(); |
200 | 200 | $sth = $Connection->db->prepare($query); |
201 | - $sth->execute(array(':source' => $database_file)); |
|
202 | - } catch(PDOException $e) { |
|
203 | - return "error : ".$e->getMessage(); |
|
204 | - } |
|
201 | + $sth->execute(array(':source' => $database_file)); |
|
202 | + } catch(PDOException $e) { |
|
203 | + return "error : ".$e->getMessage(); |
|
204 | + } |
|
205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
206 | 206 | try { |
207 | 207 | $Connection = new Connection(); |
208 | 208 | $sth = $Connection->db->prepare($query); |
209 | - $sth->execute(array(':source' => $database_file)); |
|
210 | - } catch(PDOException $e) { |
|
211 | - return "error : ".$e->getMessage(); |
|
212 | - } |
|
209 | + $sth->execute(array(':source' => $database_file)); |
|
210 | + } catch(PDOException $e) { |
|
211 | + return "error : ".$e->getMessage(); |
|
212 | + } |
|
213 | 213 | |
214 | - update_db::connect_sqlite($database_file); |
|
214 | + update_db::connect_sqlite($database_file); |
|
215 | 215 | $query = 'select * from Aircraft'; |
216 | 216 | try { |
217 | - $sth = update_db::$db_sqlite->prepare($query); |
|
218 | - $sth->execute(); |
|
219 | - } catch(PDOException $e) { |
|
220 | - return "error : ".$e->getMessage(); |
|
221 | - } |
|
217 | + $sth = update_db::$db_sqlite->prepare($query); |
|
218 | + $sth->execute(); |
|
219 | + } catch(PDOException $e) { |
|
220 | + return "error : ".$e->getMessage(); |
|
221 | + } |
|
222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
223 | 223 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
224 | 224 | |
@@ -229,17 +229,17 @@ discard block |
||
229 | 229 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
230 | 230 | try { |
231 | 231 | if ($globalTransaction) $Connection->db->beginTransaction(); |
232 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
232 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
233 | 233 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
234 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
235 | 235 | else $type = null; |
236 | 236 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
237 | 237 | $sth_dest->execute($query_dest_values); |
238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
240 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
239 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
240 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
241 | 241 | } |
242 | - } |
|
242 | + } |
|
243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
244 | 244 | } catch(PDOException $e) { |
245 | 245 | return "error : ".$e->getMessage(); |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $Connection = new Connection(); |
252 | 252 | $sth = $Connection->db->prepare($query); |
253 | - $sth->execute(array(':source' => $database_file)); |
|
254 | - } catch(PDOException $e) { |
|
255 | - return "error : ".$e->getMessage(); |
|
256 | - } |
|
253 | + $sth->execute(array(':source' => $database_file)); |
|
254 | + } catch(PDOException $e) { |
|
255 | + return "error : ".$e->getMessage(); |
|
256 | + } |
|
257 | 257 | return ''; |
258 | 258 | } |
259 | 259 | |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $Connection = new Connection(); |
267 | 267 | $sth = $Connection->db->prepare($query); |
268 | - $sth->execute(array(':source' => $database_file)); |
|
269 | - } catch(PDOException $e) { |
|
270 | - return "error : ".$e->getMessage(); |
|
271 | - } |
|
268 | + $sth->execute(array(':source' => $database_file)); |
|
269 | + } catch(PDOException $e) { |
|
270 | + return "error : ".$e->getMessage(); |
|
271 | + } |
|
272 | 272 | |
273 | 273 | if ($fh = fopen($database_file,"r")) { |
274 | 274 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -278,26 +278,26 @@ discard block |
||
278 | 278 | $sth_dest = $Connection->db->prepare($query_dest); |
279 | 279 | try { |
280 | 280 | if ($globalTransaction) $Connection->db->beginTransaction(); |
281 | - while (!feof($fh)) { |
|
282 | - $values = array(); |
|
283 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
281 | + while (!feof($fh)) { |
|
282 | + $values = array(); |
|
283 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
284 | 284 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
285 | - $values['ModeS'] = substr($line,0,6); |
|
286 | - $values['Registration'] = trim(substr($line,69,6)); |
|
287 | - $aircraft_name = trim(substr($line,48,6)); |
|
288 | - // Check if we can find ICAO, else set it to GLID |
|
289 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
290 | - $search_more = ''; |
|
291 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
292 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
293 | - $sth_search = $Connection->db->prepare($query_search); |
|
285 | + $values['ModeS'] = substr($line,0,6); |
|
286 | + $values['Registration'] = trim(substr($line,69,6)); |
|
287 | + $aircraft_name = trim(substr($line,48,6)); |
|
288 | + // Check if we can find ICAO, else set it to GLID |
|
289 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
290 | + $search_more = ''; |
|
291 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
292 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
293 | + $sth_search = $Connection->db->prepare($query_search); |
|
294 | 294 | try { |
295 | - $sth_search->execute(); |
|
296 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
297 | - //if (count($result) > 0) { |
|
298 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
299 | - $values['ICAOTypeCode'] = $result['icao']; |
|
300 | - } |
|
295 | + $sth_search->execute(); |
|
296 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
297 | + //if (count($result) > 0) { |
|
298 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
299 | + $values['ICAOTypeCode'] = $result['icao']; |
|
300 | + } |
|
301 | 301 | } catch(PDOException $e) { |
302 | 302 | return "error : ".$e->getMessage(); |
303 | 303 | } |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $Connection = new Connection(); |
322 | 322 | $sth = $Connection->db->prepare($query); |
323 | - $sth->execute(array(':source' => $database_file)); |
|
324 | - } catch(PDOException $e) { |
|
325 | - return "error : ".$e->getMessage(); |
|
326 | - } |
|
323 | + $sth->execute(array(':source' => $database_file)); |
|
324 | + } catch(PDOException $e) { |
|
325 | + return "error : ".$e->getMessage(); |
|
326 | + } |
|
327 | 327 | return ''; |
328 | 328 | } |
329 | 329 | |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | try { |
335 | 335 | $Connection = new Connection(); |
336 | 336 | $sth = $Connection->db->prepare($query); |
337 | - $sth->execute(array(':source' => $database_file)); |
|
338 | - } catch(PDOException $e) { |
|
339 | - return "error : ".$e->getMessage(); |
|
340 | - } |
|
337 | + $sth->execute(array(':source' => $database_file)); |
|
338 | + } catch(PDOException $e) { |
|
339 | + return "error : ".$e->getMessage(); |
|
340 | + } |
|
341 | 341 | |
342 | 342 | if ($fh = fopen($database_file,"r")) { |
343 | 343 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -348,24 +348,24 @@ discard block |
||
348 | 348 | try { |
349 | 349 | if ($globalTransaction) $Connection->db->beginTransaction(); |
350 | 350 | $tmp = fgetcsv($fh,9999,',',"'"); |
351 | - while (!feof($fh)) { |
|
352 | - $line = fgetcsv($fh,9999,',',"'"); |
|
351 | + while (!feof($fh)) { |
|
352 | + $line = fgetcsv($fh,9999,',',"'"); |
|
353 | 353 | |
354 | 354 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
355 | 355 | //print_r($line); |
356 | - $values['ModeS'] = $line[1]; |
|
357 | - $values['Registration'] = $line[3]; |
|
358 | - $aircraft_name = $line[2]; |
|
359 | - // Check if we can find ICAO, else set it to GLID |
|
360 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
361 | - $search_more = ''; |
|
362 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
363 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
364 | - $sth_search = $Connection->db->prepare($query_search); |
|
356 | + $values['ModeS'] = $line[1]; |
|
357 | + $values['Registration'] = $line[3]; |
|
358 | + $aircraft_name = $line[2]; |
|
359 | + // Check if we can find ICAO, else set it to GLID |
|
360 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
361 | + $search_more = ''; |
|
362 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
363 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
364 | + $sth_search = $Connection->db->prepare($query_search); |
|
365 | 365 | try { |
366 | - $sth_search->execute(); |
|
367 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
368 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
366 | + $sth_search->execute(); |
|
367 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
368 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
369 | 369 | } catch(PDOException $e) { |
370 | 370 | return "error : ".$e->getMessage(); |
371 | 371 | } |
@@ -388,10 +388,10 @@ discard block |
||
388 | 388 | try { |
389 | 389 | $Connection = new Connection(); |
390 | 390 | $sth = $Connection->db->prepare($query); |
391 | - $sth->execute(array(':source' => $database_file)); |
|
392 | - } catch(PDOException $e) { |
|
393 | - return "error : ".$e->getMessage(); |
|
394 | - } |
|
391 | + $sth->execute(array(':source' => $database_file)); |
|
392 | + } catch(PDOException $e) { |
|
393 | + return "error : ".$e->getMessage(); |
|
394 | + } |
|
395 | 395 | return ''; |
396 | 396 | } |
397 | 397 | |
@@ -402,16 +402,16 @@ discard block |
||
402 | 402 | try { |
403 | 403 | $Connection = new Connection(); |
404 | 404 | $sth = $Connection->db->prepare($query); |
405 | - $sth->execute(array(':source' => $database_file)); |
|
406 | - } catch(PDOException $e) { |
|
407 | - return "error : ".$e->getMessage(); |
|
408 | - } |
|
405 | + $sth->execute(array(':source' => $database_file)); |
|
406 | + } catch(PDOException $e) { |
|
407 | + return "error : ".$e->getMessage(); |
|
408 | + } |
|
409 | 409 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
410 | 410 | $Spotter = new Spotter(); |
411 | 411 | if ($fh = fopen($database_file,"r")) { |
412 | 412 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
413 | 413 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
414 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
414 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
415 | 415 | |
416 | 416 | $Connection = new Connection(); |
417 | 417 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -419,126 +419,126 @@ discard block |
||
419 | 419 | try { |
420 | 420 | if ($globalTransaction) $Connection->db->beginTransaction(); |
421 | 421 | $tmp = fgetcsv($fh,9999,',','"'); |
422 | - while (!feof($fh)) { |
|
423 | - $line = fgetcsv($fh,9999,',','"'); |
|
424 | - $values = array(); |
|
425 | - //print_r($line); |
|
426 | - if ($country == 'F') { |
|
427 | - $values['registration'] = $line[0]; |
|
428 | - $values['base'] = $line[4]; |
|
429 | - $values['owner'] = $line[5]; |
|
430 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
431 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
432 | - $values['cancel'] = $line[7]; |
|
422 | + while (!feof($fh)) { |
|
423 | + $line = fgetcsv($fh,9999,',','"'); |
|
424 | + $values = array(); |
|
425 | + //print_r($line); |
|
426 | + if ($country == 'F') { |
|
427 | + $values['registration'] = $line[0]; |
|
428 | + $values['base'] = $line[4]; |
|
429 | + $values['owner'] = $line[5]; |
|
430 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
431 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
432 | + $values['cancel'] = $line[7]; |
|
433 | 433 | } elseif ($country == 'EI') { |
434 | - // TODO : add modeS & reg to aircraft_modes |
|
435 | - $values['registration'] = $line[0]; |
|
436 | - $values['base'] = $line[3]; |
|
437 | - $values['owner'] = $line[2]; |
|
438 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
439 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
440 | - $values['cancel'] = ''; |
|
441 | - $values['modes'] = $line[7]; |
|
442 | - $values['icao'] = $line[8]; |
|
434 | + // TODO : add modeS & reg to aircraft_modes |
|
435 | + $values['registration'] = $line[0]; |
|
436 | + $values['base'] = $line[3]; |
|
437 | + $values['owner'] = $line[2]; |
|
438 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
439 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
440 | + $values['cancel'] = ''; |
|
441 | + $values['modes'] = $line[7]; |
|
442 | + $values['icao'] = $line[8]; |
|
443 | 443 | |
444 | 444 | } elseif ($country == 'HB') { |
445 | - // TODO : add modeS & reg to aircraft_modes |
|
446 | - $values['registration'] = $line[0]; |
|
447 | - $values['base'] = null; |
|
448 | - $values['owner'] = $line[5]; |
|
449 | - $values['date_first_reg'] = null; |
|
450 | - $values['cancel'] = ''; |
|
451 | - $values['modes'] = $line[4]; |
|
452 | - $values['icao'] = $line[7]; |
|
445 | + // TODO : add modeS & reg to aircraft_modes |
|
446 | + $values['registration'] = $line[0]; |
|
447 | + $values['base'] = null; |
|
448 | + $values['owner'] = $line[5]; |
|
449 | + $values['date_first_reg'] = null; |
|
450 | + $values['cancel'] = ''; |
|
451 | + $values['modes'] = $line[4]; |
|
452 | + $values['icao'] = $line[7]; |
|
453 | 453 | } elseif ($country == 'OK') { |
454 | - // TODO : add modeS & reg to aircraft_modes |
|
455 | - $values['registration'] = $line[3]; |
|
456 | - $values['base'] = null; |
|
457 | - $values['owner'] = $line[5]; |
|
458 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
459 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
460 | - $values['cancel'] = ''; |
|
454 | + // TODO : add modeS & reg to aircraft_modes |
|
455 | + $values['registration'] = $line[3]; |
|
456 | + $values['base'] = null; |
|
457 | + $values['owner'] = $line[5]; |
|
458 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
459 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
460 | + $values['cancel'] = ''; |
|
461 | 461 | } elseif ($country == 'VH') { |
462 | - // TODO : add modeS & reg to aircraft_modes |
|
463 | - $values['registration'] = $line[0]; |
|
464 | - $values['base'] = null; |
|
465 | - $values['owner'] = $line[12]; |
|
466 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
467 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
468 | - |
|
469 | - $values['cancel'] = $line[39]; |
|
462 | + // TODO : add modeS & reg to aircraft_modes |
|
463 | + $values['registration'] = $line[0]; |
|
464 | + $values['base'] = null; |
|
465 | + $values['owner'] = $line[12]; |
|
466 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
467 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
468 | + |
|
469 | + $values['cancel'] = $line[39]; |
|
470 | 470 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
471 | - $values['registration'] = $line[0]; |
|
472 | - $values['base'] = null; |
|
473 | - $values['owner'] = $line[4]; |
|
474 | - $values['date_first_reg'] = null; |
|
475 | - $values['cancel'] = ''; |
|
471 | + $values['registration'] = $line[0]; |
|
472 | + $values['base'] = null; |
|
473 | + $values['owner'] = $line[4]; |
|
474 | + $values['date_first_reg'] = null; |
|
475 | + $values['cancel'] = ''; |
|
476 | 476 | } elseif ($country == 'CC') { |
477 | - $values['registration'] = $line[0]; |
|
478 | - $values['base'] = null; |
|
479 | - $values['owner'] = $line[6]; |
|
480 | - $values['date_first_reg'] = null; |
|
481 | - $values['cancel'] = ''; |
|
477 | + $values['registration'] = $line[0]; |
|
478 | + $values['base'] = null; |
|
479 | + $values['owner'] = $line[6]; |
|
480 | + $values['date_first_reg'] = null; |
|
481 | + $values['cancel'] = ''; |
|
482 | 482 | } elseif ($country == 'HJ') { |
483 | - $values['registration'] = $line[0]; |
|
484 | - $values['base'] = null; |
|
485 | - $values['owner'] = $line[8]; |
|
486 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
487 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
488 | - $values['cancel'] = ''; |
|
483 | + $values['registration'] = $line[0]; |
|
484 | + $values['base'] = null; |
|
485 | + $values['owner'] = $line[8]; |
|
486 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
487 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
488 | + $values['cancel'] = ''; |
|
489 | 489 | } elseif ($country == 'PP') { |
490 | - $values['registration'] = $line[0]; |
|
491 | - $values['base'] = null; |
|
492 | - $values['owner'] = $line[4]; |
|
493 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
494 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
495 | - $values['cancel'] = $line[7]; |
|
490 | + $values['registration'] = $line[0]; |
|
491 | + $values['base'] = null; |
|
492 | + $values['owner'] = $line[4]; |
|
493 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
494 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
495 | + $values['cancel'] = $line[7]; |
|
496 | 496 | } elseif ($country == 'E7') { |
497 | - $values['registration'] = $line[0]; |
|
498 | - $values['base'] = null; |
|
499 | - $values['owner'] = $line[4]; |
|
500 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
501 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
502 | - $values['cancel'] = ''; |
|
497 | + $values['registration'] = $line[0]; |
|
498 | + $values['base'] = null; |
|
499 | + $values['owner'] = $line[4]; |
|
500 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
501 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
502 | + $values['cancel'] = ''; |
|
503 | 503 | } elseif ($country == '8Q') { |
504 | - $values['registration'] = $line[0]; |
|
505 | - $values['base'] = null; |
|
506 | - $values['owner'] = $line[3]; |
|
507 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
508 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
509 | - $values['cancel'] = ''; |
|
504 | + $values['registration'] = $line[0]; |
|
505 | + $values['base'] = null; |
|
506 | + $values['owner'] = $line[3]; |
|
507 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
508 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
509 | + $values['cancel'] = ''; |
|
510 | 510 | } elseif ($country == 'ZK') { |
511 | - $values['registration'] = $line[0]; |
|
512 | - $values['base'] = null; |
|
513 | - $values['owner'] = $line[3]; |
|
514 | - $values['date_first_reg'] = null; |
|
515 | - $values['cancel'] = ''; |
|
516 | - $values['modes'] = $line[5]; |
|
517 | - $values['icao'] = $line[9]; |
|
511 | + $values['registration'] = $line[0]; |
|
512 | + $values['base'] = null; |
|
513 | + $values['owner'] = $line[3]; |
|
514 | + $values['date_first_reg'] = null; |
|
515 | + $values['cancel'] = ''; |
|
516 | + $values['modes'] = $line[5]; |
|
517 | + $values['icao'] = $line[9]; |
|
518 | 518 | } elseif ($country == 'M') { |
519 | - $values['registration'] = $line[0]; |
|
520 | - $values['base'] = null; |
|
521 | - $values['owner'] = $line[6]; |
|
522 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
523 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
524 | - $values['modes'] = $line[4]; |
|
525 | - $values['icao'] = $line[10]; |
|
519 | + $values['registration'] = $line[0]; |
|
520 | + $values['base'] = null; |
|
521 | + $values['owner'] = $line[6]; |
|
522 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
523 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
524 | + $values['modes'] = $line[4]; |
|
525 | + $values['icao'] = $line[10]; |
|
526 | 526 | } elseif ($country == 'OY') { |
527 | - $values['registration'] = $line[0]; |
|
528 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
529 | - $values['modes'] = $line[5]; |
|
530 | - $values['icao'] = $line[6]; |
|
527 | + $values['registration'] = $line[0]; |
|
528 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
529 | + $values['modes'] = $line[5]; |
|
530 | + $values['icao'] = $line[6]; |
|
531 | 531 | } elseif ($country == 'PH') { |
532 | - $values['registration'] = $line[0]; |
|
533 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
534 | - $values['modes'] = $line[4]; |
|
535 | - $values['icao'] = $line[5]; |
|
532 | + $values['registration'] = $line[0]; |
|
533 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
534 | + $values['modes'] = $line[4]; |
|
535 | + $values['icao'] = $line[5]; |
|
536 | 536 | } elseif ($country == 'OM' || $country == 'TF') { |
537 | - $values['registration'] = $line[0]; |
|
538 | - $values['base'] = null; |
|
539 | - $values['owner'] = $line[3]; |
|
540 | - $values['date_first_reg'] = null; |
|
541 | - $values['cancel'] = ''; |
|
537 | + $values['registration'] = $line[0]; |
|
538 | + $values['base'] = null; |
|
539 | + $values['owner'] = $line[3]; |
|
540 | + $values['date_first_reg'] = null; |
|
541 | + $values['cancel'] = ''; |
|
542 | 542 | } |
543 | 543 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
544 | 544 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -665,20 +665,20 @@ discard block |
||
665 | 665 | try { |
666 | 666 | $Connection = new Connection(); |
667 | 667 | $sth = $Connection->db->prepare($query); |
668 | - $sth->execute(); |
|
669 | - } catch(PDOException $e) { |
|
670 | - return "error : ".$e->getMessage(); |
|
671 | - } |
|
668 | + $sth->execute(); |
|
669 | + } catch(PDOException $e) { |
|
670 | + return "error : ".$e->getMessage(); |
|
671 | + } |
|
672 | 672 | |
673 | 673 | |
674 | 674 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
675 | 675 | try { |
676 | 676 | $Connection = new Connection(); |
677 | 677 | $sth = $Connection->db->prepare($query); |
678 | - $sth->execute(); |
|
679 | - } catch(PDOException $e) { |
|
680 | - return "error : ".$e->getMessage(); |
|
681 | - } |
|
678 | + $sth->execute(); |
|
679 | + } catch(PDOException $e) { |
|
680 | + return "error : ".$e->getMessage(); |
|
681 | + } |
|
682 | 682 | |
683 | 683 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) |
684 | 684 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
@@ -744,10 +744,10 @@ discard block |
||
744 | 744 | try { |
745 | 745 | $Connection = new Connection(); |
746 | 746 | $sth = $Connection->db->prepare($query); |
747 | - $sth->execute(); |
|
748 | - } catch(PDOException $e) { |
|
749 | - return "error : ".$e->getMessage(); |
|
750 | - } |
|
747 | + $sth->execute(); |
|
748 | + } catch(PDOException $e) { |
|
749 | + return "error : ".$e->getMessage(); |
|
750 | + } |
|
751 | 751 | |
752 | 752 | |
753 | 753 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
@@ -757,10 +757,10 @@ discard block |
||
757 | 757 | try { |
758 | 758 | $Connection = new Connection(); |
759 | 759 | $sth = $Connection->db->prepare($query); |
760 | - $sth->execute($query_values); |
|
761 | - } catch(PDOException $e) { |
|
762 | - return "error : ".$e->getMessage(); |
|
763 | - } |
|
760 | + $sth->execute($query_values); |
|
761 | + } catch(PDOException $e) { |
|
762 | + return "error : ".$e->getMessage(); |
|
763 | + } |
|
764 | 764 | $i++; |
765 | 765 | /* |
766 | 766 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | |
875 | 875 | |
876 | 876 | |
877 | - return "success"; |
|
877 | + return "success"; |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | public static function translation() { |
@@ -890,10 +890,10 @@ discard block |
||
890 | 890 | try { |
891 | 891 | $Connection = new Connection(); |
892 | 892 | $sth = $Connection->db->prepare($query); |
893 | - $sth->execute(array(':source' => 'translation.csv')); |
|
894 | - } catch(PDOException $e) { |
|
895 | - return "error : ".$e->getMessage(); |
|
896 | - } |
|
893 | + $sth->execute(array(':source' => 'translation.csv')); |
|
894 | + } catch(PDOException $e) { |
|
895 | + return "error : ".$e->getMessage(); |
|
896 | + } |
|
897 | 897 | |
898 | 898 | |
899 | 899 | //update_db::unzip($out_file); |
@@ -912,21 +912,21 @@ discard block |
||
912 | 912 | $data = $row; |
913 | 913 | $operator = $data[2]; |
914 | 914 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
915 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
916 | - //echo substr($operator, 0, 2)."\n";; |
|
917 | - if (count($airline_array) > 0) { |
|
915 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
916 | + //echo substr($operator, 0, 2)."\n";; |
|
917 | + if (count($airline_array) > 0) { |
|
918 | 918 | //print_r($airline_array); |
919 | 919 | $operator = $airline_array[0]['icao'].substr($operator,2); |
920 | - } |
|
921 | - } |
|
920 | + } |
|
921 | + } |
|
922 | 922 | |
923 | 923 | $operator_correct = $data[3]; |
924 | 924 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
925 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
926 | - if (count($airline_array) > 0) { |
|
927 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
928 | - } |
|
929 | - } |
|
925 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
926 | + if (count($airline_array) > 0) { |
|
927 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
928 | + } |
|
929 | + } |
|
930 | 930 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
931 | 931 | try { |
932 | 932 | $sth = $Connection->db->prepare($query); |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | //$Connection->db->commit(); |
941 | 941 | } |
942 | 942 | return ''; |
943 | - } |
|
943 | + } |
|
944 | 944 | |
945 | 945 | public static function translation_fam() { |
946 | 946 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -950,10 +950,10 @@ discard block |
||
950 | 950 | try { |
951 | 951 | $Connection = new Connection(); |
952 | 952 | $sth = $Connection->db->prepare($query); |
953 | - $sth->execute(array(':source' => 'website_fam')); |
|
954 | - } catch(PDOException $e) { |
|
955 | - return "error : ".$e->getMessage(); |
|
956 | - } |
|
953 | + $sth->execute(array(':source' => 'website_fam')); |
|
954 | + } catch(PDOException $e) { |
|
955 | + return "error : ".$e->getMessage(); |
|
956 | + } |
|
957 | 957 | |
958 | 958 | |
959 | 959 | //update_db::unzip($out_file); |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | //$Connection->db->commit(); |
983 | 983 | } |
984 | 984 | return ''; |
985 | - } |
|
985 | + } |
|
986 | 986 | |
987 | 987 | /* |
988 | 988 | * This function use FAA public data. |
@@ -994,19 +994,19 @@ discard block |
||
994 | 994 | try { |
995 | 995 | $Connection = new Connection(); |
996 | 996 | $sth = $Connection->db->prepare($query); |
997 | - $sth->execute(array(':source' => 'website_faa')); |
|
998 | - } catch(PDOException $e) { |
|
999 | - return "error : ".$e->getMessage(); |
|
1000 | - } |
|
997 | + $sth->execute(array(':source' => 'website_faa')); |
|
998 | + } catch(PDOException $e) { |
|
999 | + return "error : ".$e->getMessage(); |
|
1000 | + } |
|
1001 | 1001 | |
1002 | 1002 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
1003 | 1003 | try { |
1004 | 1004 | $Connection = new Connection(); |
1005 | 1005 | $sth = $Connection->db->prepare($query); |
1006 | - $sth->execute(array(':source' => 'website_faa')); |
|
1007 | - } catch(PDOException $e) { |
|
1008 | - return "error : ".$e->getMessage(); |
|
1009 | - } |
|
1006 | + $sth->execute(array(':source' => 'website_faa')); |
|
1007 | + } catch(PDOException $e) { |
|
1008 | + return "error : ".$e->getMessage(); |
|
1009 | + } |
|
1010 | 1010 | |
1011 | 1011 | $delimiter = ","; |
1012 | 1012 | $mfr = array(); |
@@ -1082,17 +1082,17 @@ discard block |
||
1082 | 1082 | } |
1083 | 1083 | print_r($mfr); |
1084 | 1084 | return ''; |
1085 | - } |
|
1085 | + } |
|
1086 | 1086 | public static function modes_fam() { |
1087 | 1087 | global $tmp_dir, $globalTransaction; |
1088 | 1088 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; |
1089 | 1089 | try { |
1090 | 1090 | $Connection = new Connection(); |
1091 | 1091 | $sth = $Connection->db->prepare($query); |
1092 | - $sth->execute(array(':source' => 'website_fam')); |
|
1093 | - } catch(PDOException $e) { |
|
1094 | - return "error : ".$e->getMessage(); |
|
1095 | - } |
|
1092 | + $sth->execute(array(':source' => 'website_fam')); |
|
1093 | + } catch(PDOException $e) { |
|
1094 | + return "error : ".$e->getMessage(); |
|
1095 | + } |
|
1096 | 1096 | |
1097 | 1097 | |
1098 | 1098 | //update_db::unzip($out_file); |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | if ($globalTransaction) $Connection->db->commit(); |
1123 | 1123 | } |
1124 | 1124 | return ''; |
1125 | - } |
|
1125 | + } |
|
1126 | 1126 | |
1127 | 1127 | public static function owner_fam() { |
1128 | 1128 | global $tmp_dir, $globalTransaction; |
@@ -1130,10 +1130,10 @@ discard block |
||
1130 | 1130 | try { |
1131 | 1131 | $Connection = new Connection(); |
1132 | 1132 | $sth = $Connection->db->prepare($query); |
1133 | - $sth->execute(array(':source' => 'website_fam')); |
|
1134 | - } catch(PDOException $e) { |
|
1135 | - return "error : ".$e->getMessage(); |
|
1136 | - } |
|
1133 | + $sth->execute(array(':source' => 'website_fam')); |
|
1134 | + } catch(PDOException $e) { |
|
1135 | + return "error : ".$e->getMessage(); |
|
1136 | + } |
|
1137 | 1137 | |
1138 | 1138 | $delimiter = "\t"; |
1139 | 1139 | $Connection = new Connection(); |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | if ($globalTransaction) $Connection->db->commit(); |
1160 | 1160 | } |
1161 | 1161 | return ''; |
1162 | - } |
|
1162 | + } |
|
1163 | 1163 | |
1164 | 1164 | public static function routes_fam() { |
1165 | 1165 | global $tmp_dir, $globalTransaction; |
@@ -1167,10 +1167,10 @@ discard block |
||
1167 | 1167 | try { |
1168 | 1168 | $Connection = new Connection(); |
1169 | 1169 | $sth = $Connection->db->prepare($query); |
1170 | - $sth->execute(array(':source' => 'website_fam')); |
|
1171 | - } catch(PDOException $e) { |
|
1172 | - return "error : ".$e->getMessage(); |
|
1173 | - } |
|
1170 | + $sth->execute(array(':source' => 'website_fam')); |
|
1171 | + } catch(PDOException $e) { |
|
1172 | + return "error : ".$e->getMessage(); |
|
1173 | + } |
|
1174 | 1174 | |
1175 | 1175 | |
1176 | 1176 | //update_db::unzip($out_file); |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | if ($globalTransaction) $Connection->db->commit(); |
1200 | 1200 | } |
1201 | 1201 | return ''; |
1202 | - } |
|
1202 | + } |
|
1203 | 1203 | |
1204 | 1204 | public static function marine_identity_fam() { |
1205 | 1205 | global $tmp_dir, $globalTransaction; |
@@ -1207,10 +1207,10 @@ discard block |
||
1207 | 1207 | try { |
1208 | 1208 | $Connection = new Connection(); |
1209 | 1209 | $sth = $Connection->db->prepare($query); |
1210 | - $sth->execute(); |
|
1211 | - } catch(PDOException $e) { |
|
1212 | - return "error : ".$e->getMessage(); |
|
1213 | - } |
|
1210 | + $sth->execute(); |
|
1211 | + } catch(PDOException $e) { |
|
1212 | + return "error : ".$e->getMessage(); |
|
1213 | + } |
|
1214 | 1214 | |
1215 | 1215 | |
1216 | 1216 | //update_db::unzip($out_file); |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | if ($globalTransaction) $Connection->db->commit(); |
1240 | 1240 | } |
1241 | 1241 | return ''; |
1242 | - } |
|
1242 | + } |
|
1243 | 1243 | |
1244 | 1244 | public static function banned_fam() { |
1245 | 1245 | global $tmp_dir, $globalTransaction; |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | if ($globalTransaction) $Connection->db->commit(); |
1274 | 1274 | } |
1275 | 1275 | return ''; |
1276 | - } |
|
1276 | + } |
|
1277 | 1277 | |
1278 | 1278 | public static function tle($filename,$tletype) { |
1279 | 1279 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1284,10 +1284,10 @@ discard block |
||
1284 | 1284 | try { |
1285 | 1285 | $Connection = new Connection(); |
1286 | 1286 | $sth = $Connection->db->prepare($query); |
1287 | - $sth->execute(array(':source' => $filename)); |
|
1288 | - } catch(PDOException $e) { |
|
1289 | - return "error : ".$e->getMessage(); |
|
1290 | - } |
|
1287 | + $sth->execute(array(':source' => $filename)); |
|
1288 | + } catch(PDOException $e) { |
|
1289 | + return "error : ".$e->getMessage(); |
|
1290 | + } |
|
1291 | 1291 | |
1292 | 1292 | $Connection = new Connection(); |
1293 | 1293 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1322,54 +1322,54 @@ discard block |
||
1322 | 1322 | //$Connection->db->commit(); |
1323 | 1323 | } |
1324 | 1324 | return ''; |
1325 | - } |
|
1325 | + } |
|
1326 | 1326 | |
1327 | 1327 | /** |
1328 | - * Convert a HTML table to an array |
|
1329 | - * @param String $data HTML page |
|
1330 | - * @return Array array of the tables in HTML page |
|
1331 | - */ |
|
1332 | - private static function table2array($data) { |
|
1333 | - $html = str_get_html($data); |
|
1334 | - $tabledata=array(); |
|
1335 | - foreach($html->find('tr') as $element) |
|
1336 | - { |
|
1337 | - $td = array(); |
|
1338 | - foreach( $element->find('th') as $row) |
|
1339 | - { |
|
1340 | - $td [] = trim($row->plaintext); |
|
1341 | - } |
|
1342 | - $td=array_filter($td); |
|
1343 | - $tabledata[] = $td; |
|
1344 | - |
|
1345 | - $td = array(); |
|
1346 | - $tdi = array(); |
|
1347 | - foreach( $element->find('td') as $row) |
|
1348 | - { |
|
1349 | - $td [] = trim($row->plaintext); |
|
1350 | - $tdi [] = trim($row->innertext); |
|
1351 | - } |
|
1352 | - $td=array_filter($td); |
|
1353 | - $tdi=array_filter($tdi); |
|
1354 | - // $tabledata[]=array_merge($td,$tdi); |
|
1355 | - $tabledata[]=$td; |
|
1356 | - } |
|
1357 | - return(array_filter($tabledata)); |
|
1358 | - } |
|
1359 | - |
|
1360 | - /** |
|
1361 | - * Get data from form result |
|
1362 | - * @param String $url form URL |
|
1363 | - * @return String the result |
|
1364 | - */ |
|
1365 | - private static function getData($url) { |
|
1366 | - $ch = curl_init(); |
|
1367 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
1368 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1369 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1370 | - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
1371 | - return curl_exec($ch); |
|
1372 | - } |
|
1328 | + * Convert a HTML table to an array |
|
1329 | + * @param String $data HTML page |
|
1330 | + * @return Array array of the tables in HTML page |
|
1331 | + */ |
|
1332 | + private static function table2array($data) { |
|
1333 | + $html = str_get_html($data); |
|
1334 | + $tabledata=array(); |
|
1335 | + foreach($html->find('tr') as $element) |
|
1336 | + { |
|
1337 | + $td = array(); |
|
1338 | + foreach( $element->find('th') as $row) |
|
1339 | + { |
|
1340 | + $td [] = trim($row->plaintext); |
|
1341 | + } |
|
1342 | + $td=array_filter($td); |
|
1343 | + $tabledata[] = $td; |
|
1344 | + |
|
1345 | + $td = array(); |
|
1346 | + $tdi = array(); |
|
1347 | + foreach( $element->find('td') as $row) |
|
1348 | + { |
|
1349 | + $td [] = trim($row->plaintext); |
|
1350 | + $tdi [] = trim($row->innertext); |
|
1351 | + } |
|
1352 | + $td=array_filter($td); |
|
1353 | + $tdi=array_filter($tdi); |
|
1354 | + // $tabledata[]=array_merge($td,$tdi); |
|
1355 | + $tabledata[]=$td; |
|
1356 | + } |
|
1357 | + return(array_filter($tabledata)); |
|
1358 | + } |
|
1359 | + |
|
1360 | + /** |
|
1361 | + * Get data from form result |
|
1362 | + * @param String $url form URL |
|
1363 | + * @return String the result |
|
1364 | + */ |
|
1365 | + private static function getData($url) { |
|
1366 | + $ch = curl_init(); |
|
1367 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1368 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1369 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1370 | + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
1371 | + return curl_exec($ch); |
|
1372 | + } |
|
1373 | 1373 | /* |
1374 | 1374 | public static function waypoints() { |
1375 | 1375 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | if ($globalTransaction) $Connection->db->commit(); |
1453 | 1453 | } |
1454 | 1454 | return ''; |
1455 | - } |
|
1455 | + } |
|
1456 | 1456 | |
1457 | 1457 | public static function ivao_airlines($filename) { |
1458 | 1458 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1462,10 +1462,10 @@ discard block |
||
1462 | 1462 | try { |
1463 | 1463 | $Connection = new Connection(); |
1464 | 1464 | $sth = $Connection->db->prepare($query); |
1465 | - $sth->execute(); |
|
1466 | - } catch(PDOException $e) { |
|
1467 | - return "error : ".$e->getMessage(); |
|
1468 | - } |
|
1465 | + $sth->execute(); |
|
1466 | + } catch(PDOException $e) { |
|
1467 | + return "error : ".$e->getMessage(); |
|
1468 | + } |
|
1469 | 1469 | |
1470 | 1470 | $header = NULL; |
1471 | 1471 | $delimiter = ':'; |
@@ -1489,7 +1489,7 @@ discard block |
||
1489 | 1489 | if ($globalTransaction) $Connection->db->commit(); |
1490 | 1490 | } |
1491 | 1491 | return ''; |
1492 | - } |
|
1492 | + } |
|
1493 | 1493 | |
1494 | 1494 | public static function update_airspace() { |
1495 | 1495 | global $tmp_dir, $globalDBdriver; |
@@ -1499,11 +1499,11 @@ discard block |
||
1499 | 1499 | $query = 'DROP TABLE airspace'; |
1500 | 1500 | try { |
1501 | 1501 | $sth = $Connection->db->prepare($query); |
1502 | - $sth->execute(); |
|
1503 | - } catch(PDOException $e) { |
|
1502 | + $sth->execute(); |
|
1503 | + } catch(PDOException $e) { |
|
1504 | 1504 | return "error : ".$e->getMessage(); |
1505 | - } |
|
1506 | - } |
|
1505 | + } |
|
1506 | + } |
|
1507 | 1507 | |
1508 | 1508 | |
1509 | 1509 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1558,10 +1558,10 @@ discard block |
||
1558 | 1558 | $query = 'DROP TABLE countries'; |
1559 | 1559 | try { |
1560 | 1560 | $sth = $Connection->db->prepare($query); |
1561 | - $sth->execute(); |
|
1562 | - } catch(PDOException $e) { |
|
1563 | - echo "error : ".$e->getMessage(); |
|
1564 | - } |
|
1561 | + $sth->execute(); |
|
1562 | + } catch(PDOException $e) { |
|
1563 | + echo "error : ".$e->getMessage(); |
|
1564 | + } |
|
1565 | 1565 | } |
1566 | 1566 | if ($globalDBdriver == 'mysql') { |
1567 | 1567 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2090,11 +2090,11 @@ discard block |
||
2090 | 2090 | $query = 'DROP TABLE airspace'; |
2091 | 2091 | try { |
2092 | 2092 | $sth = $Connection->db->prepare($query); |
2093 | - $sth->execute(); |
|
2094 | - } catch(PDOException $e) { |
|
2093 | + $sth->execute(); |
|
2094 | + } catch(PDOException $e) { |
|
2095 | 2095 | return "error : ".$e->getMessage(); |
2096 | - } |
|
2097 | - } |
|
2096 | + } |
|
2097 | + } |
|
2098 | 2098 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2099 | 2099 | update_db::insert_airspace_version($airspace_md5); |
2100 | 2100 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -2251,12 +2251,12 @@ discard block |
||
2251 | 2251 | echo $data; |
2252 | 2252 | */ |
2253 | 2253 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2254 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2255 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2256 | - $result = fread($fh,100000000); |
|
2257 | - //echo $result; |
|
2258 | - //var_dump(str_get_html($result)); |
|
2259 | - //print_r(self::table2array($result)); |
|
2254 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2255 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2256 | + $result = fread($fh,100000000); |
|
2257 | + //echo $result; |
|
2258 | + //var_dump(str_get_html($result)); |
|
2259 | + //print_r(self::table2array($result)); |
|
2260 | 2260 | } |
2261 | 2261 | |
2262 | 2262 | } |
@@ -2270,10 +2270,10 @@ discard block |
||
2270 | 2270 | try { |
2271 | 2271 | $Connection = new Connection(); |
2272 | 2272 | $sth = $Connection->db->prepare($query); |
2273 | - $sth->execute(); |
|
2274 | - } catch(PDOException $e) { |
|
2275 | - return "error : ".$e->getMessage(); |
|
2276 | - } |
|
2273 | + $sth->execute(); |
|
2274 | + } catch(PDOException $e) { |
|
2275 | + return "error : ".$e->getMessage(); |
|
2276 | + } |
|
2277 | 2277 | |
2278 | 2278 | $error = ''; |
2279 | 2279 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2329,8 +2329,8 @@ discard block |
||
2329 | 2329 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
2330 | 2330 | $data['permanent'] = 0; |
2331 | 2331 | } else { |
2332 | - $data['date_end'] = NULL; |
|
2333 | - $data['permanent'] = 1; |
|
2332 | + $data['date_end'] = NULL; |
|
2333 | + $data['permanent'] = 1; |
|
2334 | 2334 | } |
2335 | 2335 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2336 | 2336 | $NOTAM = new NOTAM(); |
@@ -2404,13 +2404,13 @@ discard block |
||
2404 | 2404 | try { |
2405 | 2405 | $Connection = new Connection(); |
2406 | 2406 | $sth = $Connection->db->prepare($query); |
2407 | - $sth->execute(); |
|
2408 | - } catch(PDOException $e) { |
|
2409 | - return "error : ".$e->getMessage(); |
|
2410 | - } |
|
2411 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2412 | - if ($row['nb'] > 0) return false; |
|
2413 | - else return true; |
|
2407 | + $sth->execute(); |
|
2408 | + } catch(PDOException $e) { |
|
2409 | + return "error : ".$e->getMessage(); |
|
2410 | + } |
|
2411 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2412 | + if ($row['nb'] > 0) return false; |
|
2413 | + else return true; |
|
2414 | 2414 | } |
2415 | 2415 | |
2416 | 2416 | public static function insert_last_update() { |
@@ -2419,10 +2419,10 @@ discard block |
||
2419 | 2419 | try { |
2420 | 2420 | $Connection = new Connection(); |
2421 | 2421 | $sth = $Connection->db->prepare($query); |
2422 | - $sth->execute(); |
|
2423 | - } catch(PDOException $e) { |
|
2424 | - return "error : ".$e->getMessage(); |
|
2425 | - } |
|
2422 | + $sth->execute(); |
|
2423 | + } catch(PDOException $e) { |
|
2424 | + return "error : ".$e->getMessage(); |
|
2425 | + } |
|
2426 | 2426 | } |
2427 | 2427 | |
2428 | 2428 | public static function check_airspace_version($version) { |
@@ -2430,13 +2430,13 @@ discard block |
||
2430 | 2430 | try { |
2431 | 2431 | $Connection = new Connection(); |
2432 | 2432 | $sth = $Connection->db->prepare($query); |
2433 | - $sth->execute(array(':version' => $version)); |
|
2434 | - } catch(PDOException $e) { |
|
2435 | - return "error : ".$e->getMessage(); |
|
2436 | - } |
|
2437 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2438 | - if ($row['nb'] > 0) return true; |
|
2439 | - else return false; |
|
2433 | + $sth->execute(array(':version' => $version)); |
|
2434 | + } catch(PDOException $e) { |
|
2435 | + return "error : ".$e->getMessage(); |
|
2436 | + } |
|
2437 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2438 | + if ($row['nb'] > 0) return true; |
|
2439 | + else return false; |
|
2440 | 2440 | } |
2441 | 2441 | |
2442 | 2442 | public static function check_marine_identity_version($version) { |
@@ -2444,13 +2444,13 @@ discard block |
||
2444 | 2444 | try { |
2445 | 2445 | $Connection = new Connection(); |
2446 | 2446 | $sth = $Connection->db->prepare($query); |
2447 | - $sth->execute(array(':version' => $version)); |
|
2448 | - } catch(PDOException $e) { |
|
2449 | - return "error : ".$e->getMessage(); |
|
2450 | - } |
|
2451 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2452 | - if ($row['nb'] > 0) return true; |
|
2453 | - else return false; |
|
2447 | + $sth->execute(array(':version' => $version)); |
|
2448 | + } catch(PDOException $e) { |
|
2449 | + return "error : ".$e->getMessage(); |
|
2450 | + } |
|
2451 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2452 | + if ($row['nb'] > 0) return true; |
|
2453 | + else return false; |
|
2454 | 2454 | } |
2455 | 2455 | |
2456 | 2456 | |
@@ -2460,10 +2460,10 @@ discard block |
||
2460 | 2460 | try { |
2461 | 2461 | $Connection = new Connection(); |
2462 | 2462 | $sth = $Connection->db->prepare($query); |
2463 | - $sth->execute(array(':version' => $version)); |
|
2464 | - } catch(PDOException $e) { |
|
2465 | - return "error : ".$e->getMessage(); |
|
2466 | - } |
|
2463 | + $sth->execute(array(':version' => $version)); |
|
2464 | + } catch(PDOException $e) { |
|
2465 | + return "error : ".$e->getMessage(); |
|
2466 | + } |
|
2467 | 2467 | } |
2468 | 2468 | |
2469 | 2469 | public static function insert_marine_identity_version($version) { |
@@ -2472,10 +2472,10 @@ discard block |
||
2472 | 2472 | try { |
2473 | 2473 | $Connection = new Connection(); |
2474 | 2474 | $sth = $Connection->db->prepare($query); |
2475 | - $sth->execute(array(':version' => $version)); |
|
2476 | - } catch(PDOException $e) { |
|
2477 | - return "error : ".$e->getMessage(); |
|
2478 | - } |
|
2475 | + $sth->execute(array(':version' => $version)); |
|
2476 | + } catch(PDOException $e) { |
|
2477 | + return "error : ".$e->getMessage(); |
|
2478 | + } |
|
2479 | 2479 | } |
2480 | 2480 | |
2481 | 2481 | public static function check_last_notam_update() { |
@@ -2488,13 +2488,13 @@ discard block |
||
2488 | 2488 | try { |
2489 | 2489 | $Connection = new Connection(); |
2490 | 2490 | $sth = $Connection->db->prepare($query); |
2491 | - $sth->execute(); |
|
2492 | - } catch(PDOException $e) { |
|
2493 | - return "error : ".$e->getMessage(); |
|
2494 | - } |
|
2495 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2496 | - if ($row['nb'] > 0) return false; |
|
2497 | - else return true; |
|
2491 | + $sth->execute(); |
|
2492 | + } catch(PDOException $e) { |
|
2493 | + return "error : ".$e->getMessage(); |
|
2494 | + } |
|
2495 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2496 | + if ($row['nb'] > 0) return false; |
|
2497 | + else return true; |
|
2498 | 2498 | } |
2499 | 2499 | |
2500 | 2500 | public static function insert_last_notam_update() { |
@@ -2503,10 +2503,10 @@ discard block |
||
2503 | 2503 | try { |
2504 | 2504 | $Connection = new Connection(); |
2505 | 2505 | $sth = $Connection->db->prepare($query); |
2506 | - $sth->execute(); |
|
2507 | - } catch(PDOException $e) { |
|
2508 | - return "error : ".$e->getMessage(); |
|
2509 | - } |
|
2506 | + $sth->execute(); |
|
2507 | + } catch(PDOException $e) { |
|
2508 | + return "error : ".$e->getMessage(); |
|
2509 | + } |
|
2510 | 2510 | } |
2511 | 2511 | public static function check_last_airspace_update() { |
2512 | 2512 | global $globalDBdriver; |
@@ -2518,13 +2518,13 @@ discard block |
||
2518 | 2518 | try { |
2519 | 2519 | $Connection = new Connection(); |
2520 | 2520 | $sth = $Connection->db->prepare($query); |
2521 | - $sth->execute(); |
|
2522 | - } catch(PDOException $e) { |
|
2523 | - return "error : ".$e->getMessage(); |
|
2524 | - } |
|
2525 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2526 | - if ($row['nb'] > 0) return false; |
|
2527 | - else return true; |
|
2521 | + $sth->execute(); |
|
2522 | + } catch(PDOException $e) { |
|
2523 | + return "error : ".$e->getMessage(); |
|
2524 | + } |
|
2525 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2526 | + if ($row['nb'] > 0) return false; |
|
2527 | + else return true; |
|
2528 | 2528 | } |
2529 | 2529 | |
2530 | 2530 | public static function insert_last_airspace_update() { |
@@ -2533,10 +2533,10 @@ discard block |
||
2533 | 2533 | try { |
2534 | 2534 | $Connection = new Connection(); |
2535 | 2535 | $sth = $Connection->db->prepare($query); |
2536 | - $sth->execute(); |
|
2537 | - } catch(PDOException $e) { |
|
2538 | - return "error : ".$e->getMessage(); |
|
2539 | - } |
|
2536 | + $sth->execute(); |
|
2537 | + } catch(PDOException $e) { |
|
2538 | + return "error : ".$e->getMessage(); |
|
2539 | + } |
|
2540 | 2540 | } |
2541 | 2541 | |
2542 | 2542 | public static function check_last_owner_update() { |
@@ -2549,13 +2549,13 @@ discard block |
||
2549 | 2549 | try { |
2550 | 2550 | $Connection = new Connection(); |
2551 | 2551 | $sth = $Connection->db->prepare($query); |
2552 | - $sth->execute(); |
|
2553 | - } catch(PDOException $e) { |
|
2554 | - return "error : ".$e->getMessage(); |
|
2555 | - } |
|
2556 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2557 | - if ($row['nb'] > 0) return false; |
|
2558 | - else return true; |
|
2552 | + $sth->execute(); |
|
2553 | + } catch(PDOException $e) { |
|
2554 | + return "error : ".$e->getMessage(); |
|
2555 | + } |
|
2556 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2557 | + if ($row['nb'] > 0) return false; |
|
2558 | + else return true; |
|
2559 | 2559 | } |
2560 | 2560 | |
2561 | 2561 | public static function insert_last_owner_update() { |
@@ -2564,10 +2564,10 @@ discard block |
||
2564 | 2564 | try { |
2565 | 2565 | $Connection = new Connection(); |
2566 | 2566 | $sth = $Connection->db->prepare($query); |
2567 | - $sth->execute(); |
|
2568 | - } catch(PDOException $e) { |
|
2569 | - return "error : ".$e->getMessage(); |
|
2570 | - } |
|
2567 | + $sth->execute(); |
|
2568 | + } catch(PDOException $e) { |
|
2569 | + return "error : ".$e->getMessage(); |
|
2570 | + } |
|
2571 | 2571 | } |
2572 | 2572 | public static function check_last_schedules_update() { |
2573 | 2573 | global $globalDBdriver; |
@@ -2579,13 +2579,13 @@ discard block |
||
2579 | 2579 | try { |
2580 | 2580 | $Connection = new Connection(); |
2581 | 2581 | $sth = $Connection->db->prepare($query); |
2582 | - $sth->execute(); |
|
2583 | - } catch(PDOException $e) { |
|
2584 | - return "error : ".$e->getMessage(); |
|
2585 | - } |
|
2586 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2587 | - if ($row['nb'] > 0) return false; |
|
2588 | - else return true; |
|
2582 | + $sth->execute(); |
|
2583 | + } catch(PDOException $e) { |
|
2584 | + return "error : ".$e->getMessage(); |
|
2585 | + } |
|
2586 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2587 | + if ($row['nb'] > 0) return false; |
|
2588 | + else return true; |
|
2589 | 2589 | } |
2590 | 2590 | |
2591 | 2591 | public static function insert_last_schedules_update() { |
@@ -2594,10 +2594,10 @@ discard block |
||
2594 | 2594 | try { |
2595 | 2595 | $Connection = new Connection(); |
2596 | 2596 | $sth = $Connection->db->prepare($query); |
2597 | - $sth->execute(); |
|
2598 | - } catch(PDOException $e) { |
|
2599 | - return "error : ".$e->getMessage(); |
|
2600 | - } |
|
2597 | + $sth->execute(); |
|
2598 | + } catch(PDOException $e) { |
|
2599 | + return "error : ".$e->getMessage(); |
|
2600 | + } |
|
2601 | 2601 | } |
2602 | 2602 | public static function check_last_tle_update() { |
2603 | 2603 | global $globalDBdriver; |
@@ -2609,13 +2609,13 @@ discard block |
||
2609 | 2609 | try { |
2610 | 2610 | $Connection = new Connection(); |
2611 | 2611 | $sth = $Connection->db->prepare($query); |
2612 | - $sth->execute(); |
|
2613 | - } catch(PDOException $e) { |
|
2614 | - return "error : ".$e->getMessage(); |
|
2615 | - } |
|
2616 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2617 | - if ($row['nb'] > 0) return false; |
|
2618 | - else return true; |
|
2612 | + $sth->execute(); |
|
2613 | + } catch(PDOException $e) { |
|
2614 | + return "error : ".$e->getMessage(); |
|
2615 | + } |
|
2616 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2617 | + if ($row['nb'] > 0) return false; |
|
2618 | + else return true; |
|
2619 | 2619 | } |
2620 | 2620 | |
2621 | 2621 | public static function insert_last_tle_update() { |
@@ -2624,10 +2624,10 @@ discard block |
||
2624 | 2624 | try { |
2625 | 2625 | $Connection = new Connection(); |
2626 | 2626 | $sth = $Connection->db->prepare($query); |
2627 | - $sth->execute(); |
|
2628 | - } catch(PDOException $e) { |
|
2629 | - return "error : ".$e->getMessage(); |
|
2630 | - } |
|
2627 | + $sth->execute(); |
|
2628 | + } catch(PDOException $e) { |
|
2629 | + return "error : ".$e->getMessage(); |
|
2630 | + } |
|
2631 | 2631 | } |
2632 | 2632 | public static function check_last_marine_identity_update() { |
2633 | 2633 | global $globalDBdriver; |
@@ -2639,13 +2639,13 @@ discard block |
||
2639 | 2639 | try { |
2640 | 2640 | $Connection = new Connection(); |
2641 | 2641 | $sth = $Connection->db->prepare($query); |
2642 | - $sth->execute(); |
|
2643 | - } catch(PDOException $e) { |
|
2644 | - return "error : ".$e->getMessage(); |
|
2645 | - } |
|
2646 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2647 | - if ($row['nb'] > 0) return false; |
|
2648 | - else return true; |
|
2642 | + $sth->execute(); |
|
2643 | + } catch(PDOException $e) { |
|
2644 | + return "error : ".$e->getMessage(); |
|
2645 | + } |
|
2646 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2647 | + if ($row['nb'] > 0) return false; |
|
2648 | + else return true; |
|
2649 | 2649 | } |
2650 | 2650 | |
2651 | 2651 | public static function insert_last_marine_identity_update() { |
@@ -2654,10 +2654,10 @@ discard block |
||
2654 | 2654 | try { |
2655 | 2655 | $Connection = new Connection(); |
2656 | 2656 | $sth = $Connection->db->prepare($query); |
2657 | - $sth->execute(); |
|
2658 | - } catch(PDOException $e) { |
|
2659 | - return "error : ".$e->getMessage(); |
|
2660 | - } |
|
2657 | + $sth->execute(); |
|
2658 | + } catch(PDOException $e) { |
|
2659 | + return "error : ".$e->getMessage(); |
|
2660 | + } |
|
2661 | 2661 | } |
2662 | 2662 | public static function delete_duplicatemodes() { |
2663 | 2663 | global $globalDBdriver; |
@@ -2669,10 +2669,10 @@ discard block |
||
2669 | 2669 | try { |
2670 | 2670 | $Connection = new Connection(); |
2671 | 2671 | $sth = $Connection->db->prepare($query); |
2672 | - $sth->execute(); |
|
2673 | - } catch(PDOException $e) { |
|
2674 | - return "error : ".$e->getMessage(); |
|
2675 | - } |
|
2672 | + $sth->execute(); |
|
2673 | + } catch(PDOException $e) { |
|
2674 | + return "error : ".$e->getMessage(); |
|
2675 | + } |
|
2676 | 2676 | } |
2677 | 2677 | public static function delete_duplicateowner() { |
2678 | 2678 | global $globalDBdriver; |
@@ -2684,10 +2684,10 @@ discard block |
||
2684 | 2684 | try { |
2685 | 2685 | $Connection = new Connection(); |
2686 | 2686 | $sth = $Connection->db->prepare($query); |
2687 | - $sth->execute(); |
|
2688 | - } catch(PDOException $e) { |
|
2689 | - return "error : ".$e->getMessage(); |
|
2690 | - } |
|
2687 | + $sth->execute(); |
|
2688 | + } catch(PDOException $e) { |
|
2689 | + return "error : ".$e->getMessage(); |
|
2690 | + } |
|
2691 | 2691 | } |
2692 | 2692 | |
2693 | 2693 | public static function update_all() { |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | $this->db = $Connection->db; |
9 | 9 | } |
10 | 10 | |
11 | - /** |
|
12 | - * Get SQL query part for filter used |
|
13 | - * @param Array $filter the filter |
|
14 | - * @return Array the SQL part |
|
15 | - */ |
|
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
11 | + /** |
|
12 | + * Get SQL query part for filter used |
|
13 | + * @param Array $filter the filter |
|
14 | + * @return Array the SQL part |
|
15 | + */ |
|
16 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -30,88 +30,88 @@ discard block |
||
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | 32 | foreach($filters as $flt) { |
33 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
33 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | - if (isset($flt['source'])) { |
|
35 | + if (isset($flt['source'])) { |
|
36 | 36 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
37 | - } else { |
|
37 | + } else { |
|
38 | 38 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
39 | - } |
|
39 | + } |
|
40 | + } |
|
40 | 41 | } |
41 | - } |
|
42 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
42 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
47 | 47 | } |
48 | - } |
|
49 | - if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
48 | + } |
|
49 | + if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
52 | 52 | } else { |
53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | + } |
|
54 | 55 | } |
55 | - } |
|
56 | - if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
56 | + if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
57 | 57 | if (isset($flt['source'])) { |
58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
59 | 59 | } else { |
60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
61 | + } |
|
61 | 62 | } |
62 | - } |
|
63 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
63 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
64 | 64 | if (isset($flt['source'])) { |
65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
66 | + } |
|
66 | 67 | } |
67 | - } |
|
68 | 68 | } |
69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
70 | - if ($filter['airlines'][0] != '') { |
|
70 | + if ($filter['airlines'][0] != '') { |
|
71 | 71 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
72 | - } |
|
72 | + } |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
76 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
76 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
77 | 77 | } |
78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
80 | 80 | } |
81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
82 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
83 | 83 | } |
84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
85 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
85 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
86 | 86 | } |
87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
88 | 88 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
89 | 89 | } |
90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
91 | - $filter_query_date = ''; |
|
91 | + $filter_query_date = ''; |
|
92 | 92 | |
93 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
93 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
94 | 94 | if ($globalDBdriver == 'mysql') { |
95 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
95 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
96 | 96 | } else { |
97 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
97 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
98 | + } |
|
98 | 99 | } |
99 | - } |
|
100 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
100 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
101 | 101 | if ($globalDBdriver == 'mysql') { |
102 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
102 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
103 | 103 | } else { |
104 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
104 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
105 | 105 | } |
106 | - } |
|
107 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
106 | + } |
|
107 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
108 | 108 | if ($globalDBdriver == 'mysql') { |
109 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
109 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
110 | 110 | } else { |
111 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
111 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
112 | + } |
|
112 | 113 | } |
113 | - } |
|
114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
115 | 115 | } |
116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
122 | 122 | return $filter_query; |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | 125 | // Spotter_archive |
126 | 126 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -152,44 +152,44 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - /** |
|
156 | - * Gets all the spotter information based on a particular callsign |
|
157 | - * |
|
158 | - * @return Array the spotter information |
|
159 | - * |
|
160 | - */ |
|
161 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
162 | - { |
|
155 | + /** |
|
156 | + * Gets all the spotter information based on a particular callsign |
|
157 | + * |
|
158 | + * @return Array the spotter information |
|
159 | + * |
|
160 | + */ |
|
161 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
162 | + { |
|
163 | 163 | $Spotter = new Spotter($this->db); |
164 | - date_default_timezone_set('UTC'); |
|
164 | + date_default_timezone_set('UTC'); |
|
165 | 165 | |
166 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
167 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
168 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
166 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
167 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
168 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
169 | 169 | |
170 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
170 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
171 | 171 | |
172 | - return $spotter_array; |
|
173 | - } |
|
172 | + return $spotter_array; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | - /** |
|
177 | - * Gets last the spotter information based on a particular id |
|
178 | - * |
|
179 | - * @return Array the spotter information |
|
180 | - * |
|
181 | - */ |
|
182 | - public function getLastArchiveSpotterDataById($id) |
|
183 | - { |
|
184 | - $Spotter = new Spotter($this->db); |
|
185 | - date_default_timezone_set('UTC'); |
|
186 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
187 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
188 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
189 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
176 | + /** |
|
177 | + * Gets last the spotter information based on a particular id |
|
178 | + * |
|
179 | + * @return Array the spotter information |
|
180 | + * |
|
181 | + */ |
|
182 | + public function getLastArchiveSpotterDataById($id) |
|
183 | + { |
|
184 | + $Spotter = new Spotter($this->db); |
|
185 | + date_default_timezone_set('UTC'); |
|
186 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
187 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
188 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
189 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
190 | 190 | |
191 | 191 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
192 | - /* |
|
192 | + /* |
|
193 | 193 | try { |
194 | 194 | $Connection = new Connection(); |
195 | 195 | $sth = Connection->$db->prepare($query); |
@@ -199,232 +199,232 @@ discard block |
||
199 | 199 | } |
200 | 200 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
201 | 201 | */ |
202 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
203 | - |
|
204 | - return $spotter_array; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Gets all the spotter information based on a particular id |
|
209 | - * |
|
210 | - * @return Array the spotter information |
|
211 | - * |
|
212 | - */ |
|
213 | - public function getAllArchiveSpotterDataById($id) |
|
202 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
203 | + |
|
204 | + return $spotter_array; |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * Gets all the spotter information based on a particular id |
|
209 | + * |
|
210 | + * @return Array the spotter information |
|
211 | + * |
|
212 | + */ |
|
213 | + public function getAllArchiveSpotterDataById($id) |
|
214 | 214 | { |
215 | - date_default_timezone_set('UTC'); |
|
216 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
217 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
215 | + date_default_timezone_set('UTC'); |
|
216 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
217 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
218 | 218 | |
219 | 219 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
220 | 220 | |
221 | - try { |
|
222 | - $sth = $this->db->prepare($query); |
|
223 | - $sth->execute(array(':id' => $id)); |
|
224 | - } catch(PDOException $e) { |
|
225 | - echo $e->getMessage(); |
|
226 | - die; |
|
227 | - } |
|
228 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
229 | - |
|
230 | - return $spotter_array; |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Gets coordinate & time spotter information based on a particular id |
|
235 | - * |
|
236 | - * @return Array the spotter information |
|
237 | - * |
|
238 | - */ |
|
239 | - public function getCoordArchiveSpotterDataById($id) |
|
240 | - { |
|
241 | - date_default_timezone_set('UTC'); |
|
242 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
243 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
221 | + try { |
|
222 | + $sth = $this->db->prepare($query); |
|
223 | + $sth->execute(array(':id' => $id)); |
|
224 | + } catch(PDOException $e) { |
|
225 | + echo $e->getMessage(); |
|
226 | + die; |
|
227 | + } |
|
228 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
229 | + |
|
230 | + return $spotter_array; |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Gets coordinate & time spotter information based on a particular id |
|
235 | + * |
|
236 | + * @return Array the spotter information |
|
237 | + * |
|
238 | + */ |
|
239 | + public function getCoordArchiveSpotterDataById($id) |
|
240 | + { |
|
241 | + date_default_timezone_set('UTC'); |
|
242 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
243 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
244 | 244 | |
245 | 245 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
246 | 246 | |
247 | - try { |
|
248 | - $sth = $this->db->prepare($query); |
|
249 | - $sth->execute(array(':id' => $id)); |
|
250 | - } catch(PDOException $e) { |
|
251 | - echo $e->getMessage(); |
|
252 | - die; |
|
253 | - } |
|
254 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
247 | + try { |
|
248 | + $sth = $this->db->prepare($query); |
|
249 | + $sth->execute(array(':id' => $id)); |
|
250 | + } catch(PDOException $e) { |
|
251 | + echo $e->getMessage(); |
|
252 | + die; |
|
253 | + } |
|
254 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
255 | 255 | |
256 | - return $spotter_array; |
|
257 | - } |
|
256 | + return $spotter_array; |
|
257 | + } |
|
258 | 258 | |
259 | 259 | |
260 | - /** |
|
261 | - * Gets altitude information based on a particular callsign |
|
262 | - * |
|
263 | - * @return Array the spotter information |
|
264 | - * |
|
265 | - */ |
|
266 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
267 | - { |
|
260 | + /** |
|
261 | + * Gets altitude information based on a particular callsign |
|
262 | + * |
|
263 | + * @return Array the spotter information |
|
264 | + * |
|
265 | + */ |
|
266 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
267 | + { |
|
268 | 268 | |
269 | - date_default_timezone_set('UTC'); |
|
269 | + date_default_timezone_set('UTC'); |
|
270 | 270 | |
271 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
272 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
271 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
272 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
273 | 273 | |
274 | - try { |
|
275 | - $sth = $this->db->prepare($query); |
|
276 | - $sth->execute(array(':ident' => $ident)); |
|
277 | - } catch(PDOException $e) { |
|
278 | - echo $e->getMessage(); |
|
279 | - die; |
|
280 | - } |
|
281 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
274 | + try { |
|
275 | + $sth = $this->db->prepare($query); |
|
276 | + $sth->execute(array(':ident' => $ident)); |
|
277 | + } catch(PDOException $e) { |
|
278 | + echo $e->getMessage(); |
|
279 | + die; |
|
280 | + } |
|
281 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
282 | 282 | |
283 | - return $spotter_array; |
|
284 | - } |
|
283 | + return $spotter_array; |
|
284 | + } |
|
285 | 285 | |
286 | - /** |
|
287 | - * Gets altitude information based on a particular id |
|
288 | - * |
|
289 | - * @return Array the spotter information |
|
290 | - * |
|
291 | - */ |
|
292 | - public function getAltitudeArchiveSpotterDataById($id) |
|
293 | - { |
|
286 | + /** |
|
287 | + * Gets altitude information based on a particular id |
|
288 | + * |
|
289 | + * @return Array the spotter information |
|
290 | + * |
|
291 | + */ |
|
292 | + public function getAltitudeArchiveSpotterDataById($id) |
|
293 | + { |
|
294 | 294 | |
295 | - date_default_timezone_set('UTC'); |
|
295 | + date_default_timezone_set('UTC'); |
|
296 | 296 | |
297 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
298 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
297 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
298 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
299 | 299 | |
300 | - try { |
|
301 | - $sth = $this->db->prepare($query); |
|
302 | - $sth->execute(array(':id' => $id)); |
|
303 | - } catch(PDOException $e) { |
|
304 | - echo $e->getMessage(); |
|
305 | - die; |
|
306 | - } |
|
307 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
300 | + try { |
|
301 | + $sth = $this->db->prepare($query); |
|
302 | + $sth->execute(array(':id' => $id)); |
|
303 | + } catch(PDOException $e) { |
|
304 | + echo $e->getMessage(); |
|
305 | + die; |
|
306 | + } |
|
307 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
308 | 308 | |
309 | - return $spotter_array; |
|
310 | - } |
|
309 | + return $spotter_array; |
|
310 | + } |
|
311 | 311 | |
312 | - /** |
|
313 | - * Gets altitude & speed information based on a particular id |
|
314 | - * |
|
315 | - * @return Array the spotter information |
|
316 | - * |
|
317 | - */ |
|
318 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
319 | - { |
|
312 | + /** |
|
313 | + * Gets altitude & speed information based on a particular id |
|
314 | + * |
|
315 | + * @return Array the spotter information |
|
316 | + * |
|
317 | + */ |
|
318 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
319 | + { |
|
320 | 320 | |
321 | - date_default_timezone_set('UTC'); |
|
321 | + date_default_timezone_set('UTC'); |
|
322 | 322 | |
323 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
324 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
323 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
324 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
325 | 325 | |
326 | - try { |
|
327 | - $sth = $this->db->prepare($query); |
|
328 | - $sth->execute(array(':id' => $id)); |
|
329 | - } catch(PDOException $e) { |
|
330 | - echo $e->getMessage(); |
|
331 | - die; |
|
332 | - } |
|
333 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
326 | + try { |
|
327 | + $sth = $this->db->prepare($query); |
|
328 | + $sth->execute(array(':id' => $id)); |
|
329 | + } catch(PDOException $e) { |
|
330 | + echo $e->getMessage(); |
|
331 | + die; |
|
332 | + } |
|
333 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
334 | 334 | |
335 | - return $spotter_array; |
|
336 | - } |
|
335 | + return $spotter_array; |
|
336 | + } |
|
337 | 337 | |
338 | 338 | |
339 | - /** |
|
340 | - * Gets altitude information based on a particular callsign |
|
341 | - * |
|
342 | - * @return Array the spotter information |
|
343 | - * |
|
344 | - */ |
|
345 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
346 | - { |
|
339 | + /** |
|
340 | + * Gets altitude information based on a particular callsign |
|
341 | + * |
|
342 | + * @return Array the spotter information |
|
343 | + * |
|
344 | + */ |
|
345 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
346 | + { |
|
347 | 347 | |
348 | - date_default_timezone_set('UTC'); |
|
348 | + date_default_timezone_set('UTC'); |
|
349 | 349 | |
350 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
351 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
350 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
351 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
352 | 352 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
353 | 353 | |
354 | - try { |
|
355 | - $sth = $this->db->prepare($query); |
|
356 | - $sth->execute(array(':ident' => $ident)); |
|
357 | - } catch(PDOException $e) { |
|
358 | - echo $e->getMessage(); |
|
359 | - die; |
|
360 | - } |
|
361 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
354 | + try { |
|
355 | + $sth = $this->db->prepare($query); |
|
356 | + $sth->execute(array(':ident' => $ident)); |
|
357 | + } catch(PDOException $e) { |
|
358 | + echo $e->getMessage(); |
|
359 | + die; |
|
360 | + } |
|
361 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
362 | 362 | |
363 | - return $spotter_array; |
|
364 | - } |
|
363 | + return $spotter_array; |
|
364 | + } |
|
365 | 365 | |
366 | 366 | |
367 | 367 | |
368 | - /** |
|
369 | - * Gets all the archive spotter information |
|
370 | - * |
|
371 | - * @return Array the spotter information |
|
372 | - * |
|
373 | - */ |
|
374 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
375 | - { |
|
376 | - $Spotter = new Spotter($this->db); |
|
377 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
378 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
368 | + /** |
|
369 | + * Gets all the archive spotter information |
|
370 | + * |
|
371 | + * @return Array the spotter information |
|
372 | + * |
|
373 | + */ |
|
374 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
375 | + { |
|
376 | + $Spotter = new Spotter($this->db); |
|
377 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
378 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
379 | 379 | |
380 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
380 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
381 | 381 | |
382 | - return $spotter_array; |
|
383 | - } |
|
382 | + return $spotter_array; |
|
383 | + } |
|
384 | 384 | |
385 | - public function deleteSpotterArchiveTrackData() |
|
386 | - { |
|
385 | + public function deleteSpotterArchiveTrackData() |
|
386 | + { |
|
387 | 387 | global $globalArchiveKeepTrackMonths; |
388 | - date_default_timezone_set('UTC'); |
|
388 | + date_default_timezone_set('UTC'); |
|
389 | 389 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
390 | - try { |
|
391 | - $sth = $this->db->prepare($query); |
|
392 | - $sth->execute(); |
|
393 | - } catch(PDOException $e) { |
|
394 | - echo $e->getMessage(); |
|
395 | - die; |
|
396 | - } |
|
390 | + try { |
|
391 | + $sth = $this->db->prepare($query); |
|
392 | + $sth->execute(); |
|
393 | + } catch(PDOException $e) { |
|
394 | + echo $e->getMessage(); |
|
395 | + die; |
|
396 | + } |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
400 | - * Gets Minimal Live Spotter data |
|
401 | - * |
|
402 | - * @return Array the spotter information |
|
403 | - * |
|
404 | - */ |
|
405 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
406 | - { |
|
407 | - global $globalDBdriver, $globalLiveInterval; |
|
408 | - date_default_timezone_set('UTC'); |
|
409 | - |
|
410 | - $filter_query = ''; |
|
411 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
413 | - } |
|
414 | - // Use spotter_output also ? |
|
415 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
416 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
417 | - } |
|
418 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
419 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
420 | - } |
|
421 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
423 | - } |
|
424 | - |
|
425 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
426 | - if ($globalDBdriver == 'mysql') { |
|
427 | - /* |
|
400 | + * Gets Minimal Live Spotter data |
|
401 | + * |
|
402 | + * @return Array the spotter information |
|
403 | + * |
|
404 | + */ |
|
405 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
406 | + { |
|
407 | + global $globalDBdriver, $globalLiveInterval; |
|
408 | + date_default_timezone_set('UTC'); |
|
409 | + |
|
410 | + $filter_query = ''; |
|
411 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
412 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
413 | + } |
|
414 | + // Use spotter_output also ? |
|
415 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
416 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
417 | + } |
|
418 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
419 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
420 | + } |
|
421 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
423 | + } |
|
424 | + |
|
425 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
426 | + if ($globalDBdriver == 'mysql') { |
|
427 | + /* |
|
428 | 428 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
429 | 429 | FROM spotter_archive |
430 | 430 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -443,56 +443,56 @@ discard block |
||
443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
444 | 444 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
445 | 445 | '.$filter_query.' ORDER BY flightaware_id'; |
446 | - } else { |
|
447 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
448 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
446 | + } else { |
|
447 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
448 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
449 | 449 | FROM spotter_archive |
450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
451 | 451 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
452 | 452 | '.$filter_query.' ORDER BY flightaware_id'; |
453 | - } |
|
454 | - //echo $query; |
|
455 | - try { |
|
456 | - $sth = $this->db->prepare($query); |
|
457 | - $sth->execute(); |
|
458 | - } catch(PDOException $e) { |
|
459 | - echo $e->getMessage(); |
|
460 | - die; |
|
461 | - } |
|
462 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
463 | - |
|
464 | - return $spotter_array; |
|
465 | - } |
|
453 | + } |
|
454 | + //echo $query; |
|
455 | + try { |
|
456 | + $sth = $this->db->prepare($query); |
|
457 | + $sth->execute(); |
|
458 | + } catch(PDOException $e) { |
|
459 | + echo $e->getMessage(); |
|
460 | + die; |
|
461 | + } |
|
462 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
463 | + |
|
464 | + return $spotter_array; |
|
465 | + } |
|
466 | 466 | |
467 | 467 | /** |
468 | - * Gets Minimal Live Spotter data |
|
469 | - * |
|
470 | - * @return Array the spotter information |
|
471 | - * |
|
472 | - */ |
|
473 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
474 | - { |
|
475 | - global $globalDBdriver, $globalLiveInterval; |
|
476 | - date_default_timezone_set('UTC'); |
|
477 | - |
|
478 | - $filter_query = ''; |
|
479 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
480 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
481 | - } |
|
482 | - // Should use spotter_output also ? |
|
483 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
484 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
485 | - } |
|
486 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
487 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
488 | - } |
|
489 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
490 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
491 | - } |
|
492 | - |
|
493 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
494 | - if ($globalDBdriver == 'mysql') { |
|
495 | - /* |
|
468 | + * Gets Minimal Live Spotter data |
|
469 | + * |
|
470 | + * @return Array the spotter information |
|
471 | + * |
|
472 | + */ |
|
473 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
474 | + { |
|
475 | + global $globalDBdriver, $globalLiveInterval; |
|
476 | + date_default_timezone_set('UTC'); |
|
477 | + |
|
478 | + $filter_query = ''; |
|
479 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
480 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
481 | + } |
|
482 | + // Should use spotter_output also ? |
|
483 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
484 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
485 | + } |
|
486 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
487 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
488 | + } |
|
489 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
490 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
491 | + } |
|
492 | + |
|
493 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
494 | + if ($globalDBdriver == 'mysql') { |
|
495 | + /* |
|
496 | 496 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
497 | 497 | FROM spotter_archive |
498 | 498 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -503,95 +503,95 @@ discard block |
||
503 | 503 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
504 | 504 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
505 | 505 | |
506 | - } else { |
|
507 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
508 | - /* |
|
506 | + } else { |
|
507 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
508 | + /* |
|
509 | 509 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
510 | 510 | FROM spotter_archive_output |
511 | 511 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
512 | 512 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
513 | 513 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
514 | 514 | */ |
515 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
515 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
516 | 516 | FROM spotter_archive_output |
517 | 517 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
518 | 518 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
519 | 519 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
520 | 520 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
521 | 521 | |
522 | - } |
|
523 | - //echo $query; |
|
524 | - try { |
|
525 | - $sth = $this->db->prepare($query); |
|
526 | - $sth->execute(); |
|
527 | - } catch(PDOException $e) { |
|
528 | - echo $e->getMessage(); |
|
529 | - die; |
|
530 | - } |
|
531 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
532 | - |
|
533 | - return $spotter_array; |
|
534 | - } |
|
522 | + } |
|
523 | + //echo $query; |
|
524 | + try { |
|
525 | + $sth = $this->db->prepare($query); |
|
526 | + $sth->execute(); |
|
527 | + } catch(PDOException $e) { |
|
528 | + echo $e->getMessage(); |
|
529 | + die; |
|
530 | + } |
|
531 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
532 | + |
|
533 | + return $spotter_array; |
|
534 | + } |
|
535 | 535 | |
536 | 536 | /** |
537 | - * Gets count Live Spotter data |
|
538 | - * |
|
539 | - * @return Array the spotter information |
|
540 | - * |
|
541 | - */ |
|
542 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
543 | - { |
|
544 | - global $globalDBdriver, $globalLiveInterval; |
|
545 | - date_default_timezone_set('UTC'); |
|
546 | - |
|
547 | - $filter_query = ''; |
|
548 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
549 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
550 | - } |
|
551 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
552 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
553 | - } |
|
554 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
555 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
556 | - } |
|
557 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
558 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
559 | - } |
|
560 | - |
|
561 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
562 | - if ($globalDBdriver == 'mysql') { |
|
537 | + * Gets count Live Spotter data |
|
538 | + * |
|
539 | + * @return Array the spotter information |
|
540 | + * |
|
541 | + */ |
|
542 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
543 | + { |
|
544 | + global $globalDBdriver, $globalLiveInterval; |
|
545 | + date_default_timezone_set('UTC'); |
|
546 | + |
|
547 | + $filter_query = ''; |
|
548 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
549 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
550 | + } |
|
551 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
552 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
553 | + } |
|
554 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
555 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
556 | + } |
|
557 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
558 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
559 | + } |
|
560 | + |
|
561 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
562 | + if ($globalDBdriver == 'mysql') { |
|
563 | 563 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
564 | 564 | FROM spotter_archive l |
565 | 565 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
566 | - } else { |
|
566 | + } else { |
|
567 | 567 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
568 | - } |
|
569 | - //echo $query; |
|
570 | - try { |
|
571 | - $sth = $this->db->prepare($query); |
|
572 | - $sth->execute(); |
|
573 | - } catch(PDOException $e) { |
|
574 | - echo $e->getMessage(); |
|
575 | - die; |
|
576 | - } |
|
568 | + } |
|
569 | + //echo $query; |
|
570 | + try { |
|
571 | + $sth = $this->db->prepare($query); |
|
572 | + $sth->execute(); |
|
573 | + } catch(PDOException $e) { |
|
574 | + echo $e->getMessage(); |
|
575 | + die; |
|
576 | + } |
|
577 | 577 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
578 | 578 | $sth->closeCursor(); |
579 | - return $result['nb']; |
|
579 | + return $result['nb']; |
|
580 | 580 | |
581 | - } |
|
581 | + } |
|
582 | 582 | |
583 | 583 | |
584 | 584 | |
585 | 585 | // Spotter_Archive_output |
586 | 586 | |
587 | - /** |
|
588 | - * Gets all the spotter information |
|
589 | - * |
|
590 | - * @return Array the spotter information |
|
591 | - * |
|
592 | - */ |
|
593 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
594 | - { |
|
587 | + /** |
|
588 | + * Gets all the spotter information |
|
589 | + * |
|
590 | + * @return Array the spotter information |
|
591 | + * |
|
592 | + */ |
|
593 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
594 | + { |
|
595 | 595 | global $globalTimezone, $globalDBdriver; |
596 | 596 | require_once(dirname(__FILE__).'/class.Translation.php'); |
597 | 597 | $Translation = new Translation(); |
@@ -605,159 +605,159 @@ discard block |
||
605 | 605 | $filter_query = $this->getFilter($filters); |
606 | 606 | if ($q != "") |
607 | 607 | { |
608 | - if (!is_string($q)) |
|
609 | - { |
|
608 | + if (!is_string($q)) |
|
609 | + { |
|
610 | 610 | return false; |
611 | - } else { |
|
611 | + } else { |
|
612 | 612 | |
613 | 613 | $q_array = explode(" ", $q); |
614 | 614 | |
615 | 615 | foreach ($q_array as $q_item){ |
616 | - $additional_query .= " AND ("; |
|
617 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
618 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
619 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
620 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
621 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
622 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
623 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
624 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
625 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
626 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
627 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
628 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
629 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
630 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
631 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
632 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
633 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
634 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
635 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
636 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
637 | - $translate = $Translation->ident2icao($q_item); |
|
638 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
639 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
640 | - $additional_query .= ")"; |
|
641 | - } |
|
642 | - } |
|
616 | + $additional_query .= " AND ("; |
|
617 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
618 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
619 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
620 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
621 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
622 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
623 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
624 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
625 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
626 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
627 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
628 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
629 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
630 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
631 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
632 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
633 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
634 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
635 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
636 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
637 | + $translate = $Translation->ident2icao($q_item); |
|
638 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
639 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
640 | + $additional_query .= ")"; |
|
641 | + } |
|
642 | + } |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | if ($registration != "") |
646 | 646 | { |
647 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
648 | - if (!is_string($registration)) |
|
649 | - { |
|
647 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
648 | + if (!is_string($registration)) |
|
649 | + { |
|
650 | 650 | return false; |
651 | - } else { |
|
651 | + } else { |
|
652 | 652 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
653 | - } |
|
653 | + } |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | if ($aircraft_icao != "") |
657 | 657 | { |
658 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
659 | - if (!is_string($aircraft_icao)) |
|
660 | - { |
|
658 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
659 | + if (!is_string($aircraft_icao)) |
|
660 | + { |
|
661 | 661 | return false; |
662 | - } else { |
|
662 | + } else { |
|
663 | 663 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
664 | - } |
|
664 | + } |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | if ($aircraft_manufacturer != "") |
668 | 668 | { |
669 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
670 | - if (!is_string($aircraft_manufacturer)) |
|
671 | - { |
|
669 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
670 | + if (!is_string($aircraft_manufacturer)) |
|
671 | + { |
|
672 | 672 | return false; |
673 | - } else { |
|
673 | + } else { |
|
674 | 674 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
675 | - } |
|
675 | + } |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | if ($highlights == "true") |
679 | 679 | { |
680 | - if (!is_string($highlights)) |
|
681 | - { |
|
680 | + if (!is_string($highlights)) |
|
681 | + { |
|
682 | 682 | return false; |
683 | - } else { |
|
683 | + } else { |
|
684 | 684 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
685 | - } |
|
685 | + } |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | if ($airline_icao != "") |
689 | 689 | { |
690 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
691 | - if (!is_string($airline_icao)) |
|
692 | - { |
|
690 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
691 | + if (!is_string($airline_icao)) |
|
692 | + { |
|
693 | 693 | return false; |
694 | - } else { |
|
694 | + } else { |
|
695 | 695 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
696 | - } |
|
696 | + } |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | if ($airline_country != "") |
700 | 700 | { |
701 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
702 | - if (!is_string($airline_country)) |
|
703 | - { |
|
701 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
702 | + if (!is_string($airline_country)) |
|
703 | + { |
|
704 | 704 | return false; |
705 | - } else { |
|
705 | + } else { |
|
706 | 706 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
707 | - } |
|
707 | + } |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | if ($airline_type != "") |
711 | 711 | { |
712 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
713 | - if (!is_string($airline_type)) |
|
714 | - { |
|
712 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
713 | + if (!is_string($airline_type)) |
|
714 | + { |
|
715 | 715 | return false; |
716 | - } else { |
|
716 | + } else { |
|
717 | 717 | if ($airline_type == "passenger") |
718 | 718 | { |
719 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
719 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
720 | 720 | } |
721 | 721 | if ($airline_type == "cargo") |
722 | 722 | { |
723 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
723 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
724 | 724 | } |
725 | 725 | if ($airline_type == "military") |
726 | 726 | { |
727 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
727 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
728 | + } |
|
728 | 729 | } |
729 | - } |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | if ($airport != "") |
733 | 733 | { |
734 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
735 | - if (!is_string($airport)) |
|
736 | - { |
|
734 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
735 | + if (!is_string($airport)) |
|
736 | + { |
|
737 | 737 | return false; |
738 | - } else { |
|
738 | + } else { |
|
739 | 739 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
740 | - } |
|
740 | + } |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | if ($airport_country != "") |
744 | 744 | { |
745 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
746 | - if (!is_string($airport_country)) |
|
747 | - { |
|
745 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
746 | + if (!is_string($airport_country)) |
|
747 | + { |
|
748 | 748 | return false; |
749 | - } else { |
|
749 | + } else { |
|
750 | 750 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
751 | - } |
|
751 | + } |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | if ($callsign != "") |
755 | 755 | { |
756 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
757 | - if (!is_string($callsign)) |
|
758 | - { |
|
756 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
757 | + if (!is_string($callsign)) |
|
758 | + { |
|
759 | 759 | return false; |
760 | - } else { |
|
760 | + } else { |
|
761 | 761 | $translate = $Translation->ident2icao($callsign); |
762 | 762 | if ($translate != $callsign) { |
763 | 763 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -765,99 +765,99 @@ discard block |
||
765 | 765 | } else { |
766 | 766 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
767 | 767 | } |
768 | - } |
|
768 | + } |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | if ($owner != "") |
772 | 772 | { |
773 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
774 | - if (!is_string($owner)) |
|
775 | - { |
|
773 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
774 | + if (!is_string($owner)) |
|
775 | + { |
|
776 | 776 | return false; |
777 | - } else { |
|
777 | + } else { |
|
778 | 778 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
779 | - } |
|
779 | + } |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | if ($pilot_name != "") |
783 | 783 | { |
784 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
785 | - if (!is_string($pilot_name)) |
|
786 | - { |
|
784 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
785 | + if (!is_string($pilot_name)) |
|
786 | + { |
|
787 | 787 | return false; |
788 | - } else { |
|
788 | + } else { |
|
789 | 789 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
790 | - } |
|
790 | + } |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | if ($pilot_id != "") |
794 | 794 | { |
795 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
796 | - if (!is_string($pilot_id)) |
|
797 | - { |
|
795 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
796 | + if (!is_string($pilot_id)) |
|
797 | + { |
|
798 | 798 | return false; |
799 | - } else { |
|
799 | + } else { |
|
800 | 800 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
801 | - } |
|
801 | + } |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | if ($departure_airport_route != "") |
805 | 805 | { |
806 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
807 | - if (!is_string($departure_airport_route)) |
|
808 | - { |
|
806 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
807 | + if (!is_string($departure_airport_route)) |
|
808 | + { |
|
809 | 809 | return false; |
810 | - } else { |
|
810 | + } else { |
|
811 | 811 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
812 | - } |
|
812 | + } |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | if ($arrival_airport_route != "") |
816 | 816 | { |
817 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
818 | - if (!is_string($arrival_airport_route)) |
|
819 | - { |
|
817 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
818 | + if (!is_string($arrival_airport_route)) |
|
819 | + { |
|
820 | 820 | return false; |
821 | - } else { |
|
821 | + } else { |
|
822 | 822 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
823 | - } |
|
823 | + } |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | if ($altitude != "") |
827 | 827 | { |
828 | - $altitude_array = explode(",", $altitude); |
|
828 | + $altitude_array = explode(",", $altitude); |
|
829 | 829 | |
830 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
831 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
830 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
831 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
832 | 832 | |
833 | 833 | |
834 | - if ($altitude_array[1] != "") |
|
835 | - { |
|
834 | + if ($altitude_array[1] != "") |
|
835 | + { |
|
836 | 836 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
837 | 837 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
838 | 838 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
839 | - } else { |
|
839 | + } else { |
|
840 | 840 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
841 | 841 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
842 | - } |
|
842 | + } |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | if ($date_posted != "") |
846 | 846 | { |
847 | - $date_array = explode(",", $date_posted); |
|
847 | + $date_array = explode(",", $date_posted); |
|
848 | 848 | |
849 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
850 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
849 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
850 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
851 | 851 | |
852 | - if ($globalTimezone != '') { |
|
852 | + if ($globalTimezone != '') { |
|
853 | 853 | date_default_timezone_set($globalTimezone); |
854 | 854 | $datetime = new DateTime(); |
855 | 855 | $offset = $datetime->format('P'); |
856 | - } else $offset = '+00:00'; |
|
856 | + } else $offset = '+00:00'; |
|
857 | 857 | |
858 | 858 | |
859 | - if ($date_array[1] != "") |
|
860 | - { |
|
859 | + if ($date_array[1] != "") |
|
860 | + { |
|
861 | 861 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
862 | 862 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
863 | 863 | if ($globalDBdriver == 'mysql') { |
@@ -865,28 +865,28 @@ discard block |
||
865 | 865 | } else { |
866 | 866 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
867 | 867 | } |
868 | - } else { |
|
868 | + } else { |
|
869 | 869 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
870 | - if ($globalDBdriver == 'mysql') { |
|
870 | + if ($globalDBdriver == 'mysql') { |
|
871 | 871 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
872 | 872 | } else { |
873 | 873 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
874 | 874 | } |
875 | - } |
|
875 | + } |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | if ($limit != "") |
879 | 879 | { |
880 | - $limit_array = explode(",", $limit); |
|
880 | + $limit_array = explode(",", $limit); |
|
881 | 881 | |
882 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
883 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
882 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
883 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
884 | 884 | |
885 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
886 | - { |
|
885 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
886 | + { |
|
887 | 887 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
888 | 888 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
889 | - } |
|
889 | + } |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | |
@@ -917,33 +917,33 @@ discard block |
||
917 | 917 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
918 | 918 | |
919 | 919 | return $spotter_array; |
920 | - } |
|
920 | + } |
|
921 | 921 | |
922 | - public function deleteSpotterArchiveData() |
|
923 | - { |
|
922 | + public function deleteSpotterArchiveData() |
|
923 | + { |
|
924 | 924 | global $globalArchiveKeepMonths, $globalDBdriver; |
925 | - date_default_timezone_set('UTC'); |
|
926 | - if ($globalDBdriver == 'mysql') { |
|
925 | + date_default_timezone_set('UTC'); |
|
926 | + if ($globalDBdriver == 'mysql') { |
|
927 | 927 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
928 | 928 | } else { |
929 | 929 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
930 | 930 | } |
931 | - try { |
|
932 | - $sth = $this->db->prepare($query); |
|
933 | - $sth->execute(); |
|
934 | - } catch(PDOException $e) { |
|
935 | - return "error"; |
|
936 | - } |
|
931 | + try { |
|
932 | + $sth = $this->db->prepare($query); |
|
933 | + $sth->execute(); |
|
934 | + } catch(PDOException $e) { |
|
935 | + return "error"; |
|
936 | + } |
|
937 | 937 | } |
938 | 938 | |
939 | - /** |
|
940 | - * Gets all the spotter information based on the callsign |
|
941 | - * |
|
942 | - * @return Array the spotter information |
|
943 | - * |
|
944 | - */ |
|
945 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
946 | - { |
|
939 | + /** |
|
940 | + * Gets all the spotter information based on the callsign |
|
941 | + * |
|
942 | + * @return Array the spotter information |
|
943 | + * |
|
944 | + */ |
|
945 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
946 | + { |
|
947 | 947 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
948 | 948 | |
949 | 949 | date_default_timezone_set('UTC'); |
@@ -955,35 +955,35 @@ discard block |
||
955 | 955 | |
956 | 956 | if ($ident != "") |
957 | 957 | { |
958 | - if (!is_string($ident)) |
|
959 | - { |
|
958 | + if (!is_string($ident)) |
|
959 | + { |
|
960 | 960 | return false; |
961 | - } else { |
|
961 | + } else { |
|
962 | 962 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
963 | 963 | $query_values = array(':ident' => $ident); |
964 | - } |
|
964 | + } |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | if ($limit != "") |
968 | 968 | { |
969 | - $limit_array = explode(",", $limit); |
|
969 | + $limit_array = explode(",", $limit); |
|
970 | 970 | |
971 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
972 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
971 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
972 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
973 | 973 | |
974 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
975 | - { |
|
974 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
975 | + { |
|
976 | 976 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
977 | 977 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
978 | - } |
|
978 | + } |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | if ($sort != "") |
982 | 982 | { |
983 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
984 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
983 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
984 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
985 | 985 | } else { |
986 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
986 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -991,17 +991,17 @@ discard block |
||
991 | 991 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
992 | 992 | |
993 | 993 | return $spotter_array; |
994 | - } |
|
994 | + } |
|
995 | 995 | |
996 | 996 | |
997 | - /** |
|
998 | - * Gets all the spotter information based on the owner |
|
999 | - * |
|
1000 | - * @return Array the spotter information |
|
1001 | - * |
|
1002 | - */ |
|
1003 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
1004 | - { |
|
997 | + /** |
|
998 | + * Gets all the spotter information based on the owner |
|
999 | + * |
|
1000 | + * @return Array the spotter information |
|
1001 | + * |
|
1002 | + */ |
|
1003 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
1004 | + { |
|
1005 | 1005 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1006 | 1006 | |
1007 | 1007 | date_default_timezone_set('UTC'); |
@@ -1014,35 +1014,35 @@ discard block |
||
1014 | 1014 | |
1015 | 1015 | if ($owner != "") |
1016 | 1016 | { |
1017 | - if (!is_string($owner)) |
|
1018 | - { |
|
1017 | + if (!is_string($owner)) |
|
1018 | + { |
|
1019 | 1019 | return false; |
1020 | - } else { |
|
1020 | + } else { |
|
1021 | 1021 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
1022 | 1022 | $query_values = array(':owner' => $owner); |
1023 | - } |
|
1023 | + } |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | if ($limit != "") |
1027 | 1027 | { |
1028 | - $limit_array = explode(",", $limit); |
|
1028 | + $limit_array = explode(",", $limit); |
|
1029 | 1029 | |
1030 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1031 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1031 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1032 | 1032 | |
1033 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1034 | - { |
|
1033 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1034 | + { |
|
1035 | 1035 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1036 | 1036 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1037 | - } |
|
1037 | + } |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | if ($sort != "") |
1041 | 1041 | { |
1042 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1043 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1042 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1043 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1044 | 1044 | } else { |
1045 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1045 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1050,16 +1050,16 @@ discard block |
||
1050 | 1050 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1051 | 1051 | |
1052 | 1052 | return $spotter_array; |
1053 | - } |
|
1054 | - |
|
1055 | - /** |
|
1056 | - * Gets all the spotter information based on the pilot |
|
1057 | - * |
|
1058 | - * @return Array the spotter information |
|
1059 | - * |
|
1060 | - */ |
|
1061 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1062 | - { |
|
1053 | + } |
|
1054 | + |
|
1055 | + /** |
|
1056 | + * Gets all the spotter information based on the pilot |
|
1057 | + * |
|
1058 | + * @return Array the spotter information |
|
1059 | + * |
|
1060 | + */ |
|
1061 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1062 | + { |
|
1063 | 1063 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1064 | 1064 | |
1065 | 1065 | date_default_timezone_set('UTC'); |
@@ -1078,24 +1078,24 @@ discard block |
||
1078 | 1078 | |
1079 | 1079 | if ($limit != "") |
1080 | 1080 | { |
1081 | - $limit_array = explode(",", $limit); |
|
1081 | + $limit_array = explode(",", $limit); |
|
1082 | 1082 | |
1083 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1084 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1083 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1084 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1085 | 1085 | |
1086 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1087 | - { |
|
1086 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1087 | + { |
|
1088 | 1088 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1089 | 1089 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1090 | - } |
|
1090 | + } |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | if ($sort != "") |
1094 | 1094 | { |
1095 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1096 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1095 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1096 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1097 | 1097 | } else { |
1098 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1098 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1103,16 +1103,16 @@ discard block |
||
1103 | 1103 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1104 | 1104 | |
1105 | 1105 | return $spotter_array; |
1106 | - } |
|
1107 | - |
|
1108 | - /** |
|
1109 | - * Gets all number of flight over countries |
|
1110 | - * |
|
1111 | - * @return Array the airline country list |
|
1112 | - * |
|
1113 | - */ |
|
1114 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1115 | - { |
|
1106 | + } |
|
1107 | + |
|
1108 | + /** |
|
1109 | + * Gets all number of flight over countries |
|
1110 | + * |
|
1111 | + * @return Array the airline country list |
|
1112 | + * |
|
1113 | + */ |
|
1114 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1115 | + { |
|
1116 | 1116 | global $globalDBdriver; |
1117 | 1117 | /* |
1118 | 1118 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1122,14 +1122,14 @@ discard block |
||
1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1123 | 1123 | FROM countries c, spotter_archive s |
1124 | 1124 | WHERE c.iso2 = s.over_country "; |
1125 | - if ($olderthanmonths > 0) { |
|
1126 | - if ($globalDBdriver == 'mysql') { |
|
1125 | + if ($olderthanmonths > 0) { |
|
1126 | + if ($globalDBdriver == 'mysql') { |
|
1127 | 1127 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1128 | 1128 | } else { |
1129 | 1129 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1130 | 1130 | } |
1131 | 1131 | } |
1132 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1132 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1133 | 1133 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1134 | 1134 | if ($limit) $query .= " LIMIT 0,10"; |
1135 | 1135 | |
@@ -1142,23 +1142,23 @@ discard block |
||
1142 | 1142 | |
1143 | 1143 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1144 | 1144 | { |
1145 | - $temp_array['flight_count'] = $row['nb']; |
|
1146 | - $temp_array['flight_country'] = $row['name']; |
|
1147 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1148 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1149 | - $flight_array[] = $temp_array; |
|
1145 | + $temp_array['flight_count'] = $row['nb']; |
|
1146 | + $temp_array['flight_country'] = $row['name']; |
|
1147 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1148 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1149 | + $flight_array[] = $temp_array; |
|
1150 | 1150 | } |
1151 | 1151 | return $flight_array; |
1152 | - } |
|
1153 | - |
|
1154 | - /** |
|
1155 | - * Gets all number of flight over countries |
|
1156 | - * |
|
1157 | - * @return Array the airline country list |
|
1158 | - * |
|
1159 | - */ |
|
1160 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1161 | - { |
|
1152 | + } |
|
1153 | + |
|
1154 | + /** |
|
1155 | + * Gets all number of flight over countries |
|
1156 | + * |
|
1157 | + * @return Array the airline country list |
|
1158 | + * |
|
1159 | + */ |
|
1160 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1161 | + { |
|
1162 | 1162 | global $globalDBdriver; |
1163 | 1163 | /* |
1164 | 1164 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1168,14 +1168,14 @@ discard block |
||
1168 | 1168 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1169 | 1169 | FROM countries c, spotter_archive s, spotter_output o |
1170 | 1170 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
1171 | - if ($olderthanmonths > 0) { |
|
1172 | - if ($globalDBdriver == 'mysql') { |
|
1171 | + if ($olderthanmonths > 0) { |
|
1172 | + if ($globalDBdriver == 'mysql') { |
|
1173 | 1173 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1174 | 1174 | } else { |
1175 | 1175 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1176 | 1176 | } |
1177 | 1177 | } |
1178 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1178 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1179 | 1179 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1180 | 1180 | if ($limit) $query .= " LIMIT 0,10"; |
1181 | 1181 | |
@@ -1188,24 +1188,24 @@ discard block |
||
1188 | 1188 | |
1189 | 1189 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1190 | 1190 | { |
1191 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1192 | - $temp_array['flight_count'] = $row['nb']; |
|
1193 | - $temp_array['flight_country'] = $row['name']; |
|
1194 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1195 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1196 | - $flight_array[] = $temp_array; |
|
1191 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1192 | + $temp_array['flight_count'] = $row['nb']; |
|
1193 | + $temp_array['flight_country'] = $row['name']; |
|
1194 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1195 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1196 | + $flight_array[] = $temp_array; |
|
1197 | 1197 | } |
1198 | 1198 | return $flight_array; |
1199 | - } |
|
1200 | - |
|
1201 | - /** |
|
1202 | - * Gets last spotter information based on a particular callsign |
|
1203 | - * |
|
1204 | - * @return Array the spotter information |
|
1205 | - * |
|
1206 | - */ |
|
1207 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1208 | - { |
|
1199 | + } |
|
1200 | + |
|
1201 | + /** |
|
1202 | + * Gets last spotter information based on a particular callsign |
|
1203 | + * |
|
1204 | + * @return Array the spotter information |
|
1205 | + * |
|
1206 | + */ |
|
1207 | + public function getDateArchiveSpotterDataById($id,$date) |
|
1208 | + { |
|
1209 | 1209 | $Spotter = new Spotter($this->db); |
1210 | 1210 | date_default_timezone_set('UTC'); |
1211 | 1211 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1213,16 +1213,16 @@ discard block |
||
1213 | 1213 | $date = date('c',$date); |
1214 | 1214 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1215 | 1215 | return $spotter_array; |
1216 | - } |
|
1217 | - |
|
1218 | - /** |
|
1219 | - * Gets all the spotter information based on a particular callsign |
|
1220 | - * |
|
1221 | - * @return Array the spotter information |
|
1222 | - * |
|
1223 | - */ |
|
1224 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1225 | - { |
|
1216 | + } |
|
1217 | + |
|
1218 | + /** |
|
1219 | + * Gets all the spotter information based on a particular callsign |
|
1220 | + * |
|
1221 | + * @return Array the spotter information |
|
1222 | + * |
|
1223 | + */ |
|
1224 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1225 | + { |
|
1226 | 1226 | $Spotter = new Spotter($this->db); |
1227 | 1227 | date_default_timezone_set('UTC'); |
1228 | 1228 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1230,16 +1230,16 @@ discard block |
||
1230 | 1230 | $date = date('c',$date); |
1231 | 1231 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1232 | 1232 | return $spotter_array; |
1233 | - } |
|
1234 | - |
|
1235 | - /** |
|
1236 | - * Gets all the spotter information based on the airport |
|
1237 | - * |
|
1238 | - * @return Array the spotter information |
|
1239 | - * |
|
1240 | - */ |
|
1241 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1242 | - { |
|
1233 | + } |
|
1234 | + |
|
1235 | + /** |
|
1236 | + * Gets all the spotter information based on the airport |
|
1237 | + * |
|
1238 | + * @return Array the spotter information |
|
1239 | + * |
|
1240 | + */ |
|
1241 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1242 | + { |
|
1243 | 1243 | global $global_query; |
1244 | 1244 | $Spotter = new Spotter(); |
1245 | 1245 | date_default_timezone_set('UTC'); |
@@ -1250,35 +1250,35 @@ discard block |
||
1250 | 1250 | |
1251 | 1251 | if ($airport != "") |
1252 | 1252 | { |
1253 | - if (!is_string($airport)) |
|
1254 | - { |
|
1253 | + if (!is_string($airport)) |
|
1254 | + { |
|
1255 | 1255 | return false; |
1256 | - } else { |
|
1256 | + } else { |
|
1257 | 1257 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
1258 | 1258 | $query_values = array(':airport' => $airport); |
1259 | - } |
|
1259 | + } |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | if ($limit != "") |
1263 | 1263 | { |
1264 | - $limit_array = explode(",", $limit); |
|
1264 | + $limit_array = explode(",", $limit); |
|
1265 | 1265 | |
1266 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1267 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1266 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1267 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1268 | 1268 | |
1269 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1270 | - { |
|
1269 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1270 | + { |
|
1271 | 1271 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1272 | 1272 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1273 | - } |
|
1273 | + } |
|
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 | if ($sort != "") |
1277 | 1277 | { |
1278 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1279 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1278 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1279 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1280 | 1280 | } else { |
1281 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1281 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1286,6 +1286,6 @@ discard block |
||
1286 | 1286 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1287 | 1287 | |
1288 | 1288 | return $spotter_array; |
1289 | - } |
|
1289 | + } |
|
1290 | 1290 | } |
1291 | 1291 | ?> |
1292 | 1292 | \ No newline at end of file |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * Gets all the spotter information based on the latest data entry |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
131 | + * Gets all the spotter information based on the latest data entry |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
137 | 137 | { |
138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Gets Minimal Live Spotter data |
|
178 | - * |
|
179 | - * @return Array the spotter information |
|
180 | - * |
|
181 | - */ |
|
177 | + * Gets Minimal Live Spotter data |
|
178 | + * |
|
179 | + * @return Array the spotter information |
|
180 | + * |
|
181 | + */ |
|
182 | 182 | public function getMinLiveSpotterData($filter = array()) |
183 | 183 | { |
184 | 184 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | - * Gets Minimal Live Spotter data since xx seconds |
|
219 | - * |
|
220 | - * @return Array the spotter information |
|
221 | - * |
|
222 | - */ |
|
218 | + * Gets Minimal Live Spotter data since xx seconds |
|
219 | + * |
|
220 | + * @return Array the spotter information |
|
221 | + * |
|
222 | + */ |
|
223 | 223 | public function getMinLastLiveSpotterData($filter = array()) |
224 | 224 | { |
225 | 225 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
239 | 239 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
240 | 240 | } |
241 | - } else { |
|
241 | + } else { |
|
242 | 242 | if (isset($globalArchive) && $globalArchive === TRUE) { |
243 | 243 | $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
244 | 244 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - try { |
|
253 | + try { |
|
254 | 254 | $sth = $this->db->prepare($query); |
255 | 255 | $sth->execute(); |
256 | 256 | } catch(PDOException $e) { |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets number of latest data entry |
|
266 | - * |
|
267 | - * @return String number of entry |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets number of latest data entry |
|
266 | + * |
|
267 | + * @return String number of entry |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getLiveSpotterCount($filter = array()) |
271 | 271 | { |
272 | 272 | global $globalDBdriver, $globalLiveInterval; |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | - * Gets all the spotter information based on the latest data entry and coord |
|
297 | - * |
|
298 | - * @return Array the spotter information |
|
299 | - * |
|
300 | - */ |
|
296 | + * Gets all the spotter information based on the latest data entry and coord |
|
297 | + * |
|
298 | + * @return Array the spotter information |
|
299 | + * |
|
300 | + */ |
|
301 | 301 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
302 | 302 | { |
303 | 303 | global $globalDBdriver, $globalLiveInterval; |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
325 | - * Gets all the spotter information based on the latest data entry and coord |
|
326 | - * |
|
327 | - * @return Array the spotter information |
|
328 | - * |
|
329 | - */ |
|
325 | + * Gets all the spotter information based on the latest data entry and coord |
|
326 | + * |
|
327 | + * @return Array the spotter information |
|
328 | + * |
|
329 | + */ |
|
330 | 330 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
331 | 331 | { |
332 | 332 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | - * Gets all the spotter information based on a user's latitude and longitude |
|
395 | - * |
|
396 | - * @return Array the spotter information |
|
397 | - * |
|
398 | - */ |
|
394 | + * Gets all the spotter information based on a user's latitude and longitude |
|
395 | + * |
|
396 | + * @return Array the spotter information |
|
397 | + * |
|
398 | + */ |
|
399 | 399 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
400 | 400 | { |
401 | 401 | $Spotter = new Spotter($this->db); |
@@ -405,145 +405,145 @@ discard block |
||
405 | 405 | return false; |
406 | 406 | } |
407 | 407 | } |
408 | - if ($lng != '') |
|
409 | - { |
|
410 | - if (!is_numeric($lng)) |
|
411 | - { |
|
412 | - return false; |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - if ($radius != '') |
|
417 | - { |
|
418 | - if (!is_numeric($radius)) |
|
419 | - { |
|
420 | - return false; |
|
421 | - } |
|
422 | - } |
|
408 | + if ($lng != '') |
|
409 | + { |
|
410 | + if (!is_numeric($lng)) |
|
411 | + { |
|
412 | + return false; |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + if ($radius != '') |
|
417 | + { |
|
418 | + if (!is_numeric($radius)) |
|
419 | + { |
|
420 | + return false; |
|
421 | + } |
|
422 | + } |
|
423 | 423 | $additional_query = ''; |
424 | - if ($interval != '') |
|
425 | - { |
|
426 | - if (!is_string($interval)) |
|
427 | - { |
|
428 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
429 | - return false; |
|
430 | - } else { |
|
431 | - if ($interval == '1m') |
|
432 | - { |
|
433 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
434 | - } else if ($interval == '15m'){ |
|
435 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
436 | - } |
|
437 | - } |
|
438 | - } else { |
|
439 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
440 | - } |
|
441 | - |
|
442 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
424 | + if ($interval != '') |
|
425 | + { |
|
426 | + if (!is_string($interval)) |
|
427 | + { |
|
428 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
429 | + return false; |
|
430 | + } else { |
|
431 | + if ($interval == '1m') |
|
432 | + { |
|
433 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
434 | + } else if ($interval == '15m'){ |
|
435 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
436 | + } |
|
437 | + } |
|
438 | + } else { |
|
439 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
440 | + } |
|
441 | + |
|
442 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
443 | 443 | WHERE spotter_live.latitude <> '' |
444 | 444 | AND spotter_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
450 | 450 | |
451 | - return $spotter_array; |
|
452 | - } |
|
451 | + return $spotter_array; |
|
452 | + } |
|
453 | 453 | |
454 | 454 | |
455 | - /** |
|
456 | - * Gets all the spotter information based on a particular callsign |
|
457 | - * |
|
458 | - * @return Array the spotter information |
|
459 | - * |
|
460 | - */ |
|
455 | + /** |
|
456 | + * Gets all the spotter information based on a particular callsign |
|
457 | + * |
|
458 | + * @return Array the spotter information |
|
459 | + * |
|
460 | + */ |
|
461 | 461 | public function getLastLiveSpotterDataByIdent($ident) |
462 | 462 | { |
463 | 463 | $Spotter = new Spotter($this->db); |
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
467 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
468 | 468 | |
469 | 469 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
473 | 473 | |
474 | - /** |
|
475 | - * Gets all the spotter information based on a particular callsign |
|
476 | - * |
|
477 | - * @return Array the spotter information |
|
478 | - * |
|
479 | - */ |
|
474 | + /** |
|
475 | + * Gets all the spotter information based on a particular callsign |
|
476 | + * |
|
477 | + * @return Array the spotter information |
|
478 | + * |
|
479 | + */ |
|
480 | 480 | public function getDateLiveSpotterDataByIdent($ident,$date) |
481 | 481 | { |
482 | 482 | $Spotter = new Spotter($this->db); |
483 | 483 | date_default_timezone_set('UTC'); |
484 | 484 | |
485 | 485 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
486 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
486 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
487 | 487 | |
488 | - $date = date('c',$date); |
|
488 | + $date = date('c',$date); |
|
489 | 489 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
490 | 490 | |
491 | 491 | return $spotter_array; |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * Gets last spotter information based on a particular callsign |
|
496 | - * |
|
497 | - * @return Array the spotter information |
|
498 | - * |
|
499 | - */ |
|
494 | + /** |
|
495 | + * Gets last spotter information based on a particular callsign |
|
496 | + * |
|
497 | + * @return Array the spotter information |
|
498 | + * |
|
499 | + */ |
|
500 | 500 | public function getLastLiveSpotterDataById($id) |
501 | 501 | { |
502 | 502 | $Spotter = new Spotter($this->db); |
503 | 503 | date_default_timezone_set('UTC'); |
504 | 504 | |
505 | 505 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
506 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
506 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
507 | 507 | |
508 | 508 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
509 | 509 | |
510 | 510 | return $spotter_array; |
511 | 511 | } |
512 | 512 | |
513 | - /** |
|
514 | - * Gets last spotter information based on a particular callsign |
|
515 | - * |
|
516 | - * @return Array the spotter information |
|
517 | - * |
|
518 | - */ |
|
513 | + /** |
|
514 | + * Gets last spotter information based on a particular callsign |
|
515 | + * |
|
516 | + * @return Array the spotter information |
|
517 | + * |
|
518 | + */ |
|
519 | 519 | public function getDateLiveSpotterDataById($id,$date) |
520 | 520 | { |
521 | 521 | $Spotter = new Spotter($this->db); |
522 | 522 | date_default_timezone_set('UTC'); |
523 | 523 | |
524 | 524 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
525 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
526 | - $date = date('c',$date); |
|
525 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
526 | + $date = date('c',$date); |
|
527 | 527 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
528 | 528 | |
529 | 529 | return $spotter_array; |
530 | 530 | } |
531 | 531 | |
532 | - /** |
|
533 | - * Gets altitude information based on a particular callsign |
|
534 | - * |
|
535 | - * @return Array the spotter information |
|
536 | - * |
|
537 | - */ |
|
532 | + /** |
|
533 | + * Gets altitude information based on a particular callsign |
|
534 | + * |
|
535 | + * @return Array the spotter information |
|
536 | + * |
|
537 | + */ |
|
538 | 538 | public function getAltitudeLiveSpotterDataByIdent($ident) |
539 | 539 | { |
540 | 540 | |
541 | 541 | date_default_timezone_set('UTC'); |
542 | 542 | |
543 | 543 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
544 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
544 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
545 | 545 | |
546 | - try { |
|
546 | + try { |
|
547 | 547 | |
548 | 548 | $sth = $this->db->prepare($query); |
549 | 549 | $sth->execute(array(':ident' => $ident)); |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | return $spotter_array; |
557 | 557 | } |
558 | 558 | |
559 | - /** |
|
560 | - * Gets all the spotter information based on a particular id |
|
561 | - * |
|
562 | - * @return Array the spotter information |
|
563 | - * |
|
564 | - */ |
|
559 | + /** |
|
560 | + * Gets all the spotter information based on a particular id |
|
561 | + * |
|
562 | + * @return Array the spotter information |
|
563 | + * |
|
564 | + */ |
|
565 | 565 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
566 | 566 | { |
567 | 567 | global $globalDBdriver, $globalLiveInterval; |
@@ -589,18 +589,18 @@ discard block |
||
589 | 589 | return $spotter_array; |
590 | 590 | } |
591 | 591 | |
592 | - /** |
|
593 | - * Gets all the spotter information based on a particular ident |
|
594 | - * |
|
595 | - * @return Array the spotter information |
|
596 | - * |
|
597 | - */ |
|
592 | + /** |
|
593 | + * Gets all the spotter information based on a particular ident |
|
594 | + * |
|
595 | + * @return Array the spotter information |
|
596 | + * |
|
597 | + */ |
|
598 | 598 | public function getAllLiveSpotterDataByIdent($ident) |
599 | 599 | { |
600 | 600 | date_default_timezone_set('UTC'); |
601 | 601 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
602 | 602 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
603 | - try { |
|
603 | + try { |
|
604 | 604 | |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(array(':ident' => $ident)); |
@@ -614,23 +614,23 @@ discard block |
||
614 | 614 | |
615 | 615 | |
616 | 616 | /** |
617 | - * Deletes all info in the table |
|
618 | - * |
|
619 | - * @return String success or false |
|
620 | - * |
|
621 | - */ |
|
617 | + * Deletes all info in the table |
|
618 | + * |
|
619 | + * @return String success or false |
|
620 | + * |
|
621 | + */ |
|
622 | 622 | public function deleteLiveSpotterData() |
623 | 623 | { |
624 | 624 | global $globalDBdriver; |
625 | 625 | if ($globalDBdriver == 'mysql') { |
626 | 626 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
627 | 627 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
628 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
628 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
629 | 629 | } else { |
630 | 630 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
631 | 631 | } |
632 | 632 | |
633 | - try { |
|
633 | + try { |
|
634 | 634 | |
635 | 635 | $sth = $this->db->prepare($query); |
636 | 636 | $sth->execute(); |
@@ -642,18 +642,18 @@ discard block |
||
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
645 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
646 | - * |
|
647 | - * @return String success or false |
|
648 | - * |
|
649 | - */ |
|
645 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
646 | + * |
|
647 | + * @return String success or false |
|
648 | + * |
|
649 | + */ |
|
650 | 650 | public function deleteLiveSpotterDataNotUpdated() |
651 | 651 | { |
652 | 652 | global $globalDBdriver, $globalDebug; |
653 | 653 | if ($globalDBdriver == 'mysql') { |
654 | 654 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
655 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
656 | - try { |
|
655 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
656 | + try { |
|
657 | 657 | |
658 | 658 | $sth = $this->db->prepare($query); |
659 | 659 | $sth->execute(); |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | return "error"; |
662 | 662 | } |
663 | 663 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
664 | - $i = 0; |
|
665 | - $j =0; |
|
664 | + $i = 0; |
|
665 | + $j =0; |
|
666 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
667 | 667 | foreach($all as $row) |
668 | 668 | { |
@@ -670,20 +670,20 @@ discard block |
||
670 | 670 | $j++; |
671 | 671 | if ($j == 30) { |
672 | 672 | if ($globalDebug) echo "."; |
673 | - try { |
|
673 | + try { |
|
674 | 674 | |
675 | 675 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
676 | 676 | $sth->execute(); |
677 | 677 | } catch(PDOException $e) { |
678 | 678 | return "error"; |
679 | 679 | } |
680 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
681 | - $j = 0; |
|
680 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
681 | + $j = 0; |
|
682 | 682 | } |
683 | 683 | $query_delete .= "'".$row['flightaware_id']."',"; |
684 | 684 | } |
685 | 685 | if ($i > 0) { |
686 | - try { |
|
686 | + try { |
|
687 | 687 | |
688 | 688 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
689 | 689 | $sth->execute(); |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | return "success"; |
695 | 695 | } elseif ($globalDBdriver == 'pgsql') { |
696 | 696 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
697 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
698 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
699 | - try { |
|
697 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
698 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
699 | + try { |
|
700 | 700 | |
701 | 701 | $sth = $this->db->prepare($query); |
702 | 702 | $sth->execute(); |
@@ -740,17 +740,17 @@ discard block |
||
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
743 | - * Deletes all info in the table for an ident |
|
744 | - * |
|
745 | - * @return String success or false |
|
746 | - * |
|
747 | - */ |
|
743 | + * Deletes all info in the table for an ident |
|
744 | + * |
|
745 | + * @return String success or false |
|
746 | + * |
|
747 | + */ |
|
748 | 748 | public function deleteLiveSpotterDataByIdent($ident) |
749 | 749 | { |
750 | 750 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
751 | 751 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
752 | 752 | |
753 | - try { |
|
753 | + try { |
|
754 | 754 | |
755 | 755 | $sth = $this->db->prepare($query); |
756 | 756 | $sth->execute(array(':ident' => $ident)); |
@@ -762,17 +762,17 @@ discard block |
||
762 | 762 | } |
763 | 763 | |
764 | 764 | /** |
765 | - * Deletes all info in the table for an id |
|
766 | - * |
|
767 | - * @return String success or false |
|
768 | - * |
|
769 | - */ |
|
765 | + * Deletes all info in the table for an id |
|
766 | + * |
|
767 | + * @return String success or false |
|
768 | + * |
|
769 | + */ |
|
770 | 770 | public function deleteLiveSpotterDataById($id) |
771 | 771 | { |
772 | 772 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
773 | 773 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
774 | 774 | |
775 | - try { |
|
775 | + try { |
|
776 | 776 | |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute(array(':id' => $id)); |
@@ -785,11 +785,11 @@ discard block |
||
785 | 785 | |
786 | 786 | |
787 | 787 | /** |
788 | - * Gets the aircraft ident within the last hour |
|
789 | - * |
|
790 | - * @return String the ident |
|
791 | - * |
|
792 | - */ |
|
788 | + * Gets the aircraft ident within the last hour |
|
789 | + * |
|
790 | + * @return String the ident |
|
791 | + * |
|
792 | + */ |
|
793 | 793 | public function getIdentFromLastHour($ident) |
794 | 794 | { |
795 | 795 | global $globalDBdriver, $globalTimezone; |
@@ -815,14 +815,14 @@ discard block |
||
815 | 815 | $ident_result = $row['ident']; |
816 | 816 | } |
817 | 817 | return $ident_result; |
818 | - } |
|
818 | + } |
|
819 | 819 | |
820 | 820 | /** |
821 | - * Check recent aircraft |
|
822 | - * |
|
823 | - * @return String the ident |
|
824 | - * |
|
825 | - */ |
|
821 | + * Check recent aircraft |
|
822 | + * |
|
823 | + * @return String the ident |
|
824 | + * |
|
825 | + */ |
|
826 | 826 | public function checkIdentRecent($ident) |
827 | 827 | { |
828 | 828 | global $globalDBdriver, $globalTimezone; |
@@ -848,14 +848,14 @@ discard block |
||
848 | 848 | $ident_result = $row['flightaware_id']; |
849 | 849 | } |
850 | 850 | return $ident_result; |
851 | - } |
|
851 | + } |
|
852 | 852 | |
853 | 853 | /** |
854 | - * Check recent aircraft by id |
|
855 | - * |
|
856 | - * @return String the ident |
|
857 | - * |
|
858 | - */ |
|
854 | + * Check recent aircraft by id |
|
855 | + * |
|
856 | + * @return String the ident |
|
857 | + * |
|
858 | + */ |
|
859 | 859 | public function checkIdRecent($id) |
860 | 860 | { |
861 | 861 | global $globalDBdriver, $globalTimezone; |
@@ -881,14 +881,14 @@ discard block |
||
881 | 881 | $ident_result = $row['flightaware_id']; |
882 | 882 | } |
883 | 883 | return $ident_result; |
884 | - } |
|
884 | + } |
|
885 | 885 | |
886 | 886 | /** |
887 | - * Check recent aircraft by ModeS |
|
888 | - * |
|
889 | - * @return String the ModeS |
|
890 | - * |
|
891 | - */ |
|
887 | + * Check recent aircraft by ModeS |
|
888 | + * |
|
889 | + * @return String the ModeS |
|
890 | + * |
|
891 | + */ |
|
892 | 892 | public function checkModeSRecent($modes) |
893 | 893 | { |
894 | 894 | global $globalDBdriver, $globalTimezone; |
@@ -915,19 +915,19 @@ discard block |
||
915 | 915 | $ident_result = $row['flightaware_id']; |
916 | 916 | } |
917 | 917 | return $ident_result; |
918 | - } |
|
918 | + } |
|
919 | 919 | |
920 | 920 | /** |
921 | - * Adds a new spotter data |
|
922 | - * |
|
923 | - * @param String $flightaware_id the ID from flightaware |
|
924 | - * @param String $ident the flight ident |
|
925 | - * @param String $aircraft_icao the aircraft type |
|
926 | - * @param String $departure_airport_icao the departure airport |
|
927 | - * @param String $arrival_airport_icao the arrival airport |
|
928 | - * @return String success or false |
|
929 | - * |
|
930 | - */ |
|
921 | + * Adds a new spotter data |
|
922 | + * |
|
923 | + * @param String $flightaware_id the ID from flightaware |
|
924 | + * @param String $ident the flight ident |
|
925 | + * @param String $aircraft_icao the aircraft type |
|
926 | + * @param String $departure_airport_icao the departure airport |
|
927 | + * @param String $arrival_airport_icao the arrival airport |
|
928 | + * @return String success or false |
|
929 | + * |
|
930 | + */ |
|
931 | 931 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
932 | 932 | { |
933 | 933 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1062,10 +1062,10 @@ discard block |
||
1062 | 1062 | $arrival_airport_country = ''; |
1063 | 1063 | |
1064 | 1064 | |
1065 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1066 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1067 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1068 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1065 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1066 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1067 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1068 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1069 | 1069 | |
1070 | 1070 | $query = ''; |
1071 | 1071 | if ($globalArchive) { |
@@ -1086,10 +1086,10 @@ discard block |
||
1086 | 1086 | return "error : ".$e->getMessage(); |
1087 | 1087 | } |
1088 | 1088 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1089 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1090 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1091 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1092 | - if ($globalDebug) echo $result.')'; |
|
1089 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1090 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1091 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1092 | + if ($globalDebug) echo $result.')'; |
|
1093 | 1093 | } |
1094 | 1094 | return "success"; |
1095 | 1095 |
@@ -5,23 +5,23 @@ discard block |
||
5 | 5 | $marine = false; |
6 | 6 | $usecoord = false; |
7 | 7 | if (isset($_GET['tracker'])) { |
8 | - $tracker = true; |
|
8 | + $tracker = true; |
|
9 | 9 | } |
10 | 10 | if (isset($_GET['marine'])) { |
11 | - $marine = true; |
|
11 | + $marine = true; |
|
12 | 12 | } |
13 | 13 | if ($tracker) { |
14 | - require_once('require/class.Tracker.php'); |
|
15 | - require_once('require/class.TrackerLive.php'); |
|
16 | - //require_once('require/class.TrackerArchive.php'); |
|
14 | + require_once('require/class.Tracker.php'); |
|
15 | + require_once('require/class.TrackerLive.php'); |
|
16 | + //require_once('require/class.TrackerArchive.php'); |
|
17 | 17 | } elseif ($marine) { |
18 | - require_once('require/class.Marine.php'); |
|
19 | - require_once('require/class.MarineLive.php'); |
|
20 | - //require_once('require/class.MarineArchive.php'); |
|
18 | + require_once('require/class.Marine.php'); |
|
19 | + require_once('require/class.MarineLive.php'); |
|
20 | + //require_once('require/class.MarineArchive.php'); |
|
21 | 21 | } else { |
22 | - require_once('require/class.Spotter.php'); |
|
23 | - require_once('require/class.SpotterLive.php'); |
|
24 | - require_once('require/class.SpotterArchive.php'); |
|
22 | + require_once('require/class.Spotter.php'); |
|
23 | + require_once('require/class.SpotterLive.php'); |
|
24 | + require_once('require/class.SpotterArchive.php'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | $begintime = microtime(true); |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | $Common = new Common(); |
42 | 42 | |
43 | 43 | if (isset($_GET['download'])) { |
44 | - if ($_GET['download'] == "true") |
|
45 | - { |
|
44 | + if ($_GET['download'] == "true") |
|
45 | + { |
|
46 | 46 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
47 | - } |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | header('Content-Type: text/javascript'); |
50 | 50 | |
@@ -497,17 +497,17 @@ discard block |
||
497 | 497 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
498 | 498 | |
499 | 499 | if ( |
500 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
501 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
500 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
501 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
504 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
505 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
506 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
507 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
508 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
509 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
510 | - ) { |
|
504 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
505 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
506 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
507 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
508 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
509 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
510 | + ) { |
|
511 | 511 | if ($tracker) { |
512 | 512 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
513 | 513 | } elseif ($marine) { |
@@ -592,26 +592,26 @@ discard block |
||
592 | 592 | } |
593 | 593 | |
594 | 594 | if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
595 | - $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
596 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
595 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
596 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
597 | 597 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
598 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
598 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
599 | 599 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
600 | 600 | if (isset($dairport[0]['latitude'])) { |
601 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
601 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
602 | 602 | } |
603 | - } |
|
604 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
603 | + } |
|
604 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
605 | 605 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
606 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
606 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
607 | 607 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
608 | 608 | if (isset($aairport[0]['latitude'])) { |
609 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
609 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
610 | 610 | } |
611 | - } |
|
612 | - $output_air .= ']}},'; |
|
613 | - $output .= $output_air; |
|
614 | - unset($output_air); |
|
611 | + } |
|
612 | + $output_air .= ']}},'; |
|
613 | + $output .= $output_air; |
|
614 | + unset($output_air); |
|
615 | 615 | } |
616 | 616 | } |
617 | 617 | $output = substr($output, 0, -1); |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | } |
10 | 10 | |
11 | 11 | /** |
12 | - * Get SQL query part for filter used |
|
13 | - * @param Array $filter the filter |
|
14 | - * @return Array the SQL part |
|
15 | - */ |
|
12 | + * Get SQL query part for filter used |
|
13 | + * @param Array $filter the filter |
|
14 | + * @return Array the SQL part |
|
15 | + */ |
|
16 | 16 | public function getFilter($filter = array(),$where = false,$and = false) { |
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
@@ -110,44 +110,44 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * Gets all the spotter information based on a particular callsign |
|
115 | - * |
|
116 | - * @return Array the spotter information |
|
117 | - * |
|
118 | - */ |
|
119 | - public function getLastArchiveMarineDataByIdent($ident) |
|
120 | - { |
|
113 | + /** |
|
114 | + * Gets all the spotter information based on a particular callsign |
|
115 | + * |
|
116 | + * @return Array the spotter information |
|
117 | + * |
|
118 | + */ |
|
119 | + public function getLastArchiveMarineDataByIdent($ident) |
|
120 | + { |
|
121 | 121 | $Marine = new Marine($this->db); |
122 | - date_default_timezone_set('UTC'); |
|
122 | + date_default_timezone_set('UTC'); |
|
123 | 123 | |
124 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
124 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
127 | 127 | |
128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
128 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
129 | 129 | |
130 | - return $spotter_array; |
|
131 | - } |
|
130 | + return $spotter_array; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | - /** |
|
135 | - * Gets last the spotter information based on a particular id |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
140 | - public function getLastArchiveMarineDataById($id) |
|
141 | - { |
|
142 | - $Marine = new Marine($this->db); |
|
143 | - date_default_timezone_set('UTC'); |
|
144 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
134 | + /** |
|
135 | + * Gets last the spotter information based on a particular id |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | + public function getLastArchiveMarineDataById($id) |
|
141 | + { |
|
142 | + $Marine = new Marine($this->db); |
|
143 | + date_default_timezone_set('UTC'); |
|
144 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
148 | 148 | |
149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
150 | - /* |
|
150 | + /* |
|
151 | 151 | try { |
152 | 152 | $Connection = new Connection(); |
153 | 153 | $sth = Connection->$db->prepare($query); |
@@ -157,232 +157,232 @@ discard block |
||
157 | 157 | } |
158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
159 | 159 | */ |
160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | - |
|
162 | - return $spotter_array; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Gets all the spotter information based on a particular id |
|
167 | - * |
|
168 | - * @return Array the spotter information |
|
169 | - * |
|
170 | - */ |
|
171 | - public function getAllArchiveMarineDataById($id) |
|
160 | + $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | + |
|
162 | + return $spotter_array; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Gets all the spotter information based on a particular id |
|
167 | + * |
|
168 | + * @return Array the spotter information |
|
169 | + * |
|
170 | + */ |
|
171 | + public function getAllArchiveMarineDataById($id) |
|
172 | 172 | { |
173 | - date_default_timezone_set('UTC'); |
|
174 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
173 | + date_default_timezone_set('UTC'); |
|
174 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
176 | 176 | |
177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
178 | 178 | |
179 | - try { |
|
180 | - $sth = $this->db->prepare($query); |
|
181 | - $sth->execute(array(':id' => $id)); |
|
182 | - } catch(PDOException $e) { |
|
183 | - echo $e->getMessage(); |
|
184 | - die; |
|
185 | - } |
|
186 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | - |
|
188 | - return $spotter_array; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Gets coordinate & time spotter information based on a particular id |
|
193 | - * |
|
194 | - * @return Array the spotter information |
|
195 | - * |
|
196 | - */ |
|
197 | - public function getCoordArchiveMarineDataById($id) |
|
198 | - { |
|
199 | - date_default_timezone_set('UTC'); |
|
200 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
179 | + try { |
|
180 | + $sth = $this->db->prepare($query); |
|
181 | + $sth->execute(array(':id' => $id)); |
|
182 | + } catch(PDOException $e) { |
|
183 | + echo $e->getMessage(); |
|
184 | + die; |
|
185 | + } |
|
186 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | + |
|
188 | + return $spotter_array; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Gets coordinate & time spotter information based on a particular id |
|
193 | + * |
|
194 | + * @return Array the spotter information |
|
195 | + * |
|
196 | + */ |
|
197 | + public function getCoordArchiveMarineDataById($id) |
|
198 | + { |
|
199 | + date_default_timezone_set('UTC'); |
|
200 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
202 | 202 | |
203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
204 | 204 | |
205 | - try { |
|
206 | - $sth = $this->db->prepare($query); |
|
207 | - $sth->execute(array(':id' => $id)); |
|
208 | - } catch(PDOException $e) { |
|
209 | - echo $e->getMessage(); |
|
210 | - die; |
|
211 | - } |
|
212 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | + try { |
|
206 | + $sth = $this->db->prepare($query); |
|
207 | + $sth->execute(array(':id' => $id)); |
|
208 | + } catch(PDOException $e) { |
|
209 | + echo $e->getMessage(); |
|
210 | + die; |
|
211 | + } |
|
212 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
213 | 213 | |
214 | - return $spotter_array; |
|
215 | - } |
|
214 | + return $spotter_array; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * Gets altitude information based on a particular callsign |
|
220 | - * |
|
221 | - * @return Array the spotter information |
|
222 | - * |
|
223 | - */ |
|
224 | - public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | - { |
|
218 | + /** |
|
219 | + * Gets altitude information based on a particular callsign |
|
220 | + * |
|
221 | + * @return Array the spotter information |
|
222 | + * |
|
223 | + */ |
|
224 | + public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | + { |
|
226 | 226 | |
227 | - date_default_timezone_set('UTC'); |
|
227 | + date_default_timezone_set('UTC'); |
|
228 | 228 | |
229 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
229 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
231 | 231 | |
232 | - try { |
|
233 | - $sth = $this->db->prepare($query); |
|
234 | - $sth->execute(array(':ident' => $ident)); |
|
235 | - } catch(PDOException $e) { |
|
236 | - echo $e->getMessage(); |
|
237 | - die; |
|
238 | - } |
|
239 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
232 | + try { |
|
233 | + $sth = $this->db->prepare($query); |
|
234 | + $sth->execute(array(':ident' => $ident)); |
|
235 | + } catch(PDOException $e) { |
|
236 | + echo $e->getMessage(); |
|
237 | + die; |
|
238 | + } |
|
239 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
240 | 240 | |
241 | - return $spotter_array; |
|
242 | - } |
|
241 | + return $spotter_array; |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * Gets altitude information based on a particular id |
|
246 | - * |
|
247 | - * @return Array the spotter information |
|
248 | - * |
|
249 | - */ |
|
250 | - public function getAltitudeArchiveMarineDataById($id) |
|
251 | - { |
|
244 | + /** |
|
245 | + * Gets altitude information based on a particular id |
|
246 | + * |
|
247 | + * @return Array the spotter information |
|
248 | + * |
|
249 | + */ |
|
250 | + public function getAltitudeArchiveMarineDataById($id) |
|
251 | + { |
|
252 | 252 | |
253 | - date_default_timezone_set('UTC'); |
|
253 | + date_default_timezone_set('UTC'); |
|
254 | 254 | |
255 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
255 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
257 | 257 | |
258 | - try { |
|
259 | - $sth = $this->db->prepare($query); |
|
260 | - $sth->execute(array(':id' => $id)); |
|
261 | - } catch(PDOException $e) { |
|
262 | - echo $e->getMessage(); |
|
263 | - die; |
|
264 | - } |
|
265 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
258 | + try { |
|
259 | + $sth = $this->db->prepare($query); |
|
260 | + $sth->execute(array(':id' => $id)); |
|
261 | + } catch(PDOException $e) { |
|
262 | + echo $e->getMessage(); |
|
263 | + die; |
|
264 | + } |
|
265 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
266 | 266 | |
267 | - return $spotter_array; |
|
268 | - } |
|
267 | + return $spotter_array; |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Gets altitude & speed information based on a particular id |
|
272 | - * |
|
273 | - * @return Array the spotter information |
|
274 | - * |
|
275 | - */ |
|
276 | - public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | - { |
|
270 | + /** |
|
271 | + * Gets altitude & speed information based on a particular id |
|
272 | + * |
|
273 | + * @return Array the spotter information |
|
274 | + * |
|
275 | + */ |
|
276 | + public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | + { |
|
278 | 278 | |
279 | - date_default_timezone_set('UTC'); |
|
279 | + date_default_timezone_set('UTC'); |
|
280 | 280 | |
281 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
281 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
283 | 283 | |
284 | - try { |
|
285 | - $sth = $this->db->prepare($query); |
|
286 | - $sth->execute(array(':id' => $id)); |
|
287 | - } catch(PDOException $e) { |
|
288 | - echo $e->getMessage(); |
|
289 | - die; |
|
290 | - } |
|
291 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | + try { |
|
285 | + $sth = $this->db->prepare($query); |
|
286 | + $sth->execute(array(':id' => $id)); |
|
287 | + } catch(PDOException $e) { |
|
288 | + echo $e->getMessage(); |
|
289 | + die; |
|
290 | + } |
|
291 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
292 | 292 | |
293 | - return $spotter_array; |
|
294 | - } |
|
293 | + return $spotter_array; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | - /** |
|
298 | - * Gets altitude information based on a particular callsign |
|
299 | - * |
|
300 | - * @return Array the spotter information |
|
301 | - * |
|
302 | - */ |
|
303 | - public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | - { |
|
297 | + /** |
|
298 | + * Gets altitude information based on a particular callsign |
|
299 | + * |
|
300 | + * @return Array the spotter information |
|
301 | + * |
|
302 | + */ |
|
303 | + public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | + { |
|
305 | 305 | |
306 | - date_default_timezone_set('UTC'); |
|
306 | + date_default_timezone_set('UTC'); |
|
307 | 307 | |
308 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
308 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
311 | 311 | |
312 | - try { |
|
313 | - $sth = $this->db->prepare($query); |
|
314 | - $sth->execute(array(':ident' => $ident)); |
|
315 | - } catch(PDOException $e) { |
|
316 | - echo $e->getMessage(); |
|
317 | - die; |
|
318 | - } |
|
319 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
312 | + try { |
|
313 | + $sth = $this->db->prepare($query); |
|
314 | + $sth->execute(array(':ident' => $ident)); |
|
315 | + } catch(PDOException $e) { |
|
316 | + echo $e->getMessage(); |
|
317 | + die; |
|
318 | + } |
|
319 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
320 | 320 | |
321 | - return $spotter_array; |
|
322 | - } |
|
321 | + return $spotter_array; |
|
322 | + } |
|
323 | 323 | |
324 | 324 | |
325 | 325 | |
326 | - /** |
|
327 | - * Gets all the archive spotter information |
|
328 | - * |
|
329 | - * @return Array the spotter information |
|
330 | - * |
|
331 | - */ |
|
332 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
333 | - { |
|
334 | - $Marine = new Marine($this->db); |
|
335 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
336 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
326 | + /** |
|
327 | + * Gets all the archive spotter information |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | + public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
333 | + { |
|
334 | + $Marine = new Marine($this->db); |
|
335 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
336 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
337 | 337 | |
338 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
338 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
339 | 339 | |
340 | - return $spotter_array; |
|
341 | - } |
|
340 | + return $spotter_array; |
|
341 | + } |
|
342 | 342 | |
343 | - public function deleteMarineArchiveTrackData() |
|
344 | - { |
|
343 | + public function deleteMarineArchiveTrackData() |
|
344 | + { |
|
345 | 345 | global $globalArchiveKeepTrackMonths; |
346 | - date_default_timezone_set('UTC'); |
|
346 | + date_default_timezone_set('UTC'); |
|
347 | 347 | $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
348 | - try { |
|
349 | - $sth = $this->db->prepare($query); |
|
350 | - $sth->execute(); |
|
351 | - } catch(PDOException $e) { |
|
352 | - echo $e->getMessage(); |
|
353 | - die; |
|
354 | - } |
|
348 | + try { |
|
349 | + $sth = $this->db->prepare($query); |
|
350 | + $sth->execute(); |
|
351 | + } catch(PDOException $e) { |
|
352 | + echo $e->getMessage(); |
|
353 | + die; |
|
354 | + } |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
358 | - * Gets Minimal Live Marine data |
|
359 | - * |
|
360 | - * @return Array the spotter information |
|
361 | - * |
|
362 | - */ |
|
363 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
364 | - { |
|
365 | - global $globalDBdriver, $globalLiveInterval; |
|
366 | - date_default_timezone_set('UTC'); |
|
367 | - |
|
368 | - $filter_query = ''; |
|
369 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
370 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
371 | - } |
|
372 | - // Use spotter_output also ? |
|
373 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
374 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
375 | - } |
|
376 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
377 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
378 | - } |
|
379 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
380 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
381 | - } |
|
358 | + * Gets Minimal Live Marine data |
|
359 | + * |
|
360 | + * @return Array the spotter information |
|
361 | + * |
|
362 | + */ |
|
363 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
364 | + { |
|
365 | + global $globalDBdriver, $globalLiveInterval; |
|
366 | + date_default_timezone_set('UTC'); |
|
367 | + |
|
368 | + $filter_query = ''; |
|
369 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
370 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
371 | + } |
|
372 | + // Use spotter_output also ? |
|
373 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
374 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
375 | + } |
|
376 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
377 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
378 | + } |
|
379 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
380 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
381 | + } |
|
382 | 382 | |
383 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
384 | - if ($globalDBdriver == 'mysql') { |
|
385 | - /* |
|
383 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
384 | + if ($globalDBdriver == 'mysql') { |
|
385 | + /* |
|
386 | 386 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
387 | 387 | FROM marine_archive |
388 | 388 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -401,56 +401,56 @@ discard block |
||
401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
402 | 402 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
403 | 403 | '.$filter_query.' ORDER BY fammarine_id'; |
404 | - } else { |
|
405 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
406 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
404 | + } else { |
|
405 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
406 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
407 | 407 | FROM marine_archive |
408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
409 | 409 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
410 | 410 | '.$filter_query.' ORDER BY fammarine_id'; |
411 | - } |
|
412 | - //echo $query; |
|
413 | - try { |
|
414 | - $sth = $this->db->prepare($query); |
|
415 | - $sth->execute(); |
|
416 | - } catch(PDOException $e) { |
|
417 | - echo $e->getMessage(); |
|
418 | - die; |
|
419 | - } |
|
420 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
411 | + } |
|
412 | + //echo $query; |
|
413 | + try { |
|
414 | + $sth = $this->db->prepare($query); |
|
415 | + $sth->execute(); |
|
416 | + } catch(PDOException $e) { |
|
417 | + echo $e->getMessage(); |
|
418 | + die; |
|
419 | + } |
|
420 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
421 | 421 | |
422 | - return $spotter_array; |
|
423 | - } |
|
422 | + return $spotter_array; |
|
423 | + } |
|
424 | 424 | |
425 | 425 | /** |
426 | - * Gets Minimal Live Marine data |
|
427 | - * |
|
428 | - * @return Array the spotter information |
|
429 | - * |
|
430 | - */ |
|
431 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
432 | - { |
|
433 | - global $globalDBdriver, $globalLiveInterval; |
|
434 | - date_default_timezone_set('UTC'); |
|
435 | - |
|
436 | - $filter_query = ''; |
|
437 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
438 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
439 | - } |
|
440 | - // Should use spotter_output also ? |
|
441 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
442 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
443 | - } |
|
444 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
445 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
446 | - } |
|
447 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
448 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
449 | - } |
|
426 | + * Gets Minimal Live Marine data |
|
427 | + * |
|
428 | + * @return Array the spotter information |
|
429 | + * |
|
430 | + */ |
|
431 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
432 | + { |
|
433 | + global $globalDBdriver, $globalLiveInterval; |
|
434 | + date_default_timezone_set('UTC'); |
|
435 | + |
|
436 | + $filter_query = ''; |
|
437 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
438 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
439 | + } |
|
440 | + // Should use spotter_output also ? |
|
441 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
442 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
443 | + } |
|
444 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
445 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
446 | + } |
|
447 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
448 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
449 | + } |
|
450 | 450 | |
451 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
452 | - if ($globalDBdriver == 'mysql') { |
|
453 | - /* |
|
451 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
452 | + if ($globalDBdriver == 'mysql') { |
|
453 | + /* |
|
454 | 454 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
455 | 455 | FROM marine_archive |
456 | 456 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -461,95 +461,95 @@ discard block |
||
461 | 461 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
462 | 462 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
463 | 463 | |
464 | - } else { |
|
465 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
466 | - /* |
|
464 | + } else { |
|
465 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
466 | + /* |
|
467 | 467 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
468 | 468 | FROM marine_archive_output |
469 | 469 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
470 | 470 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
471 | 471 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
472 | 472 | */ |
473 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
473 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
474 | 474 | FROM marine_archive_output |
475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
476 | 476 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
477 | 477 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
478 | 478 | // .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
479 | 479 | |
480 | - } |
|
481 | - //echo $query; |
|
482 | - try { |
|
483 | - $sth = $this->db->prepare($query); |
|
484 | - $sth->execute(); |
|
485 | - } catch(PDOException $e) { |
|
486 | - echo $e->getMessage(); |
|
487 | - die; |
|
488 | - } |
|
489 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
480 | + } |
|
481 | + //echo $query; |
|
482 | + try { |
|
483 | + $sth = $this->db->prepare($query); |
|
484 | + $sth->execute(); |
|
485 | + } catch(PDOException $e) { |
|
486 | + echo $e->getMessage(); |
|
487 | + die; |
|
488 | + } |
|
489 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
490 | 490 | |
491 | - return $spotter_array; |
|
492 | - } |
|
491 | + return $spotter_array; |
|
492 | + } |
|
493 | 493 | |
494 | 494 | /** |
495 | - * Gets count Live Marine data |
|
496 | - * |
|
497 | - * @return Array the spotter information |
|
498 | - * |
|
499 | - */ |
|
500 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
501 | - { |
|
502 | - global $globalDBdriver, $globalLiveInterval; |
|
503 | - date_default_timezone_set('UTC'); |
|
504 | - |
|
505 | - $filter_query = ''; |
|
506 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
507 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
508 | - } |
|
509 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
510 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
511 | - } |
|
512 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
513 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
514 | - } |
|
515 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
516 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
517 | - } |
|
495 | + * Gets count Live Marine data |
|
496 | + * |
|
497 | + * @return Array the spotter information |
|
498 | + * |
|
499 | + */ |
|
500 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
501 | + { |
|
502 | + global $globalDBdriver, $globalLiveInterval; |
|
503 | + date_default_timezone_set('UTC'); |
|
518 | 504 | |
519 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
520 | - if ($globalDBdriver == 'mysql') { |
|
505 | + $filter_query = ''; |
|
506 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
507 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
508 | + } |
|
509 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
510 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
511 | + } |
|
512 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
513 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
514 | + } |
|
515 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
516 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
517 | + } |
|
518 | + |
|
519 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
520 | + if ($globalDBdriver == 'mysql') { |
|
521 | 521 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
522 | 522 | FROM marine_archive l |
523 | 523 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
524 | - } else { |
|
524 | + } else { |
|
525 | 525 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
526 | - } |
|
527 | - //echo $query; |
|
528 | - try { |
|
529 | - $sth = $this->db->prepare($query); |
|
530 | - $sth->execute(); |
|
531 | - } catch(PDOException $e) { |
|
532 | - echo $e->getMessage(); |
|
533 | - die; |
|
534 | - } |
|
526 | + } |
|
527 | + //echo $query; |
|
528 | + try { |
|
529 | + $sth = $this->db->prepare($query); |
|
530 | + $sth->execute(); |
|
531 | + } catch(PDOException $e) { |
|
532 | + echo $e->getMessage(); |
|
533 | + die; |
|
534 | + } |
|
535 | 535 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
536 | 536 | $sth->closeCursor(); |
537 | - return $result['nb']; |
|
537 | + return $result['nb']; |
|
538 | 538 | |
539 | - } |
|
539 | + } |
|
540 | 540 | |
541 | 541 | |
542 | 542 | |
543 | 543 | // marine_archive_output |
544 | 544 | |
545 | - /** |
|
546 | - * Gets all the spotter information |
|
547 | - * |
|
548 | - * @return Array the spotter information |
|
549 | - * |
|
550 | - */ |
|
551 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
552 | - { |
|
545 | + /** |
|
546 | + * Gets all the spotter information |
|
547 | + * |
|
548 | + * @return Array the spotter information |
|
549 | + * |
|
550 | + */ |
|
551 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
552 | + { |
|
553 | 553 | global $globalTimezone, $globalDBdriver; |
554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php'); |
555 | 555 | $Translation = new Translation(); |
@@ -563,159 +563,159 @@ discard block |
||
563 | 563 | $filter_query = $this->getFilter($filters); |
564 | 564 | if ($q != "") |
565 | 565 | { |
566 | - if (!is_string($q)) |
|
567 | - { |
|
566 | + if (!is_string($q)) |
|
567 | + { |
|
568 | 568 | return false; |
569 | - } else { |
|
569 | + } else { |
|
570 | 570 | |
571 | 571 | $q_array = explode(" ", $q); |
572 | 572 | |
573 | 573 | foreach ($q_array as $q_item){ |
574 | - $additional_query .= " AND ("; |
|
575 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
576 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
577 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
578 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
579 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
580 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
594 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
595 | - $translate = $Translation->ident2icao($q_item); |
|
596 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
597 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
598 | - $additional_query .= ")"; |
|
574 | + $additional_query .= " AND ("; |
|
575 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
576 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
577 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
578 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
579 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
580 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
594 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
595 | + $translate = $Translation->ident2icao($q_item); |
|
596 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
597 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
598 | + $additional_query .= ")"; |
|
599 | + } |
|
599 | 600 | } |
600 | - } |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | if ($registration != "") |
604 | 604 | { |
605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
606 | - if (!is_string($registration)) |
|
607 | - { |
|
605 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
606 | + if (!is_string($registration)) |
|
607 | + { |
|
608 | 608 | return false; |
609 | - } else { |
|
609 | + } else { |
|
610 | 610 | $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
611 | - } |
|
611 | + } |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | if ($aircraft_icao != "") |
615 | 615 | { |
616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
617 | - if (!is_string($aircraft_icao)) |
|
618 | - { |
|
616 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
617 | + if (!is_string($aircraft_icao)) |
|
618 | + { |
|
619 | 619 | return false; |
620 | - } else { |
|
620 | + } else { |
|
621 | 621 | $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
622 | - } |
|
622 | + } |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | if ($aircraft_manufacturer != "") |
626 | 626 | { |
627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
628 | - if (!is_string($aircraft_manufacturer)) |
|
629 | - { |
|
627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
628 | + if (!is_string($aircraft_manufacturer)) |
|
629 | + { |
|
630 | 630 | return false; |
631 | - } else { |
|
631 | + } else { |
|
632 | 632 | $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
633 | - } |
|
633 | + } |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | if ($highlights == "true") |
637 | 637 | { |
638 | - if (!is_string($highlights)) |
|
639 | - { |
|
638 | + if (!is_string($highlights)) |
|
639 | + { |
|
640 | 640 | return false; |
641 | - } else { |
|
641 | + } else { |
|
642 | 642 | $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
643 | - } |
|
643 | + } |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | if ($airline_icao != "") |
647 | 647 | { |
648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
649 | - if (!is_string($airline_icao)) |
|
650 | - { |
|
648 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
649 | + if (!is_string($airline_icao)) |
|
650 | + { |
|
651 | 651 | return false; |
652 | - } else { |
|
652 | + } else { |
|
653 | 653 | $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
654 | - } |
|
654 | + } |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | if ($airline_country != "") |
658 | 658 | { |
659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
660 | - if (!is_string($airline_country)) |
|
661 | - { |
|
659 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
660 | + if (!is_string($airline_country)) |
|
661 | + { |
|
662 | 662 | return false; |
663 | - } else { |
|
663 | + } else { |
|
664 | 664 | $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
665 | - } |
|
665 | + } |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | if ($airline_type != "") |
669 | 669 | { |
670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
671 | - if (!is_string($airline_type)) |
|
672 | - { |
|
670 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
671 | + if (!is_string($airline_type)) |
|
672 | + { |
|
673 | 673 | return false; |
674 | - } else { |
|
674 | + } else { |
|
675 | 675 | if ($airline_type == "passenger") |
676 | 676 | { |
677 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
677 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
678 | 678 | } |
679 | 679 | if ($airline_type == "cargo") |
680 | 680 | { |
681 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
681 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
682 | 682 | } |
683 | 683 | if ($airline_type == "military") |
684 | 684 | { |
685 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
685 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
686 | + } |
|
686 | 687 | } |
687 | - } |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | if ($airport != "") |
691 | 691 | { |
692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
693 | - if (!is_string($airport)) |
|
694 | - { |
|
692 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
693 | + if (!is_string($airport)) |
|
694 | + { |
|
695 | 695 | return false; |
696 | - } else { |
|
696 | + } else { |
|
697 | 697 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
698 | - } |
|
698 | + } |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | if ($airport_country != "") |
702 | 702 | { |
703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
704 | - if (!is_string($airport_country)) |
|
705 | - { |
|
703 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
704 | + if (!is_string($airport_country)) |
|
705 | + { |
|
706 | 706 | return false; |
707 | - } else { |
|
707 | + } else { |
|
708 | 708 | $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
709 | - } |
|
709 | + } |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | if ($callsign != "") |
713 | 713 | { |
714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
715 | - if (!is_string($callsign)) |
|
716 | - { |
|
714 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
715 | + if (!is_string($callsign)) |
|
716 | + { |
|
717 | 717 | return false; |
718 | - } else { |
|
718 | + } else { |
|
719 | 719 | $translate = $Translation->ident2icao($callsign); |
720 | 720 | if ($translate != $callsign) { |
721 | 721 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
@@ -723,99 +723,99 @@ discard block |
||
723 | 723 | } else { |
724 | 724 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
725 | 725 | } |
726 | - } |
|
726 | + } |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | if ($owner != "") |
730 | 730 | { |
731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
732 | - if (!is_string($owner)) |
|
733 | - { |
|
731 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
732 | + if (!is_string($owner)) |
|
733 | + { |
|
734 | 734 | return false; |
735 | - } else { |
|
735 | + } else { |
|
736 | 736 | $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
737 | - } |
|
737 | + } |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | if ($pilot_name != "") |
741 | 741 | { |
742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
743 | - if (!is_string($pilot_name)) |
|
744 | - { |
|
742 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
743 | + if (!is_string($pilot_name)) |
|
744 | + { |
|
745 | 745 | return false; |
746 | - } else { |
|
746 | + } else { |
|
747 | 747 | $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
748 | - } |
|
748 | + } |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | if ($pilot_id != "") |
752 | 752 | { |
753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
754 | - if (!is_string($pilot_id)) |
|
755 | - { |
|
753 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
754 | + if (!is_string($pilot_id)) |
|
755 | + { |
|
756 | 756 | return false; |
757 | - } else { |
|
757 | + } else { |
|
758 | 758 | $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
759 | - } |
|
759 | + } |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | if ($departure_airport_route != "") |
763 | 763 | { |
764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
765 | - if (!is_string($departure_airport_route)) |
|
766 | - { |
|
764 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
765 | + if (!is_string($departure_airport_route)) |
|
766 | + { |
|
767 | 767 | return false; |
768 | - } else { |
|
768 | + } else { |
|
769 | 769 | $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
770 | - } |
|
770 | + } |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | if ($arrival_airport_route != "") |
774 | 774 | { |
775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
776 | - if (!is_string($arrival_airport_route)) |
|
777 | - { |
|
775 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
776 | + if (!is_string($arrival_airport_route)) |
|
777 | + { |
|
778 | 778 | return false; |
779 | - } else { |
|
779 | + } else { |
|
780 | 780 | $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
781 | - } |
|
781 | + } |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | if ($altitude != "") |
785 | 785 | { |
786 | - $altitude_array = explode(",", $altitude); |
|
786 | + $altitude_array = explode(",", $altitude); |
|
787 | 787 | |
788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
790 | 790 | |
791 | 791 | |
792 | - if ($altitude_array[1] != "") |
|
793 | - { |
|
792 | + if ($altitude_array[1] != "") |
|
793 | + { |
|
794 | 794 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
795 | 795 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
796 | 796 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
797 | - } else { |
|
797 | + } else { |
|
798 | 798 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
799 | 799 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
800 | - } |
|
800 | + } |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | if ($date_posted != "") |
804 | 804 | { |
805 | - $date_array = explode(",", $date_posted); |
|
805 | + $date_array = explode(",", $date_posted); |
|
806 | 806 | |
807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
807 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
808 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
809 | 809 | |
810 | - if ($globalTimezone != '') { |
|
810 | + if ($globalTimezone != '') { |
|
811 | 811 | date_default_timezone_set($globalTimezone); |
812 | 812 | $datetime = new DateTime(); |
813 | 813 | $offset = $datetime->format('P'); |
814 | - } else $offset = '+00:00'; |
|
814 | + } else $offset = '+00:00'; |
|
815 | 815 | |
816 | 816 | |
817 | - if ($date_array[1] != "") |
|
818 | - { |
|
817 | + if ($date_array[1] != "") |
|
818 | + { |
|
819 | 819 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
820 | 820 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
821 | 821 | if ($globalDBdriver == 'mysql') { |
@@ -823,28 +823,28 @@ discard block |
||
823 | 823 | } else { |
824 | 824 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
825 | 825 | } |
826 | - } else { |
|
826 | + } else { |
|
827 | 827 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
828 | - if ($globalDBdriver == 'mysql') { |
|
828 | + if ($globalDBdriver == 'mysql') { |
|
829 | 829 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
830 | 830 | } else { |
831 | 831 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
832 | 832 | } |
833 | - } |
|
833 | + } |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | if ($limit != "") |
837 | 837 | { |
838 | - $limit_array = explode(",", $limit); |
|
838 | + $limit_array = explode(",", $limit); |
|
839 | 839 | |
840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
841 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
842 | 842 | |
843 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
844 | - { |
|
843 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
844 | + { |
|
845 | 845 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
846 | 846 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
847 | - } |
|
847 | + } |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | |
@@ -875,33 +875,33 @@ discard block |
||
875 | 875 | $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
876 | 876 | |
877 | 877 | return $spotter_array; |
878 | - } |
|
878 | + } |
|
879 | 879 | |
880 | - public function deleteMarineArchiveData() |
|
881 | - { |
|
880 | + public function deleteMarineArchiveData() |
|
881 | + { |
|
882 | 882 | global $globalArchiveKeepMonths, $globalDBdriver; |
883 | - date_default_timezone_set('UTC'); |
|
884 | - if ($globalDBdriver == 'mysql') { |
|
883 | + date_default_timezone_set('UTC'); |
|
884 | + if ($globalDBdriver == 'mysql') { |
|
885 | 885 | $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
886 | 886 | } else { |
887 | 887 | $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
888 | 888 | } |
889 | - try { |
|
890 | - $sth = $this->db->prepare($query); |
|
891 | - $sth->execute(); |
|
892 | - } catch(PDOException $e) { |
|
893 | - return "error"; |
|
894 | - } |
|
889 | + try { |
|
890 | + $sth = $this->db->prepare($query); |
|
891 | + $sth->execute(); |
|
892 | + } catch(PDOException $e) { |
|
893 | + return "error"; |
|
894 | + } |
|
895 | 895 | } |
896 | 896 | |
897 | - /** |
|
898 | - * Gets all the spotter information based on the callsign |
|
899 | - * |
|
900 | - * @return Array the spotter information |
|
901 | - * |
|
902 | - */ |
|
903 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
904 | - { |
|
897 | + /** |
|
898 | + * Gets all the spotter information based on the callsign |
|
899 | + * |
|
900 | + * @return Array the spotter information |
|
901 | + * |
|
902 | + */ |
|
903 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
904 | + { |
|
905 | 905 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
906 | 906 | |
907 | 907 | date_default_timezone_set('UTC'); |
@@ -913,35 +913,35 @@ discard block |
||
913 | 913 | |
914 | 914 | if ($ident != "") |
915 | 915 | { |
916 | - if (!is_string($ident)) |
|
917 | - { |
|
916 | + if (!is_string($ident)) |
|
917 | + { |
|
918 | 918 | return false; |
919 | - } else { |
|
919 | + } else { |
|
920 | 920 | $additional_query = " AND (marine_archive_output.ident = :ident)"; |
921 | 921 | $query_values = array(':ident' => $ident); |
922 | - } |
|
922 | + } |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | if ($limit != "") |
926 | 926 | { |
927 | - $limit_array = explode(",", $limit); |
|
927 | + $limit_array = explode(",", $limit); |
|
928 | 928 | |
929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
930 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
931 | 931 | |
932 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
933 | - { |
|
932 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
933 | + { |
|
934 | 934 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
935 | 935 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
936 | - } |
|
936 | + } |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | if ($sort != "") |
940 | 940 | { |
941 | - $search_orderby_array = $Marine->getOrderBy(); |
|
942 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
941 | + $search_orderby_array = $Marine->getOrderBy(); |
|
942 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
943 | 943 | } else { |
944 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
944 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -949,17 +949,17 @@ discard block |
||
949 | 949 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
950 | 950 | |
951 | 951 | return $spotter_array; |
952 | - } |
|
952 | + } |
|
953 | 953 | |
954 | 954 | |
955 | - /** |
|
956 | - * Gets all the spotter information based on the owner |
|
957 | - * |
|
958 | - * @return Array the spotter information |
|
959 | - * |
|
960 | - */ |
|
961 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
962 | - { |
|
955 | + /** |
|
956 | + * Gets all the spotter information based on the owner |
|
957 | + * |
|
958 | + * @return Array the spotter information |
|
959 | + * |
|
960 | + */ |
|
961 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
962 | + { |
|
963 | 963 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
964 | 964 | |
965 | 965 | date_default_timezone_set('UTC'); |
@@ -972,35 +972,35 @@ discard block |
||
972 | 972 | |
973 | 973 | if ($owner != "") |
974 | 974 | { |
975 | - if (!is_string($owner)) |
|
976 | - { |
|
975 | + if (!is_string($owner)) |
|
976 | + { |
|
977 | 977 | return false; |
978 | - } else { |
|
978 | + } else { |
|
979 | 979 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
980 | 980 | $query_values = array(':owner' => $owner); |
981 | - } |
|
981 | + } |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | if ($limit != "") |
985 | 985 | { |
986 | - $limit_array = explode(",", $limit); |
|
986 | + $limit_array = explode(",", $limit); |
|
987 | 987 | |
988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
989 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
990 | 990 | |
991 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
992 | - { |
|
991 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
992 | + { |
|
993 | 993 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
994 | 994 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
995 | - } |
|
995 | + } |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | if ($sort != "") |
999 | 999 | { |
1000 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1001 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1000 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1001 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1002 | 1002 | } else { |
1003 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1003 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1008,16 +1008,16 @@ discard block |
||
1008 | 1008 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1009 | 1009 | |
1010 | 1010 | return $spotter_array; |
1011 | - } |
|
1012 | - |
|
1013 | - /** |
|
1014 | - * Gets all the spotter information based on the pilot |
|
1015 | - * |
|
1016 | - * @return Array the spotter information |
|
1017 | - * |
|
1018 | - */ |
|
1019 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1020 | - { |
|
1011 | + } |
|
1012 | + |
|
1013 | + /** |
|
1014 | + * Gets all the spotter information based on the pilot |
|
1015 | + * |
|
1016 | + * @return Array the spotter information |
|
1017 | + * |
|
1018 | + */ |
|
1019 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1020 | + { |
|
1021 | 1021 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
1022 | 1022 | |
1023 | 1023 | date_default_timezone_set('UTC'); |
@@ -1036,24 +1036,24 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | if ($limit != "") |
1038 | 1038 | { |
1039 | - $limit_array = explode(",", $limit); |
|
1039 | + $limit_array = explode(",", $limit); |
|
1040 | 1040 | |
1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1043 | 1043 | |
1044 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1045 | - { |
|
1044 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1045 | + { |
|
1046 | 1046 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1047 | 1047 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1048 | - } |
|
1048 | + } |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | if ($sort != "") |
1052 | 1052 | { |
1053 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1054 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1053 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1054 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1055 | 1055 | } else { |
1056 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1056 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1061,16 +1061,16 @@ discard block |
||
1061 | 1061 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1062 | 1062 | |
1063 | 1063 | return $spotter_array; |
1064 | - } |
|
1065 | - |
|
1066 | - /** |
|
1067 | - * Gets all number of flight over countries |
|
1068 | - * |
|
1069 | - * @return Array the airline country list |
|
1070 | - * |
|
1071 | - */ |
|
1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1073 | - { |
|
1064 | + } |
|
1065 | + |
|
1066 | + /** |
|
1067 | + * Gets all number of flight over countries |
|
1068 | + * |
|
1069 | + * @return Array the airline country list |
|
1070 | + * |
|
1071 | + */ |
|
1072 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1073 | + { |
|
1074 | 1074 | global $globalDBdriver; |
1075 | 1075 | /* |
1076 | 1076 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1080,14 +1080,14 @@ discard block |
||
1080 | 1080 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1081 | 1081 | FROM countries c, marine_archive s |
1082 | 1082 | WHERE c.iso2 = s.over_country "; |
1083 | - if ($olderthanmonths > 0) { |
|
1084 | - if ($globalDBdriver == 'mysql') { |
|
1083 | + if ($olderthanmonths > 0) { |
|
1084 | + if ($globalDBdriver == 'mysql') { |
|
1085 | 1085 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1086 | 1086 | } else { |
1087 | 1087 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1088 | 1088 | } |
1089 | 1089 | } |
1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1090 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1091 | 1091 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1092 | 1092 | if ($limit) $query .= " LIMIT 0,10"; |
1093 | 1093 | |
@@ -1100,23 +1100,23 @@ discard block |
||
1100 | 1100 | |
1101 | 1101 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1102 | 1102 | { |
1103 | - $temp_array['flight_count'] = $row['nb']; |
|
1104 | - $temp_array['flight_country'] = $row['name']; |
|
1105 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1106 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1107 | - $flight_array[] = $temp_array; |
|
1103 | + $temp_array['flight_count'] = $row['nb']; |
|
1104 | + $temp_array['flight_country'] = $row['name']; |
|
1105 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1106 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1107 | + $flight_array[] = $temp_array; |
|
1108 | 1108 | } |
1109 | 1109 | return $flight_array; |
1110 | - } |
|
1111 | - |
|
1112 | - /** |
|
1113 | - * Gets all number of flight over countries |
|
1114 | - * |
|
1115 | - * @return Array the airline country list |
|
1116 | - * |
|
1117 | - */ |
|
1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1119 | - { |
|
1110 | + } |
|
1111 | + |
|
1112 | + /** |
|
1113 | + * Gets all number of flight over countries |
|
1114 | + * |
|
1115 | + * @return Array the airline country list |
|
1116 | + * |
|
1117 | + */ |
|
1118 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1119 | + { |
|
1120 | 1120 | global $globalDBdriver; |
1121 | 1121 | /* |
1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1126,14 +1126,14 @@ discard block |
||
1126 | 1126 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1127 | 1127 | FROM countries c, marine_archive s, spotter_output o |
1128 | 1128 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
1129 | - if ($olderthanmonths > 0) { |
|
1130 | - if ($globalDBdriver == 'mysql') { |
|
1129 | + if ($olderthanmonths > 0) { |
|
1130 | + if ($globalDBdriver == 'mysql') { |
|
1131 | 1131 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1132 | 1132 | } else { |
1133 | 1133 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1134 | 1134 | } |
1135 | 1135 | } |
1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1136 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1137 | 1137 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1138 | 1138 | if ($limit) $query .= " LIMIT 0,10"; |
1139 | 1139 | |
@@ -1146,24 +1146,24 @@ discard block |
||
1146 | 1146 | |
1147 | 1147 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1148 | 1148 | { |
1149 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1150 | - $temp_array['flight_count'] = $row['nb']; |
|
1151 | - $temp_array['flight_country'] = $row['name']; |
|
1152 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1153 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1154 | - $flight_array[] = $temp_array; |
|
1149 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1150 | + $temp_array['flight_count'] = $row['nb']; |
|
1151 | + $temp_array['flight_country'] = $row['name']; |
|
1152 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1153 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1154 | + $flight_array[] = $temp_array; |
|
1155 | 1155 | } |
1156 | 1156 | return $flight_array; |
1157 | - } |
|
1158 | - |
|
1159 | - /** |
|
1160 | - * Gets last spotter information based on a particular callsign |
|
1161 | - * |
|
1162 | - * @return Array the spotter information |
|
1163 | - * |
|
1164 | - */ |
|
1165 | - public function getDateArchiveMarineDataById($id,$date) |
|
1166 | - { |
|
1157 | + } |
|
1158 | + |
|
1159 | + /** |
|
1160 | + * Gets last spotter information based on a particular callsign |
|
1161 | + * |
|
1162 | + * @return Array the spotter information |
|
1163 | + * |
|
1164 | + */ |
|
1165 | + public function getDateArchiveMarineDataById($id,$date) |
|
1166 | + { |
|
1167 | 1167 | $Marine = new Marine($this->db); |
1168 | 1168 | date_default_timezone_set('UTC'); |
1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1171,16 +1171,16 @@ discard block |
||
1171 | 1171 | $date = date('c',$date); |
1172 | 1172 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1173 | 1173 | return $spotter_array; |
1174 | - } |
|
1175 | - |
|
1176 | - /** |
|
1177 | - * Gets all the spotter information based on a particular callsign |
|
1178 | - * |
|
1179 | - * @return Array the spotter information |
|
1180 | - * |
|
1181 | - */ |
|
1182 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1183 | - { |
|
1174 | + } |
|
1175 | + |
|
1176 | + /** |
|
1177 | + * Gets all the spotter information based on a particular callsign |
|
1178 | + * |
|
1179 | + * @return Array the spotter information |
|
1180 | + * |
|
1181 | + */ |
|
1182 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1183 | + { |
|
1184 | 1184 | $Marine = new Marine($this->db); |
1185 | 1185 | date_default_timezone_set('UTC'); |
1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1188,16 +1188,16 @@ discard block |
||
1188 | 1188 | $date = date('c',$date); |
1189 | 1189 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1190 | 1190 | return $spotter_array; |
1191 | - } |
|
1192 | - |
|
1193 | - /** |
|
1194 | - * Gets all the spotter information based on the airport |
|
1195 | - * |
|
1196 | - * @return Array the spotter information |
|
1197 | - * |
|
1198 | - */ |
|
1199 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1200 | - { |
|
1191 | + } |
|
1192 | + |
|
1193 | + /** |
|
1194 | + * Gets all the spotter information based on the airport |
|
1195 | + * |
|
1196 | + * @return Array the spotter information |
|
1197 | + * |
|
1198 | + */ |
|
1199 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1200 | + { |
|
1201 | 1201 | global $global_query; |
1202 | 1202 | $Marine = new Marine(); |
1203 | 1203 | date_default_timezone_set('UTC'); |
@@ -1208,35 +1208,35 @@ discard block |
||
1208 | 1208 | |
1209 | 1209 | if ($airport != "") |
1210 | 1210 | { |
1211 | - if (!is_string($airport)) |
|
1212 | - { |
|
1211 | + if (!is_string($airport)) |
|
1212 | + { |
|
1213 | 1213 | return false; |
1214 | - } else { |
|
1214 | + } else { |
|
1215 | 1215 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
1216 | 1216 | $query_values = array(':airport' => $airport); |
1217 | - } |
|
1217 | + } |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | if ($limit != "") |
1221 | 1221 | { |
1222 | - $limit_array = explode(",", $limit); |
|
1222 | + $limit_array = explode(",", $limit); |
|
1223 | 1223 | |
1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1226 | 1226 | |
1227 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1228 | - { |
|
1227 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1228 | + { |
|
1229 | 1229 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1230 | 1230 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1231 | - } |
|
1231 | + } |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | if ($sort != "") |
1235 | 1235 | { |
1236 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1237 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1236 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1237 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1238 | 1238 | } else { |
1239 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1239 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1244,6 +1244,6 @@ discard block |
||
1244 | 1244 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1245 | 1245 | |
1246 | 1246 | return $spotter_array; |
1247 | - } |
|
1247 | + } |
|
1248 | 1248 | } |
1249 | 1249 | ?> |
1250 | 1250 | \ No newline at end of file |