@@ -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; |
@@ -90,6 +90,10 @@ discard block |
||
90 | 90 | return strlen($headerLine); // Needed by curl |
91 | 91 | } |
92 | 92 | |
93 | + /** |
|
94 | + * @param string $url |
|
95 | + * @param string $file |
|
96 | + */ |
|
93 | 97 | public static function download($url, $file, $referer = '') { |
94 | 98 | global $globalDebug; |
95 | 99 | $fp = fopen($file, 'w'); |
@@ -106,6 +110,9 @@ discard block |
||
106 | 110 | fclose($fp); |
107 | 111 | } |
108 | 112 | |
113 | + /** |
|
114 | + * @param string $in_file |
|
115 | + */ |
|
109 | 116 | public static function gunzip($in_file,$out_file_name = '') { |
110 | 117 | //echo $in_file.' -> '.$out_file_name."\n"; |
111 | 118 | $buffer_size = 4096; // read 4kb at a time |
@@ -211,7 +218,7 @@ discard block |
||
211 | 218 | * Check is distance realistic |
212 | 219 | * @param int $timeDifference the time between the reception of both messages |
213 | 220 | * @param float $distance distance covered |
214 | - * @return whether distance is realistic |
|
221 | + * @return boolean distance is realistic |
|
215 | 222 | */ |
216 | 223 | public function withinThreshold ($timeDifference, $distance) { |
217 | 224 | $x = abs($timeDifference); |
@@ -234,6 +241,9 @@ discard block |
||
234 | 241 | } |
235 | 242 | |
236 | 243 | |
244 | + /** |
|
245 | + * @param string $latlong |
|
246 | + */ |
|
237 | 247 | public function convertDec($dms,$latlong) { |
238 | 248 | if ($latlong == 'latitude') { |
239 | 249 | $deg = substr($dms, 0, 2); |
@@ -245,6 +255,9 @@ discard block |
||
245 | 255 | return $deg+(($min*60)/3600); |
246 | 256 | } |
247 | 257 | |
258 | + /** |
|
259 | + * @param string $latlong |
|
260 | + */ |
|
248 | 261 | public function convertDM($coord,$latlong) { |
249 | 262 | if ($latlong == 'latitude') { |
250 | 263 | if ($coord < 0) $NSEW = 'S'; |
@@ -382,7 +395,7 @@ discard block |
||
382 | 395 | /** |
383 | 396 | * Returns list of available locales |
384 | 397 | * |
385 | - * @return array |
|
398 | + * @return string[] |
|
386 | 399 | */ |
387 | 400 | public function listLocaleDir() |
388 | 401 | { |
@@ -37,8 +37,11 @@ discard block |
||
37 | 37 | } else { |
38 | 38 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
39 | 39 | } |
40 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
41 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
40 | + if ($timeout == '') { |
|
41 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
42 | + } else { |
|
43 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
44 | + } |
|
42 | 45 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
43 | 46 | if ($type == 'post') { |
44 | 47 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | private function curlResponseHeaderCallback($ch, $headerLine) { |
86 | 89 | //global $cookies; |
87 | 90 | $cookies = array(); |
88 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
89 | - $cookies[] = $cookie; |
|
91 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
92 | + $cookies[] = $cookie; |
|
93 | + } |
|
90 | 94 | return strlen($headerLine); // Needed by curl |
91 | 95 | } |
92 | 96 | |
@@ -97,11 +101,15 @@ discard block |
||
97 | 101 | curl_setopt($ch, CURLOPT_URL, $url); |
98 | 102 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
99 | 103 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
100 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
104 | + if ($referer != '') { |
|
105 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
106 | + } |
|
101 | 107 | 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'); |
102 | 108 | curl_setopt($ch, CURLOPT_FILE, $fp); |
103 | 109 | curl_exec($ch); |
104 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
110 | + if (curl_errno($ch) && $globalDebug) { |
|
111 | + echo 'Download error: '.curl_error($ch); |
|
112 | + } |
|
105 | 113 | curl_close($ch); |
106 | 114 | fclose($fp); |
107 | 115 | } |
@@ -109,12 +117,16 @@ discard block |
||
109 | 117 | public static function gunzip($in_file,$out_file_name = '') { |
110 | 118 | //echo $in_file.' -> '.$out_file_name."\n"; |
111 | 119 | $buffer_size = 4096; // read 4kb at a time |
112 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
120 | + if ($out_file_name == '') { |
|
121 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
122 | + } |
|
113 | 123 | if ($in_file != '' && file_exists($in_file)) { |
114 | 124 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
115 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
116 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
117 | - else { |
|
125 | + if (function_exists('gzopen')) { |
|
126 | + $file = gzopen($in_file,'rb'); |
|
127 | + } elseif (function_exists('gzopen64')) { |
|
128 | + $file = gzopen64($in_file,'rb'); |
|
129 | + } else { |
|
118 | 130 | echo 'gzopen not available'; |
119 | 131 | die; |
120 | 132 | } |
@@ -130,11 +142,14 @@ discard block |
||
130 | 142 | public static function bunzip2($in_file,$out_file_name = '') { |
131 | 143 | //echo $in_file.' -> '.$out_file_name."\n"; |
132 | 144 | $buffer_size = 4096; // read 4kb at a time |
133 | - if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
|
145 | + if ($out_file_name == '') { |
|
146 | + $out_file_name = str_replace('.bz2', '', $in_file); |
|
147 | + } |
|
134 | 148 | if ($in_file != '' && file_exists($in_file)) { |
135 | 149 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
137 | - else { |
|
150 | + if (function_exists('bzopen')) { |
|
151 | + $file = bzopen($in_file,'rb'); |
|
152 | + } else { |
|
138 | 153 | echo 'bzopen not available'; |
139 | 154 | die; |
140 | 155 | } |
@@ -153,10 +168,16 @@ discard block |
||
153 | 168 | * @return Array array of the tables in HTML page |
154 | 169 | */ |
155 | 170 | public function table2array($data) { |
156 | - if (!is_string($data)) return array(); |
|
157 | - if ($data == '') return array(); |
|
171 | + if (!is_string($data)) { |
|
172 | + return array(); |
|
173 | + } |
|
174 | + if ($data == '') { |
|
175 | + return array(); |
|
176 | + } |
|
158 | 177 | $html = str_get_html($data); |
159 | - if ($html === false) return array(); |
|
178 | + if ($html === false) { |
|
179 | + return array(); |
|
180 | + } |
|
160 | 181 | $tabledata=array(); |
161 | 182 | foreach($html->find('tr') as $element) |
162 | 183 | { |
@@ -191,7 +212,9 @@ discard block |
||
191 | 212 | */ |
192 | 213 | public function text2array($data) { |
193 | 214 | $html = str_get_html($data); |
194 | - if ($html === false) return array(); |
|
215 | + if ($html === false) { |
|
216 | + return array(); |
|
217 | + } |
|
195 | 218 | $tabledata=array(); |
196 | 219 | foreach($html->find('p') as $element) |
197 | 220 | { |
@@ -212,7 +235,9 @@ discard block |
||
212 | 235 | * @return Float Distance in $unit |
213 | 236 | */ |
214 | 237 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
215 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
238 | + if ($lat == $latc && $lon == $lonc) { |
|
239 | + return 0; |
|
240 | + } |
|
216 | 241 | $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; |
217 | 242 | if ($unit == "km") { |
218 | 243 | return round($dist * 1.609344); |
@@ -236,10 +261,16 @@ discard block |
||
236 | 261 | public function withinThreshold ($timeDifference, $distance) { |
237 | 262 | $x = abs($timeDifference); |
238 | 263 | $d = abs($distance); |
239 | - if ($x == 0 || $d == 0) return true; |
|
264 | + if ($x == 0 || $d == 0) { |
|
265 | + return true; |
|
266 | + } |
|
240 | 267 | // may be due to Internet jitter; distance is realistic |
241 | - if ($x < 0.7 && $d < 2000) return true; |
|
242 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
268 | + if ($x < 0.7 && $d < 2000) { |
|
269 | + return true; |
|
270 | + } else { |
|
271 | + return $d/$x < 1500*0.27778; |
|
272 | + } |
|
273 | + // 1500 km/h max |
|
243 | 274 | } |
244 | 275 | |
245 | 276 | |
@@ -267,11 +298,17 @@ discard block |
||
267 | 298 | |
268 | 299 | public function convertDM($coord,$latlong) { |
269 | 300 | if ($latlong == 'latitude') { |
270 | - if ($coord < 0) $NSEW = 'S'; |
|
271 | - else $NSEW = 'N'; |
|
301 | + if ($coord < 0) { |
|
302 | + $NSEW = 'S'; |
|
303 | + } else { |
|
304 | + $NSEW = 'N'; |
|
305 | + } |
|
272 | 306 | } else { |
273 | - if ($coord < 0) $NSEW = 'W'; |
|
274 | - else $NSEW = 'E'; |
|
307 | + if ($coord < 0) { |
|
308 | + $NSEW = 'W'; |
|
309 | + } else { |
|
310 | + $NSEW = 'E'; |
|
311 | + } |
|
275 | 312 | } |
276 | 313 | $coord = abs($coord); |
277 | 314 | $deg = floor($coord); |
@@ -314,7 +351,9 @@ discard block |
||
314 | 351 | public function hex2str($hex) { |
315 | 352 | $str = ''; |
316 | 353 | $hexln = strlen($hex); |
317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
354 | + for($i=0;$i<$hexln;$i+=2) { |
|
355 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
356 | + } |
|
318 | 357 | return $str; |
319 | 358 | } |
320 | 359 | |
@@ -351,8 +390,11 @@ discard block |
||
351 | 390 | $b = $lat2 - $lat1; |
352 | 391 | $c = -($a*$lat1+$b*$lon1); |
353 | 392 | $d = $a*$lat3+$b*$lon3+$c; |
354 | - if ($d > -$approx && $d < $approx) return true; |
|
355 | - else return false; |
|
393 | + if ($d > -$approx && $d < $approx) { |
|
394 | + return true; |
|
395 | + } else { |
|
396 | + return false; |
|
397 | + } |
|
356 | 398 | } |
357 | 399 | |
358 | 400 | public function array_merge_noappend() { |
@@ -411,7 +453,9 @@ discard block |
||
411 | 453 | return $result; |
412 | 454 | } |
413 | 455 | $handle = @opendir('./locale'); |
414 | - if ($handle === false) return $result; |
|
456 | + if ($handle === false) { |
|
457 | + return $result; |
|
458 | + } |
|
415 | 459 | while (false !== ($file = readdir($handle))) { |
416 | 460 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
417 | 461 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -478,8 +522,9 @@ discard block |
||
478 | 522 | $error = false; |
479 | 523 | if ($fp_out = gzopen($dest, $mode)) { |
480 | 524 | if ($fp_in = fopen($source,'rb')) { |
481 | - while (!feof($fp_in)) |
|
482 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
525 | + while (!feof($fp_in)) { |
|
526 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
527 | + } |
|
483 | 528 | fclose($fp_in); |
484 | 529 | } else { |
485 | 530 | $error = true; |
@@ -488,14 +533,17 @@ discard block |
||
488 | 533 | } else { |
489 | 534 | $error = true; |
490 | 535 | } |
491 | - if ($error) |
|
492 | - return false; |
|
493 | - else |
|
494 | - return $dest; |
|
536 | + if ($error) { |
|
537 | + return false; |
|
538 | + } else { |
|
539 | + return $dest; |
|
540 | + } |
|
495 | 541 | } |
496 | 542 | |
497 | 543 | public function remove_accents($string) { |
498 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
544 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
545 | + return $string; |
|
546 | + } |
|
499 | 547 | $chars = array( |
500 | 548 | // Decompositions for Latin-1 Supplement |
501 | 549 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -619,7 +667,9 @@ discard block |
||
619 | 667 | $ip = gethostbyname($host); |
620 | 668 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
621 | 669 | $r = @socket_connect($s, $ip, $port); |
622 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
670 | + if (!socket_set_nonblock($s)) { |
|
671 | + echo "Unable to set nonblock on socket\n"; |
|
672 | + } |
|
623 | 673 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
624 | 674 | return $s; |
625 | 675 | } |
@@ -664,18 +714,22 @@ discard block |
||
664 | 714 | //NOTE: use a trailing slash for folders!!! |
665 | 715 | //see http://bugs.php.net/bug.php?id=27609 |
666 | 716 | //see http://bugs.php.net/bug.php?id=30931 |
667 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
717 | + if ($path{strlen($path)-1}=='/') { |
|
718 | + // recursively return a temporary file path |
|
668 | 719 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
669 | - else if (is_dir($path)) |
|
670 | - return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
720 | + } else if (is_dir($path)) { |
|
721 | + return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
722 | + } |
|
671 | 723 | // check tmp file for read/write capabilities |
672 | 724 | $rm = file_exists($path); |
673 | 725 | $f = @fopen($path, 'a'); |
674 | - if ($f===false) |
|
675 | - return false; |
|
726 | + if ($f===false) { |
|
727 | + return false; |
|
728 | + } |
|
676 | 729 | fclose($f); |
677 | - if (!$rm) |
|
678 | - unlink($path); |
|
730 | + if (!$rm) { |
|
731 | + unlink($path); |
|
732 | + } |
|
679 | 733 | return true; |
680 | 734 | } |
681 | 735 | } |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * @param Array $headers header to submit with the form |
15 | 15 | * @return String the result |
16 | 16 | */ |
17 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
|
17 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') { |
|
18 | 18 | global $globalProxy, $globalForceIPv4; |
19 | 19 | $ch = curl_init(); |
20 | 20 | curl_setopt($ch, CURLOPT_URL, $url); |
21 | 21 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
22 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
22 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
23 | 23 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
24 | 24 | } |
25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
30 | 30 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
31 | 31 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
32 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
32 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
33 | 33 | //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'); |
34 | 34 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
35 | 35 | if ($useragent == '') { |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | } |
40 | 40 | if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
41 | 41 | else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
42 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
|
42 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback")); |
|
43 | 43 | if ($type == 'post') { |
44 | 44 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
45 | 45 | if (is_array($data)) { |
46 | 46 | curl_setopt($ch, CURLOPT_POST, count($data)); |
47 | 47 | $data_string = ''; |
48 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
48 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
49 | 49 | rtrim($data_string, '&'); |
50 | 50 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
51 | 51 | } else { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | if ($cookie != '') { |
59 | 59 | if (is_array($cookie)) { |
60 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
60 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
61 | 61 | } else { |
62 | 62 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
63 | 63 | } |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | $info = curl_getinfo($ch); |
70 | 70 | //var_dump($info); |
71 | 71 | curl_close($ch); |
72 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
72 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
73 | 73 | echo "Cloudflare Detected\n"; |
74 | 74 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
75 | 75 | $useragent = UAgent::random(); |
76 | 76 | cloudflare::useUserAgent($useragent); |
77 | 77 | if ($clearanceCookie = cloudflare::bypass($url)) { |
78 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
78 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
79 | 79 | } |
80 | 80 | } else { |
81 | 81 | return $result; |
@@ -106,20 +106,20 @@ discard block |
||
106 | 106 | fclose($fp); |
107 | 107 | } |
108 | 108 | |
109 | - public static function gunzip($in_file,$out_file_name = '') { |
|
109 | + public static function gunzip($in_file, $out_file_name = '') { |
|
110 | 110 | //echo $in_file.' -> '.$out_file_name."\n"; |
111 | 111 | $buffer_size = 4096; // read 4kb at a time |
112 | 112 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
113 | 113 | if ($in_file != '' && file_exists($in_file)) { |
114 | 114 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
115 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
116 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
115 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
116 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
117 | 117 | else { |
118 | 118 | echo 'gzopen not available'; |
119 | 119 | die; |
120 | 120 | } |
121 | 121 | $out_file = fopen($out_file_name, 'wb'); |
122 | - while(!gzeof($file)) { |
|
122 | + while (!gzeof($file)) { |
|
123 | 123 | fwrite($out_file, gzread($file, $buffer_size)); |
124 | 124 | } |
125 | 125 | fclose($out_file); |
@@ -127,19 +127,19 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - public static function bunzip2($in_file,$out_file_name = '') { |
|
130 | + public static function bunzip2($in_file, $out_file_name = '') { |
|
131 | 131 | //echo $in_file.' -> '.$out_file_name."\n"; |
132 | 132 | $buffer_size = 4096; // read 4kb at a time |
133 | 133 | if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
134 | 134 | if ($in_file != '' && file_exists($in_file)) { |
135 | 135 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
136 | + if (function_exists('bzopen')) $file = bzopen($in_file, 'rb'); |
|
137 | 137 | else { |
138 | 138 | echo 'bzopen not available'; |
139 | 139 | die; |
140 | 140 | } |
141 | 141 | $out_file = fopen($out_file_name, 'wb'); |
142 | - while(!feof($file)) { |
|
142 | + while (!feof($file)) { |
|
143 | 143 | fwrite($out_file, bzread($file, $buffer_size)); |
144 | 144 | } |
145 | 145 | fclose($out_file); |
@@ -157,27 +157,27 @@ discard block |
||
157 | 157 | if ($data == '') return array(); |
158 | 158 | $html = str_get_html($data); |
159 | 159 | if ($html === false) return array(); |
160 | - $tabledata=array(); |
|
161 | - foreach($html->find('tr') as $element) |
|
160 | + $tabledata = array(); |
|
161 | + foreach ($html->find('tr') as $element) |
|
162 | 162 | { |
163 | 163 | $td = array(); |
164 | - foreach( $element->find('th') as $row) |
|
164 | + foreach ($element->find('th') as $row) |
|
165 | 165 | { |
166 | 166 | $td [] = trim($row->plaintext); |
167 | 167 | } |
168 | - $td=array_filter($td); |
|
168 | + $td = array_filter($td); |
|
169 | 169 | $tabledata[] = $td; |
170 | 170 | |
171 | 171 | $td = array(); |
172 | 172 | $tdi = array(); |
173 | - foreach( $element->find('td') as $row) |
|
173 | + foreach ($element->find('td') as $row) |
|
174 | 174 | { |
175 | 175 | $td [] = trim($row->plaintext); |
176 | 176 | $tdi [] = trim($row->innertext); |
177 | 177 | } |
178 | - $td=array_filter($td); |
|
179 | - $tdi=array_filter($tdi); |
|
180 | - $tabledata[]=array_merge($td,$tdi); |
|
178 | + $td = array_filter($td); |
|
179 | + $tdi = array_filter($tdi); |
|
180 | + $tabledata[] = array_merge($td, $tdi); |
|
181 | 181 | } |
182 | 182 | $html->clear(); |
183 | 183 | unset($html); |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | public function text2array($data) { |
193 | 193 | $html = str_get_html($data); |
194 | 194 | if ($html === false) return array(); |
195 | - $tabledata=array(); |
|
196 | - foreach($html->find('p') as $element) |
|
195 | + $tabledata = array(); |
|
196 | + foreach ($html->find('p') as $element) |
|
197 | 197 | { |
198 | 198 | $tabledata [] = trim($element->plaintext); |
199 | 199 | } |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
215 | 215 | if ($lat == $latc && $lon == $lonc) return 0; |
216 | - $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; |
|
216 | + $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; |
|
217 | 217 | if ($unit == "km") { |
218 | - return round($dist * 1.609344); |
|
218 | + return round($dist*1.609344); |
|
219 | 219 | } elseif ($unit == "m") { |
220 | - return round($dist * 1.609344 * 1000); |
|
220 | + return round($dist*1.609344*1000); |
|
221 | 221 | } elseif ($unit == "mile" || $unit == "mi") { |
222 | 222 | return round($dist); |
223 | 223 | } elseif ($unit == "nm") { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @param float $distance distance covered |
234 | 234 | * @return whether distance is realistic |
235 | 235 | */ |
236 | - public function withinThreshold ($timeDifference, $distance) { |
|
236 | + public function withinThreshold($timeDifference, $distance) { |
|
237 | 237 | $x = abs($timeDifference); |
238 | 238 | $d = abs($distance); |
239 | 239 | if ($x == 0 || $d == 0) return true; |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | return ($array !== array_values($array)); |
250 | 250 | } |
251 | 251 | |
252 | - public function isInteger($input){ |
|
252 | + public function isInteger($input) { |
|
253 | 253 | return(ctype_digit(strval($input))); |
254 | 254 | } |
255 | 255 | |
256 | 256 | |
257 | - public function convertDec($dms,$latlong) { |
|
257 | + public function convertDec($dms, $latlong) { |
|
258 | 258 | if ($latlong == 'latitude') { |
259 | 259 | $deg = substr($dms, 0, 2); |
260 | 260 | $min = substr($dms, 2, 4); |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | $deg = substr($dms, 0, 3); |
263 | 263 | $min = substr($dms, 3, 5); |
264 | 264 | } |
265 | - return $deg+(($min*60)/3600); |
|
265 | + return $deg + (($min*60)/3600); |
|
266 | 266 | } |
267 | 267 | |
268 | - public function convertDM($coord,$latlong) { |
|
268 | + public function convertDM($coord, $latlong) { |
|
269 | 269 | if ($latlong == 'latitude') { |
270 | 270 | if ($coord < 0) $NSEW = 'S'; |
271 | 271 | else $NSEW = 'N'; |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | } |
276 | 276 | $coord = abs($coord); |
277 | 277 | $deg = floor($coord); |
278 | - $coord = ($coord-$deg)*60; |
|
278 | + $coord = ($coord - $deg)*60; |
|
279 | 279 | $min = $coord; |
280 | - return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW); |
|
280 | + return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | public function xcopy($source, $dest) |
290 | 290 | { |
291 | 291 | $files = glob($source.'*.*'); |
292 | - foreach($files as $file){ |
|
293 | - $file_to_go = str_replace($source,$dest,$file); |
|
292 | + foreach ($files as $file) { |
|
293 | + $file_to_go = str_replace($source, $dest, $file); |
|
294 | 294 | copy($file, $file_to_go); |
295 | 295 | } |
296 | 296 | return true; |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * @param String $url url to check |
302 | 302 | * @return bool Return true on succes false on failure |
303 | 303 | */ |
304 | - public function urlexist($url){ |
|
305 | - $headers=get_headers($url); |
|
306 | - return stripos($headers[0],"200 OK")?true:false; |
|
304 | + public function urlexist($url) { |
|
305 | + $headers = get_headers($url); |
|
306 | + return stripos($headers[0], "200 OK") ? true : false; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | public function hex2str($hex) { |
315 | 315 | $str = ''; |
316 | 316 | $hexln = strlen($hex); |
317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
317 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
318 | 318 | return $str; |
319 | 319 | } |
320 | 320 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @return String Return result |
325 | 325 | */ |
326 | 326 | public function hex2rgb($hex) { |
327 | - $hex = str_replace('#','',$hex); |
|
327 | + $hex = str_replace('#', '', $hex); |
|
328 | 328 | return sscanf($hex, "%02x%02x%02x"); |
329 | 329 | } |
330 | 330 | |
@@ -332,33 +332,33 @@ discard block |
||
332 | 332 | //difference in longitudinal coordinates |
333 | 333 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
334 | 334 | //difference in the phi of latitudinal coordinates |
335 | - $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); |
|
335 | + $dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4)); |
|
336 | 336 | //we need to recalculate $dLon if it is greater than pi |
337 | - if(abs($dLon) > pi()) { |
|
338 | - if($dLon > 0) { |
|
339 | - $dLon = (2 * pi() - $dLon) * -1; |
|
337 | + if (abs($dLon) > pi()) { |
|
338 | + if ($dLon > 0) { |
|
339 | + $dLon = (2*pi() - $dLon)*-1; |
|
340 | 340 | } else { |
341 | - $dLon = 2 * pi() + $dLon; |
|
341 | + $dLon = 2*pi() + $dLon; |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | //return the angle, normalized |
345 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
345 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
346 | 346 | } |
347 | 347 | |
348 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) { |
|
348 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) { |
|
349 | 349 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
350 | - $a = -($lon2-$lon1); |
|
350 | + $a = -($lon2 - $lon1); |
|
351 | 351 | $b = $lat2 - $lat1; |
352 | - $c = -($a*$lat1+$b*$lon1); |
|
353 | - $d = $a*$lat3+$b*$lon3+$c; |
|
352 | + $c = -($a*$lat1 + $b*$lon1); |
|
353 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
354 | 354 | if ($d > -$approx && $d < $approx) return true; |
355 | 355 | else return false; |
356 | 356 | } |
357 | 357 | |
358 | 358 | public function array_merge_noappend() { |
359 | 359 | $output = array(); |
360 | - foreach(func_get_args() as $array) { |
|
361 | - foreach($array as $key => $value) { |
|
360 | + foreach (func_get_args() as $array) { |
|
361 | + foreach ($array as $key => $value) { |
|
362 | 362 | $output[$key] = isset($output[$key]) ? |
363 | 363 | array_merge($output[$key], $value) : $value; |
364 | 364 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | return $result; |
423 | 423 | } |
424 | 424 | |
425 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){ |
|
425 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') { |
|
426 | 426 | global $globalMapRefresh; |
427 | 427 | if ($seconds == '') { |
428 | 428 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
@@ -433,27 +433,27 @@ discard block |
||
433 | 433 | $latitude = deg2rad($latitude); |
434 | 434 | $longitude = deg2rad($longitude); |
435 | 435 | $bearing = deg2rad($heading); |
436 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
437 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
438 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
436 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
437 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
438 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
439 | 439 | } |
440 | 440 | |
441 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
441 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
442 | 442 | // distance in meter |
443 | 443 | $R = 6378.14; |
444 | - $latitude1 = $latitude * (M_PI/180); |
|
445 | - $longitude1 = $longitude * (M_PI/180); |
|
446 | - $brng = $bearing * (M_PI/180); |
|
444 | + $latitude1 = $latitude*(M_PI/180); |
|
445 | + $longitude1 = $longitude*(M_PI/180); |
|
446 | + $brng = $bearing*(M_PI/180); |
|
447 | 447 | $d = $distance; |
448 | 448 | |
449 | 449 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
450 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
450 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
451 | 451 | |
452 | - $latitude2 = $latitude2 * (180/M_PI); |
|
453 | - $longitude2 = $longitude2 * (180/M_PI); |
|
452 | + $latitude2 = $latitude2*(180/M_PI); |
|
453 | + $longitude2 = $longitude2*(180/M_PI); |
|
454 | 454 | |
455 | - $flat = round ($latitude2,6); |
|
456 | - $flong = round ($longitude2,6); |
|
455 | + $flat = round($latitude2, 6); |
|
456 | + $flong = round($longitude2, 6); |
|
457 | 457 | /* |
458 | 458 | $dx = $distance*cos($bearing); |
459 | 459 | $dy = $distance*sin($bearing); |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | $flong = $longitude + $dlong; |
463 | 463 | $flat = $latitude + $dlat; |
464 | 464 | */ |
465 | - return array('latitude' => $flat,'longitude' => $flong); |
|
465 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | * @param integer $level GZIP compression level (default: 9) |
477 | 477 | * @return string New filename (with .gz appended) if success, or false if operation fails |
478 | 478 | */ |
479 | - public function gzCompressFile($source, $level = 9){ |
|
480 | - $dest = $source . '.gz'; |
|
481 | - $mode = 'wb' . $level; |
|
479 | + public function gzCompressFile($source, $level = 9) { |
|
480 | + $dest = $source.'.gz'; |
|
481 | + $mode = 'wb'.$level; |
|
482 | 482 | $error = false; |
483 | 483 | if ($fp_out = gzopen($dest, $mode)) { |
484 | - if ($fp_in = fopen($source,'rb')) { |
|
484 | + if ($fp_in = fopen($source, 'rb')) { |
|
485 | 485 | while (!feof($fp_in)) |
486 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
486 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
487 | 487 | fclose($fp_in); |
488 | 488 | } else { |
489 | 489 | $error = true; |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | } |
500 | 500 | |
501 | 501 | public function remove_accents($string) { |
502 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
502 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
503 | 503 | $chars = array( |
504 | 504 | // Decompositions for Latin-1 Supplement |
505 | 505 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
557 | 557 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
558 | 558 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
559 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
559 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
560 | 560 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
561 | 561 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
562 | 562 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -572,13 +572,13 @@ discard block |
||
572 | 572 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
573 | 573 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
574 | 574 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
575 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
576 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
577 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
578 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
579 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
580 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
581 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
575 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
576 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
577 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
578 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
579 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
580 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
581 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
582 | 582 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
583 | 583 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
584 | 584 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
613 | 613 | if (is_numeric($string[$i]) && $concat_flag) { |
614 | 614 | $int .= $string[$i]; |
615 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
615 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
616 | 616 | $concat_flag = false; |
617 | 617 | } |
618 | 618 | } |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | $slice = array_slice($arr, $offset + 1, $length); |
659 | 659 | return implode("", $slice); |
660 | 660 | } else { |
661 | - return mb_substr($string,$offset,$length,'UTF-8'); |
|
661 | + return mb_substr($string, $offset, $length, 'UTF-8'); |
|
662 | 662 | } |
663 | 663 | } |
664 | 664 | |
@@ -668,14 +668,14 @@ discard block |
||
668 | 668 | //NOTE: use a trailing slash for folders!!! |
669 | 669 | //see http://bugs.php.net/bug.php?id=27609 |
670 | 670 | //see http://bugs.php.net/bug.php?id=30931 |
671 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
671 | + if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path |
|
672 | 672 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
673 | 673 | else if (is_dir($path)) |
674 | 674 | return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
675 | 675 | // check tmp file for read/write capabilities |
676 | 676 | $rm = file_exists($path); |
677 | 677 | $f = @fopen($path, 'a'); |
678 | - if ($f===false) |
|
678 | + if ($f === false) |
|
679 | 679 | return false; |
680 | 680 | fclose($f); |
681 | 681 | if (!$rm) |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | </span> |
4 | 4 | <div class="sub-menu sub-menu-container"> |
5 | 5 | <ul class="nav nav-pills"> |
6 | - <li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
6 | + <li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
7 | 7 | <li class="dropdown"> |
8 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
8 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
9 | 9 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
10 | 10 | </a> |
11 | 11 | <ul class="dropdown-menu" role="menu"> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | </ul> |
15 | 15 | </li> |
16 | 16 | <li class="dropdown"> |
17 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
17 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
18 | 18 | <?php echo _("Airline"); ?> <span class="caret"></span> |
19 | 19 | </a> |
20 | 20 | <ul class="dropdown-menu" role="menu"> |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | </ul> |
24 | 24 | </li> |
25 | 25 | <li class="dropdown"> |
26 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
26 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
27 | 27 | <?php echo _("Airport"); ?> <span class="caret"></span> |
28 | 28 | </a> |
29 | 29 | <ul class="dropdown-menu" role="menu"> |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/arrival-airport-country/<?php print $manufacturer; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
34 | 34 | </ul> |
35 | 35 | </li> |
36 | - <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
37 | - <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
36 | + <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
37 | + <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
38 | 38 | </ul> |
39 | 39 | </div> |
40 | 40 | \ No newline at end of file |
@@ -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); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | if (isset($_GET['coord'])) |
13 | 13 | { |
14 | - $coords = explode(',',$_GET['coord']); |
|
14 | + $coords = explode(',', $_GET['coord']); |
|
15 | 15 | $spotter_array = $Spotter->getAllAirportInfobyCoord($coords); |
16 | 16 | } else { |
17 | 17 | $spotter_array = $Spotter->getAllAirportInfo(); |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | |
23 | 23 | if (!empty($spotter_array)) |
24 | 24 | { |
25 | - foreach($spotter_array as $spotter_item) |
|
25 | + foreach ($spotter_array as $spotter_item) |
|
26 | 26 | { |
27 | 27 | date_default_timezone_set('UTC'); |
28 | 28 | //waypoint plotting |
29 | 29 | $output .= '{"type": "Feature",'; |
30 | 30 | $output .= '"properties": {'; |
31 | - $output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",'; |
|
32 | - $output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",'; |
|
31 | + $output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",'; |
|
32 | + $output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",'; |
|
33 | 33 | $output .= '"country": "'.$spotter_item['country'].'",'; |
34 | 34 | $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
35 | - $output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
35 | + $output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
36 | 36 | if ($spotter_item['type'] == 'large_airport') { |
37 | 37 | $output .= '"icon": "'.$globalURL.'/images/airport.png",'; |
38 | 38 | } elseif ($spotter_item['type'] == 'heliport') { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $output .= '}'; |
60 | 60 | $output .= '},'; |
61 | 61 | } |
62 | - $output = substr($output, 0, -1); |
|
62 | + $output = substr($output, 0, -1); |
|
63 | 63 | } |
64 | 64 | $output .= ']}'; |
65 | 65 | print $output; |
@@ -254,6 +254,7 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @param String $aircraft_registration the registration of the aircraft |
256 | 256 | * @param String $aircraft_name type of the aircraft |
257 | + * @param string $type |
|
257 | 258 | * @return Array the aircraft thumbnail, orignal url and copyright |
258 | 259 | * |
259 | 260 | */ |
@@ -287,6 +288,7 @@ discard block |
||
287 | 288 | * |
288 | 289 | * @param String $registration the registration of the aircraft |
289 | 290 | * @param String $name type of the aircraft |
291 | + * @param string $type |
|
290 | 292 | * @return Array the aircraft thumbnail, orignal url and copyright |
291 | 293 | * |
292 | 294 | */ |
@@ -325,6 +327,7 @@ discard block |
||
325 | 327 | * |
326 | 328 | * @param String $aircraft_registration the registration of the aircraft |
327 | 329 | * @param String $aircraft_name type of the aircraft |
330 | + * @param string $type |
|
328 | 331 | * @return Array the aircraft thumbnail, orignal url and copyright |
329 | 332 | * |
330 | 333 | */ |
@@ -367,6 +370,7 @@ discard block |
||
367 | 370 | * |
368 | 371 | * @param String $aircraft_registration the registration of the aircraft |
369 | 372 | * @param String $aircraft_name type of the aircraft |
373 | + * @param string $type |
|
370 | 374 | * @return Array the aircraft thumbnail, orignal url and copyright |
371 | 375 | * |
372 | 376 | */ |
@@ -401,6 +405,7 @@ discard block |
||
401 | 405 | * |
402 | 406 | * @param String $registration the registration of the aircraft |
403 | 407 | * @param String $name type of the aircraft |
408 | + * @param string $type |
|
404 | 409 | * @return Array the aircraft thumbnail, orignal url and copyright |
405 | 410 | * |
406 | 411 | */ |
@@ -429,6 +434,10 @@ discard block |
||
429 | 434 | return false; |
430 | 435 | } |
431 | 436 | |
437 | + /** |
|
438 | + * @param string $type |
|
439 | + * @param string $aircraft_icao |
|
440 | + */ |
|
432 | 441 | public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
433 | 442 | $Common = new Common(); |
434 | 443 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
@@ -450,6 +459,7 @@ discard block |
||
450 | 459 | * |
451 | 460 | * @param String $aircraft_registration the registration of the aircraft |
452 | 461 | * @param String $aircraft_name type of the aircraft |
462 | + * @param string $type |
|
453 | 463 | * @return Array the aircraft thumbnail, orignal url and copyright |
454 | 464 | * |
455 | 465 | */ |
@@ -482,6 +492,7 @@ discard block |
||
482 | 492 | * |
483 | 493 | * @param String $aircraft_registration the registration of the aircraft |
484 | 494 | * @param String $aircraft_name type of the aircraft |
495 | + * @param string $type |
|
485 | 496 | * @return Array the aircraft thumbnail, orignal url and copyright |
486 | 497 | * |
487 | 498 | */ |
@@ -507,6 +518,7 @@ discard block |
||
507 | 518 | * |
508 | 519 | * @param String $registration the registration of the aircraft/mmsi |
509 | 520 | * @param String $name name |
521 | + * @param string $type |
|
510 | 522 | * @return Array the aircraft thumbnail, orignal url and copyright |
511 | 523 | * |
512 | 524 | */ |
@@ -568,6 +580,7 @@ discard block |
||
568 | 580 | * |
569 | 581 | * @param String $registration the registration of the aircraft |
570 | 582 | * @param String $name type of the aircraft |
583 | + * @param string $type |
|
571 | 584 | * @return Array the aircraft thumbnail, orignal url and copyright |
572 | 585 | * |
573 | 586 | */ |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * Gets the images based on the aircraft registration |
|
16 | - * |
|
17 | - * @return Array the images list |
|
18 | - * |
|
19 | - */ |
|
15 | + * Gets the images based on the aircraft registration |
|
16 | + * |
|
17 | + * @return Array the images list |
|
18 | + * |
|
19 | + */ |
|
20 | 20 | public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
21 | 21 | { |
22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | - * Gets the images based on the ship name |
|
41 | - * |
|
42 | - * @return Array the images list |
|
43 | - * |
|
44 | - */ |
|
40 | + * Gets the images based on the ship name |
|
41 | + * |
|
42 | + * @return Array the images list |
|
43 | + * |
|
44 | + */ |
|
45 | 45 | public function getMarineImage($mmsi,$imo = '',$name = '') |
46 | 46 | { |
47 | 47 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * Gets the image copyright based on the Exif data |
|
72 | - * |
|
73 | - * @return String image copyright |
|
74 | - * |
|
75 | - */ |
|
71 | + * Gets the image copyright based on the Exif data |
|
72 | + * |
|
73 | + * @return String image copyright |
|
74 | + * |
|
75 | + */ |
|
76 | 76 | public function getExifCopyright($url) { |
77 | 77 | $exif = exif_read_data($url); |
78 | 78 | $copyright = ''; |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Adds the images based on the aircraft registration |
|
91 | - * |
|
92 | - * @return String either success or error |
|
93 | - * |
|
94 | - */ |
|
90 | + * Adds the images based on the aircraft registration |
|
91 | + * |
|
92 | + * @return String either success or error |
|
93 | + * |
|
94 | + */ |
|
95 | 95 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
96 | 96 | { |
97 | 97 | global $globalDebug,$globalAircraftImageFetch; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | - * Adds the images based on the marine name |
|
123 | - * |
|
124 | - * @return String either success or error |
|
125 | - * |
|
126 | - */ |
|
122 | + * Adds the images based on the marine name |
|
123 | + * |
|
124 | + * @return String either success or error |
|
125 | + * |
|
126 | + */ |
|
127 | 127 | public function addMarineImage($mmsi,$imo = '',$name = '') |
128 | 128 | { |
129 | 129 | global $globalDebug,$globalMarineImageFetch; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | - * Gets the aircraft image |
|
164 | - * |
|
165 | - * @param String $aircraft_registration the registration of the aircraft |
|
166 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
167 | - * |
|
168 | - */ |
|
163 | + * Gets the aircraft image |
|
164 | + * |
|
165 | + * @param String $aircraft_registration the registration of the aircraft |
|
166 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
167 | + * |
|
168 | + */ |
|
169 | 169 | public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
170 | 170 | { |
171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
212 | - * Gets the vessel image |
|
213 | - * |
|
214 | - * @param String $mmsi the vessel mmsi |
|
215 | - * @param String $imo the vessel imo |
|
216 | - * @param String $name the vessel name |
|
217 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
218 | - * |
|
219 | - */ |
|
212 | + * Gets the vessel image |
|
213 | + * |
|
214 | + * @param String $mmsi the vessel mmsi |
|
215 | + * @param String $imo the vessel imo |
|
216 | + * @param String $name the vessel name |
|
217 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
218 | + * |
|
219 | + */ |
|
220 | 220 | public function findMarineImage($mmsi,$imo = '',$name = '') |
221 | 221 | { |
222 | 222 | global $globalMarineImageSources; |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | - * Gets the aircraft image from Planespotters |
|
254 | - * |
|
255 | - * @param String $aircraft_registration the registration of the aircraft |
|
256 | - * @param String $aircraft_name type of the aircraft |
|
257 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
258 | - * |
|
259 | - */ |
|
253 | + * Gets the aircraft image from Planespotters |
|
254 | + * |
|
255 | + * @param String $aircraft_registration the registration of the aircraft |
|
256 | + * @param String $aircraft_name type of the aircraft |
|
257 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
258 | + * |
|
259 | + */ |
|
260 | 260 | public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
261 | 261 | $Common = new Common(); |
262 | 262 | // If aircraft registration is only number, also check with aircraft model |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | - * Gets the aircraft image from Deviantart |
|
287 | - * |
|
288 | - * @param String $registration the registration of the aircraft |
|
289 | - * @param String $name type of the aircraft |
|
290 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
291 | - * |
|
292 | - */ |
|
286 | + * Gets the aircraft image from Deviantart |
|
287 | + * |
|
288 | + * @param String $registration the registration of the aircraft |
|
289 | + * @param String $name type of the aircraft |
|
290 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
291 | + * |
|
292 | + */ |
|
293 | 293 | public function fromDeviantart($type,$registration, $name='') { |
294 | 294 | $Common = new Common(); |
295 | 295 | if ($type == 'aircraft') { |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
324 | - * Gets the aircraft image from JetPhotos |
|
325 | - * |
|
326 | - * @param String $aircraft_registration the registration of the aircraft |
|
327 | - * @param String $aircraft_name type of the aircraft |
|
328 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
329 | - * |
|
330 | - */ |
|
324 | + * Gets the aircraft image from JetPhotos |
|
325 | + * |
|
326 | + * @param String $aircraft_registration the registration of the aircraft |
|
327 | + * @param String $aircraft_name type of the aircraft |
|
328 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
329 | + * |
|
330 | + */ |
|
331 | 331 | public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
332 | 332 | $Common = new Common(); |
333 | 333 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
366 | - * Gets the aircraft image from PlanePictures |
|
367 | - * |
|
368 | - * @param String $aircraft_registration the registration of the aircraft |
|
369 | - * @param String $aircraft_name type of the aircraft |
|
370 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
371 | - * |
|
372 | - */ |
|
366 | + * Gets the aircraft image from PlanePictures |
|
367 | + * |
|
368 | + * @param String $aircraft_registration the registration of the aircraft |
|
369 | + * @param String $aircraft_name type of the aircraft |
|
370 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
371 | + * |
|
372 | + */ |
|
373 | 373 | public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
374 | 374 | $Common = new Common(); |
375 | 375 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
400 | - * Gets the aircraft image from Flickr |
|
401 | - * |
|
402 | - * @param String $registration the registration of the aircraft |
|
403 | - * @param String $name type of the aircraft |
|
404 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
405 | - * |
|
406 | - */ |
|
400 | + * Gets the aircraft image from Flickr |
|
401 | + * |
|
402 | + * @param String $registration the registration of the aircraft |
|
403 | + * @param String $name type of the aircraft |
|
404 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
405 | + * |
|
406 | + */ |
|
407 | 407 | public function fromFlickr($type,$registration,$name='') { |
408 | 408 | $Common = new Common(); |
409 | 409 | if ($type == 'aircraft') { |
@@ -446,13 +446,13 @@ discard block |
||
446 | 446 | } |
447 | 447 | |
448 | 448 | /** |
449 | - * Gets the aircraft image from Bing |
|
450 | - * |
|
451 | - * @param String $aircraft_registration the registration of the aircraft |
|
452 | - * @param String $aircraft_name type of the aircraft |
|
453 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
454 | - * |
|
455 | - */ |
|
449 | + * Gets the aircraft image from Bing |
|
450 | + * |
|
451 | + * @param String $aircraft_registration the registration of the aircraft |
|
452 | + * @param String $aircraft_name type of the aircraft |
|
453 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
454 | + * |
|
455 | + */ |
|
456 | 456 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
457 | 457 | global $globalImageBingKey; |
458 | 458 | $Common = new Common(); |
@@ -478,13 +478,13 @@ discard block |
||
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
481 | - * Gets the aircraft image from airport-data |
|
482 | - * |
|
483 | - * @param String $aircraft_registration the registration of the aircraft |
|
484 | - * @param String $aircraft_name type of the aircraft |
|
485 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
486 | - * |
|
487 | - */ |
|
481 | + * Gets the aircraft image from airport-data |
|
482 | + * |
|
483 | + * @param String $aircraft_registration the registration of the aircraft |
|
484 | + * @param String $aircraft_name type of the aircraft |
|
485 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
486 | + * |
|
487 | + */ |
|
488 | 488 | public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
489 | 489 | $Common = new Common(); |
490 | 490 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
@@ -503,13 +503,13 @@ discard block |
||
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
506 | - * Gets image from WikiMedia |
|
507 | - * |
|
508 | - * @param String $registration the registration of the aircraft/mmsi |
|
509 | - * @param String $name name |
|
510 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
511 | - * |
|
512 | - */ |
|
506 | + * Gets image from WikiMedia |
|
507 | + * |
|
508 | + * @param String $registration the registration of the aircraft/mmsi |
|
509 | + * @param String $name name |
|
510 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
511 | + * |
|
512 | + */ |
|
513 | 513 | public function fromWikimedia($type,$registration,$name='') { |
514 | 514 | $Common = new Common(); |
515 | 515 | if ($type == 'aircraft') { |
@@ -564,13 +564,13 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
567 | - * Gets the aircraft image from custom url |
|
568 | - * |
|
569 | - * @param String $registration the registration of the aircraft |
|
570 | - * @param String $name type of the aircraft |
|
571 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
572 | - * |
|
573 | - */ |
|
567 | + * Gets the aircraft image from custom url |
|
568 | + * |
|
569 | + * @param String $registration the registration of the aircraft |
|
570 | + * @param String $name type of the aircraft |
|
571 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
572 | + * |
|
573 | + */ |
|
574 | 574 | public function fromCustomSource($type,$registration,$name='') { |
575 | 575 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
576 | 576 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
@@ -18,22 +18,22 @@ discard block |
||
18 | 18 | * @return Array the images list |
19 | 19 | * |
20 | 20 | */ |
21 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
21 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
22 | 22 | { |
23 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
24 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
25 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
23 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
24 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
25 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
26 | 26 | $reg = $registration; |
27 | 27 | if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
28 | 28 | $reg = trim($reg); |
29 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
29 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
30 | 30 | FROM spotter_image |
31 | 31 | WHERE spotter_image.registration = :registration LIMIT 1"; |
32 | 32 | $sth = $this->db->prepare($query); |
33 | 33 | $sth->execute(array(':registration' => $reg)); |
34 | 34 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | 35 | if (!empty($result)) return $result; |
36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
36 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
37 | 37 | else return array(); |
38 | 38 | } |
39 | 39 | |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | * @return Array the images list |
44 | 44 | * |
45 | 45 | */ |
46 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
46 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
47 | 47 | { |
48 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
49 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
50 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
48 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
49 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
50 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
51 | 51 | $name = trim($name); |
52 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
52 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
53 | 53 | FROM marine_image |
54 | 54 | WHERE marine_image.mmsi = :mmsi"; |
55 | 55 | $query_data = array(':mmsi' => $mmsi); |
56 | 56 | if ($imo != '') { |
57 | 57 | $query .= " AND marine_image.imo = :imo"; |
58 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
58 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
59 | 59 | } |
60 | 60 | if ($name != '') { |
61 | 61 | $query .= " AND marine_image.name = :name"; |
62 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
62 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
63 | 63 | } |
64 | 64 | $query .= " LIMIT 1"; |
65 | 65 | $sth = $this->db->prepare($query); |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
81 | 81 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
82 | 82 | if ($copyright != '') { |
83 | - $copyright = str_replace('Copyright ','',$copyright); |
|
84 | - $copyright = str_replace('© ','',$copyright); |
|
85 | - $copyright = str_replace('(c) ','',$copyright); |
|
83 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
84 | + $copyright = str_replace('© ', '', $copyright); |
|
85 | + $copyright = str_replace('(c) ', '', $copyright); |
|
86 | 86 | } |
87 | 87 | return $copyright; |
88 | 88 | } |
@@ -93,25 +93,25 @@ discard block |
||
93 | 93 | * @return String either success or error |
94 | 94 | * |
95 | 95 | */ |
96 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
96 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
97 | 97 | { |
98 | - global $globalDebug,$globalAircraftImageFetch; |
|
98 | + global $globalDebug, $globalAircraftImageFetch; |
|
99 | 99 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
100 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
100 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
101 | 101 | $registration = trim($registration); |
102 | 102 | //getting the aircraft image |
103 | 103 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
104 | 104 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
105 | 105 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
106 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
106 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
107 | 107 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
108 | 108 | if ($image_url['original'] != '') { |
109 | 109 | if ($globalDebug) echo 'Found !'."\n"; |
110 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
110 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
111 | 111 | try { |
112 | 112 | $sth = $this->db->prepare($query); |
113 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
114 | - } catch(PDOException $e) { |
|
113 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
114 | + } catch (PDOException $e) { |
|
115 | 115 | echo $e->getMessage()."\n"; |
116 | 116 | return "error"; |
117 | 117 | } |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | * @return String either success or error |
126 | 126 | * |
127 | 127 | */ |
128 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
128 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
129 | 129 | { |
130 | - global $globalDebug,$globalMarineImageFetch; |
|
130 | + global $globalDebug, $globalMarineImageFetch; |
|
131 | 131 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
132 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
133 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
134 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
132 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
133 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
134 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
135 | 135 | $name = trim($name); |
136 | 136 | $Marine = new Marine($this->db); |
137 | 137 | if ($imo == '' || $name == '') { |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | |
146 | 146 | //getting the aircraft image |
147 | 147 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
148 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
148 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
149 | 149 | if ($image_url['original'] != '') { |
150 | 150 | if ($globalDebug) echo 'Found !'."\n"; |
151 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
151 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
152 | 152 | try { |
153 | 153 | $sth = $this->db->prepare($query); |
154 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
155 | - } catch(PDOException $e) { |
|
154 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
155 | + } catch (PDOException $e) { |
|
156 | 156 | echo $e->getMessage()."\n"; |
157 | 157 | return "error"; |
158 | 158 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
173 | 173 | $Spotter = new Spotter($this->db); |
174 | 174 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
175 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
175 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
176 | 176 | if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) { |
177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
177 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
178 | 178 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
179 | 179 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
180 | 180 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -188,25 +188,25 @@ discard block |
||
188 | 188 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
189 | 189 | else $aircraft_name = ''; |
190 | 190 | $aircraft_registration = $aircraft_icao; |
191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
191 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
192 | 192 | unset($Spotter); |
193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
193 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
194 | 194 | foreach ($globalAircraftImageSources as $source) { |
195 | 195 | $source = strtolower($source); |
196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
196 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
197 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
198 | + if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
199 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
200 | + if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
201 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
202 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
203 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
204 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
205 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
206 | 206 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
207 | 207 | } |
208 | 208 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
209 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
209 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @return Array the aircraft thumbnail, orignal url and copyright |
219 | 219 | * |
220 | 220 | */ |
221 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
221 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
222 | 222 | { |
223 | 223 | global $globalMarineImageSources; |
224 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
224 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
225 | 225 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
226 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
226 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
227 | 227 | $name = trim($name); |
228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
228 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
229 | 229 | /* |
230 | 230 | $Marine = new Marine($this->db); |
231 | 231 | if ($imo == '' || $name == '') { |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | } |
238 | 238 | unset($Marine); |
239 | 239 | */ |
240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
240 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
241 | 241 | foreach ($globalMarineImageSources as $source) { |
242 | 242 | $source = strtolower($source); |
243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
243 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
244 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
245 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
246 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
247 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
248 | 248 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
249 | 249 | } |
250 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
250 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * @return Array the aircraft thumbnail, orignal url and copyright |
259 | 259 | * |
260 | 260 | */ |
261 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
261 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
262 | 262 | $Common = new Common(); |
263 | 263 | // If aircraft registration is only number, also check with aircraft model |
264 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
265 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
264 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
265 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
266 | 266 | } else { |
267 | 267 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
268 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
268 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
269 | 269 | } |
270 | 270 | $data = $Common->getData($url); |
271 | 271 | if (substr($data, 0, 5) != "<?xml") return false; |
272 | 272 | if ($xml = simplexml_load_string($data)) { |
273 | 273 | if (isset($xml->channel->item)) { |
274 | 274 | $image_url = array(); |
275 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
275 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
276 | 276 | $image_url['thumbnail'] = $thumbnail_url; |
277 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
278 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
279 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
277 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
278 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
279 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
280 | 280 | $image_url['source'] = 'planespotters'; |
281 | 281 | return $image_url; |
282 | 282 | } |
@@ -292,31 +292,31 @@ discard block |
||
292 | 292 | * @return Array the aircraft thumbnail, orignal url and copyright |
293 | 293 | * |
294 | 294 | */ |
295 | - public function fromDeviantart($type,$registration, $name='') { |
|
295 | + public function fromDeviantart($type, $registration, $name = '') { |
|
296 | 296 | $Common = new Common(); |
297 | 297 | if ($type == 'aircraft') { |
298 | 298 | // If aircraft registration is only number, also check with aircraft model |
299 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
299 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
301 | 301 | } else { |
302 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
302 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
303 | 303 | } |
304 | 304 | } elseif ($type == 'marine') { |
305 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
305 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
306 | 306 | } else { |
307 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
307 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
308 | 308 | } |
309 | 309 | $data = $Common->getData($url); |
310 | 310 | if (substr($data, 0, 5) != "<?xml") return false; |
311 | 311 | if ($xml = simplexml_load_string($data)) { |
312 | 312 | if (isset($xml->channel->item->link)) { |
313 | 313 | $image_url = array(); |
314 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
314 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
315 | 315 | $image_url['thumbnail'] = $thumbnail_url; |
316 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
316 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
317 | 317 | $image_url['original'] = $original_url; |
318 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
319 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
318 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
319 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
320 | 320 | $image_url['source'] = 'deviantart'; |
321 | 321 | return $image_url; |
322 | 322 | } |
@@ -332,32 +332,32 @@ discard block |
||
332 | 332 | * @return Array the aircraft thumbnail, orignal url and copyright |
333 | 333 | * |
334 | 334 | */ |
335 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
335 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
336 | 336 | $Common = new Common(); |
337 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
337 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
338 | 338 | $data = $Common->getData($url); |
339 | 339 | $dom = new DOMDocument(); |
340 | 340 | @$dom->loadHTML($data); |
341 | 341 | $all_pics = array(); |
342 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
342 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
343 | 343 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
344 | 344 | $all_pics[] = $image->getAttribute('src'); |
345 | 345 | } |
346 | 346 | } |
347 | 347 | $all_authors = array(); |
348 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
348 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
349 | 349 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
350 | 350 | $all_authors[] = $author->getAttribute('content'); |
351 | 351 | } |
352 | 352 | } |
353 | 353 | $all_ref = array(); |
354 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
354 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
355 | 355 | $all_ref[] = $link->getAttribute('href'); |
356 | 356 | } |
357 | 357 | if (isset($all_pics[0])) { |
358 | 358 | $image_url = array(); |
359 | 359 | $image_url['thumbnail'] = $all_pics[0]; |
360 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
360 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
361 | 361 | $image_url['copyright'] = $all_authors[0]; |
362 | 362 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
363 | 363 | $image_url['source'] = 'JetPhotos'; |
@@ -374,24 +374,24 @@ discard block |
||
374 | 374 | * @return Array the aircraft thumbnail, orignal url and copyright |
375 | 375 | * |
376 | 376 | */ |
377 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
377 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
378 | 378 | $Common = new Common(); |
379 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
379 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
380 | 380 | $data = $Common->getData($url); |
381 | 381 | $dom = new DOMDocument(); |
382 | 382 | @$dom->loadHTML($data); |
383 | 383 | $all_pics = array(); |
384 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
384 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
385 | 385 | $all_pics[] = $image->getAttribute('src'); |
386 | 386 | } |
387 | 387 | $all_links = array(); |
388 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
389 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
388 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
389 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
390 | 390 | } |
391 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
391 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
392 | 392 | $image_url = array(); |
393 | 393 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
394 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
394 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
395 | 395 | $image_url['copyright'] = $all_links[6]['text']; |
396 | 396 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
397 | 397 | $image_url['source'] = 'PlanePictures'; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return Array the aircraft thumbnail, orignal url and copyright |
409 | 409 | * |
410 | 410 | */ |
411 | - public function fromFlickr($type,$registration,$name='') { |
|
411 | + public function fromFlickr($type, $registration, $name = '') { |
|
412 | 412 | $Common = new Common(); |
413 | 413 | if ($type == 'aircraft') { |
414 | 414 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | if (substr($data, 0, 5) != "<?xml") return false; |
422 | 422 | if ($xml = simplexml_load_string($data)) { |
423 | 423 | if (isset($xml->channel->item)) { |
424 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
424 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
425 | 425 | $image_url = array(); |
426 | 426 | $image_url['thumbnail'] = $original_url; |
427 | 427 | $image_url['original'] = $original_url; |
428 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
429 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
428 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
429 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
430 | 430 | $image_url['source'] = 'flickr'; |
431 | 431 | return $image_url; |
432 | 432 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | |
437 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
437 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
438 | 438 | $Common = new Common(); |
439 | 439 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
440 | 440 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @return Array the aircraft thumbnail, orignal url and copyright |
459 | 459 | * |
460 | 460 | */ |
461 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
461 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
462 | 462 | global $globalImageBingKey; |
463 | 463 | $Common = new Common(); |
464 | 464 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
470 | 470 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
471 | 471 | } |
472 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
473 | - $data = $Common->getData($url,'get','',$headers); |
|
472 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
473 | + $data = $Common->getData($url, 'get', '', $headers); |
|
474 | 474 | $result = json_decode($data); |
475 | 475 | if (isset($result->d->results[0]->MediaUrl)) { |
476 | 476 | $image_url = array(); |
@@ -495,14 +495,14 @@ discard block |
||
495 | 495 | * @return Array the aircraft thumbnail, orignal url and copyright |
496 | 496 | * |
497 | 497 | */ |
498 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
498 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
499 | 499 | $Common = new Common(); |
500 | 500 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
501 | 501 | $data = $Common->getData($url); |
502 | 502 | $result = json_decode($data); |
503 | 503 | if (isset($result->count) && $result->count > 0) { |
504 | 504 | $image_url = array(); |
505 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
505 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
506 | 506 | $image_url['source_website'] = $result->data[0]->link; |
507 | 507 | $image_url['thumbnail'] = $result->data[0]->image; |
508 | 508 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @return Array the aircraft thumbnail, orignal url and copyright |
521 | 521 | * |
522 | 522 | */ |
523 | - public function fromWikimedia($type,$registration,$name='') { |
|
523 | + public function fromWikimedia($type, $registration, $name = '') { |
|
524 | 524 | $Common = new Common(); |
525 | 525 | if ($type == 'aircraft') { |
526 | 526 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $result = json_decode($data); |
534 | 534 | if (isset($result->query->search[0]->title)) { |
535 | 535 | $fileo = $result->query->search[0]->title; |
536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
536 | + if (substr($fileo, -3) == 'pdf') return false; |
|
537 | 537 | $file = urlencode($fileo); |
538 | 538 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
539 | 539 | $data2 = $Common->getData($url2); |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | if (isset($result2->query->pages)) { |
559 | 559 | foreach ($result2->query->pages as $page) { |
560 | 560 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
561 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
561 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
562 | 562 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
563 | 563 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
564 | 564 | } |
565 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
565 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
566 | 566 | return $image_url; |
567 | 567 | } |
568 | 568 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @return Array the aircraft thumbnail, orignal url and copyright |
582 | 582 | * |
583 | 583 | */ |
584 | - public function fromCustomSource($type,$registration,$name='') { |
|
584 | + public function fromCustomSource($type, $registration, $name = '') { |
|
585 | 585 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
586 | 586 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
587 | 587 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | print_r($source); |
599 | 599 | print_r($customsources); |
600 | 600 | } |
601 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
602 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
601 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
602 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
603 | 603 | if ($Common->urlexist($url)) { |
604 | 604 | $image_url = array(); |
605 | 605 | $image_url['thumbnail'] = $url_thumbnail; |
606 | 606 | $image_url['original'] = $url; |
607 | 607 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
608 | 608 | else $exifCopyright = ''; |
609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
609 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
610 | 610 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
611 | 611 | else $image_url['copyright'] = $source['source_website']; |
612 | 612 | $image_url['source_website'] = $source['source_website']; |
@@ -630,19 +630,19 @@ discard block |
||
630 | 630 | print_r($source); |
631 | 631 | print_r($customsources); |
632 | 632 | } |
633 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
634 | - $url = str_replace('{mmsi}',$registration,$url); |
|
635 | - $url = str_replace('{name}',$name,$url); |
|
636 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
637 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
638 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
633 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
634 | + $url = str_replace('{mmsi}', $registration, $url); |
|
635 | + $url = str_replace('{name}', $name, $url); |
|
636 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
637 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
638 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
639 | 639 | if ($Common->urlexist($url)) { |
640 | 640 | $image_url = array(); |
641 | 641 | $image_url['thumbnail'] = $url_thumbnail; |
642 | 642 | $image_url['original'] = $url; |
643 | 643 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
644 | 644 | else $exifCopyright = ''; |
645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
645 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
646 | 646 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
647 | 647 | else $image_url['copyright'] = $source['source_website']; |
648 | 648 | $image_url['source_website'] = $source['source_website']; |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | public function __construct($dbc = null) { |
10 | 10 | $Connection = new Connection($dbc); |
11 | 11 | $this->db = $Connection->db(); |
12 | - if ($this->db === null) die('Error: No DB connection. (Image)'); |
|
12 | + if ($this->db === null) { |
|
13 | + die('Error: No DB connection. (Image)'); |
|
14 | + } |
|
13 | 15 | } |
14 | 16 | |
15 | 17 | /** |
@@ -24,7 +26,9 @@ discard block |
||
24 | 26 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
25 | 27 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
26 | 28 | $reg = $registration; |
27 | - if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
29 | + if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') { |
|
30 | + $reg = $aircraft_icao.$airline_icao; |
|
31 | + } |
|
28 | 32 | $reg = trim($reg); |
29 | 33 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
30 | 34 | FROM spotter_image |
@@ -32,9 +36,13 @@ discard block |
||
32 | 36 | $sth = $this->db->prepare($query); |
33 | 37 | $sth->execute(array(':registration' => $reg)); |
34 | 38 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | - if (!empty($result)) return $result; |
|
36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
37 | - else return array(); |
|
39 | + if (!empty($result)) { |
|
40 | + return $result; |
|
41 | + } elseif ($registration != '') { |
|
42 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
43 | + } else { |
|
44 | + return array(); |
|
45 | + } |
|
38 | 46 | } |
39 | 47 | |
40 | 48 | /** |
@@ -77,8 +85,11 @@ discard block |
||
77 | 85 | public function getExifCopyright($url) { |
78 | 86 | $exif = exif_read_data($url); |
79 | 87 | $copyright = ''; |
80 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
81 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
88 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
89 | + $copyright = $exif['COMPUTED']['copyright']; |
|
90 | + } elseif (isset($exif['copyright'])) { |
|
91 | + $copyright = $exif['copyright']; |
|
92 | + } |
|
82 | 93 | if ($copyright != '') { |
83 | 94 | $copyright = str_replace('Copyright ','',$copyright); |
84 | 95 | $copyright = str_replace('© ','',$copyright); |
@@ -96,17 +107,27 @@ discard block |
||
96 | 107 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
97 | 108 | { |
98 | 109 | global $globalDebug,$globalAircraftImageFetch; |
99 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
110 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
111 | + return ''; |
|
112 | + } |
|
100 | 113 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
101 | 114 | $registration = trim($registration); |
102 | 115 | //getting the aircraft image |
103 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
104 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
105 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
116 | + if ($globalDebug && $registration != '') { |
|
117 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
118 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
119 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
120 | + } elseif ($globalDebug && $airline_icao != '') { |
|
121 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
122 | + } |
|
106 | 123 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
107 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
124 | + if ($registration == '' && $aircraft_icao != '') { |
|
125 | + $registration = $aircraft_icao.$airline_icao; |
|
126 | + } |
|
108 | 127 | if ($image_url['original'] != '') { |
109 | - if ($globalDebug) echo 'Found !'."\n"; |
|
128 | + if ($globalDebug) { |
|
129 | + echo 'Found !'."\n"; |
|
130 | + } |
|
110 | 131 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
111 | 132 | try { |
112 | 133 | $sth = $this->db->prepare($query); |
@@ -115,7 +136,9 @@ discard block |
||
115 | 136 | echo $e->getMessage()."\n"; |
116 | 137 | return "error"; |
117 | 138 | } |
118 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
139 | + } elseif ($globalDebug) { |
|
140 | + echo "Not found :'(\n"; |
|
141 | + } |
|
119 | 142 | return "success"; |
120 | 143 | } |
121 | 144 | |
@@ -128,7 +151,9 @@ discard block |
||
128 | 151 | public function addMarineImage($mmsi,$imo = '',$name = '') |
129 | 152 | { |
130 | 153 | global $globalDebug,$globalMarineImageFetch; |
131 | - if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
|
154 | + if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) { |
|
155 | + return ''; |
|
156 | + } |
|
132 | 157 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
133 | 158 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
134 | 159 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -138,16 +163,22 @@ discard block |
||
138 | 163 | $identity = $Marine->getIdentity($mmsi); |
139 | 164 | if (isset($identity[0]['mmsi'])) { |
140 | 165 | $imo = $identity[0]['imo']; |
141 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
166 | + if ($identity[0]['ship_name'] != '') { |
|
167 | + $name = $identity[0]['ship_name']; |
|
168 | + } |
|
142 | 169 | } |
143 | 170 | } |
144 | 171 | unset($Marine); |
145 | 172 | |
146 | 173 | //getting the aircraft image |
147 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
174 | + if ($globalDebug && $name != '') { |
|
175 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
176 | + } |
|
148 | 177 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
149 | 178 | if ($image_url['original'] != '') { |
150 | - if ($globalDebug) echo 'Found !'."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo 'Found !'."\n"; |
|
181 | + } |
|
151 | 182 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
152 | 183 | try { |
153 | 184 | $sth = $this->db->prepare($query); |
@@ -156,7 +187,9 @@ discard block |
||
156 | 187 | echo $e->getMessage()."\n"; |
157 | 188 | return "error"; |
158 | 189 | } |
159 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
190 | + } elseif ($globalDebug) { |
|
191 | + echo "Not found :'(\n"; |
|
192 | + } |
|
160 | 193 | return "success"; |
161 | 194 | } |
162 | 195 | |
@@ -171,41 +204,85 @@ discard block |
||
171 | 204 | { |
172 | 205 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
173 | 206 | $Spotter = new Spotter($this->db); |
174 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
207 | + if (!isset($globalIVAO)) { |
|
208 | + $globalIVAO = FALSE; |
|
209 | + } |
|
175 | 210 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
176 | 211 | if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) { |
177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
212 | + if (strpos($aircraft_registration,'/') !== false) { |
|
213 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
214 | + } |
|
178 | 215 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
179 | 216 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
180 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
181 | - else $aircraft_name = ''; |
|
182 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
183 | - else $aircraft_icao = ''; |
|
184 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
185 | - else $airline_icao = ''; |
|
217 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
218 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
219 | + } else { |
|
220 | + $aircraft_name = ''; |
|
221 | + } |
|
222 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
223 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
224 | + } else { |
|
225 | + $aircraft_icao = ''; |
|
226 | + } |
|
227 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
228 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
229 | + } else { |
|
230 | + $airline_icao = ''; |
|
231 | + } |
|
186 | 232 | } elseif ($aircraft_icao != '') { |
187 | 233 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
188 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
189 | - else $aircraft_name = ''; |
|
234 | + if (isset($aircraft_info[0]['type'])) { |
|
235 | + $aircraft_name = $aircraft_info[0]['type']; |
|
236 | + } else { |
|
237 | + $aircraft_name = ''; |
|
238 | + } |
|
190 | 239 | $aircraft_registration = $aircraft_icao; |
191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
240 | + } else { |
|
241 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
242 | + } |
|
192 | 243 | unset($Spotter); |
193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
244 | + if (!isset($globalAircraftImageSources)) { |
|
245 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
246 | + } |
|
194 | 247 | foreach ($globalAircraftImageSources as $source) { |
195 | 248 | $source = strtolower($source); |
196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
206 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
207 | - } |
|
208 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
249 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
250 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
251 | + } |
|
252 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) { |
|
253 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
254 | + } |
|
255 | + if ($source == 'flickr' && extension_loaded('simplexml')) { |
|
256 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
257 | + } |
|
258 | + if ($source == 'bing') { |
|
259 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
260 | + } |
|
261 | + if ($source == 'deviantart' && extension_loaded('simplexml')) { |
|
262 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
263 | + } |
|
264 | + if ($source == 'wikimedia') { |
|
265 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
266 | + } |
|
267 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) { |
|
268 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
269 | + } |
|
270 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) { |
|
271 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
272 | + } |
|
273 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
274 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
275 | + } |
|
276 | + if ($source == 'customsources') { |
|
277 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
278 | + } |
|
279 | + if (isset($images_array) && $images_array['original'] != '') { |
|
280 | + return $images_array; |
|
281 | + } |
|
282 | + } |
|
283 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
284 | + return $this->findAircraftImage($aircraft_icao); |
|
285 | + } |
|
209 | 286 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
210 | 287 | } |
211 | 288 | |
@@ -225,7 +302,9 @@ discard block |
||
225 | 302 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
226 | 303 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
227 | 304 | $name = trim($name); |
228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
305 | + if (strlen($name) < 4) { |
|
306 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
307 | + } |
|
229 | 308 | /* |
230 | 309 | $Marine = new Marine($this->db); |
231 | 310 | if ($imo == '' || $name == '') { |
@@ -237,15 +316,29 @@ discard block |
||
237 | 316 | } |
238 | 317 | unset($Marine); |
239 | 318 | */ |
240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
319 | + if (!isset($globalMarineImageSources)) { |
|
320 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
321 | + } |
|
241 | 322 | foreach ($globalMarineImageSources as $source) { |
242 | 323 | $source = strtolower($source); |
243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
248 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
324 | + if ($source == 'flickr') { |
|
325 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
326 | + } |
|
327 | + if ($source == 'bing') { |
|
328 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
329 | + } |
|
330 | + if ($source == 'deviantart') { |
|
331 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
332 | + } |
|
333 | + if ($source == 'wikimedia') { |
|
334 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
335 | + } |
|
336 | + if ($source == 'customsources') { |
|
337 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
338 | + } |
|
339 | + if (isset($images_array) && $images_array['original'] != '') { |
|
340 | + return $images_array; |
|
341 | + } |
|
249 | 342 | } |
250 | 343 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
251 | 344 | } |
@@ -268,7 +361,9 @@ discard block |
||
268 | 361 | $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
269 | 362 | } |
270 | 363 | $data = $Common->getData($url); |
271 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
364 | + if (substr($data, 0, 5) != "<?xml") { |
|
365 | + return false; |
|
366 | + } |
|
272 | 367 | if ($xml = simplexml_load_string($data)) { |
273 | 368 | if (isset($xml->channel->item)) { |
274 | 369 | $image_url = array(); |
@@ -307,7 +402,9 @@ discard block |
||
307 | 402 | $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
308 | 403 | } |
309 | 404 | $data = $Common->getData($url); |
310 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
405 | + if (substr($data, 0, 5) != "<?xml") { |
|
406 | + return false; |
|
407 | + } |
|
311 | 408 | if ($xml = simplexml_load_string($data)) { |
312 | 409 | if (isset($xml->channel->item->link)) { |
313 | 410 | $image_url = array(); |
@@ -411,14 +508,22 @@ discard block |
||
411 | 508 | public function fromFlickr($type,$registration,$name='') { |
412 | 509 | $Common = new Common(); |
413 | 510 | if ($type == 'aircraft') { |
414 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
415 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
511 | + if ($name != '') { |
|
512 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
513 | + } else { |
|
514 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
515 | + } |
|
416 | 516 | } elseif ($type == 'marine') { |
417 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
418 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
517 | + if ($name != '') { |
|
518 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
519 | + } else { |
|
520 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
521 | + } |
|
419 | 522 | } |
420 | 523 | $data = $Common->getData($url); |
421 | - if (substr($data, 0, 5) != "<?xml") return false; |
|
524 | + if (substr($data, 0, 5) != "<?xml") { |
|
525 | + return false; |
|
526 | + } |
|
422 | 527 | if ($xml = simplexml_load_string($data)) { |
423 | 528 | if (isset($xml->channel->item)) { |
424 | 529 | $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
@@ -461,13 +566,21 @@ discard block |
||
461 | 566 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
462 | 567 | global $globalImageBingKey; |
463 | 568 | $Common = new Common(); |
464 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
569 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
570 | + return false; |
|
571 | + } |
|
465 | 572 | if ($type == 'aircraft') { |
466 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
467 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
573 | + if ($aircraft_name != '') { |
|
574 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
575 | + } else { |
|
576 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
577 | + } |
|
468 | 578 | } elseif ($type == 'marine') { |
469 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
470 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
579 | + if ($aircraft_name != '') { |
|
580 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
581 | + } else { |
|
582 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
583 | + } |
|
471 | 584 | } |
472 | 585 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
473 | 586 | $data = $Common->getData($url,'get','',$headers); |
@@ -523,17 +636,25 @@ discard block |
||
523 | 636 | public function fromWikimedia($type,$registration,$name='') { |
524 | 637 | $Common = new Common(); |
525 | 638 | if ($type == 'aircraft') { |
526 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
527 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
639 | + if ($name != '') { |
|
640 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
641 | + } else { |
|
642 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
643 | + } |
|
528 | 644 | } elseif ($type == 'marine') { |
529 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
530 | - else return false; |
|
645 | + if ($name != '') { |
|
646 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
647 | + } else { |
|
648 | + return false; |
|
649 | + } |
|
531 | 650 | } |
532 | 651 | $data = $Common->getData($url); |
533 | 652 | $result = json_decode($data); |
534 | 653 | if (isset($result->query->search[0]->title)) { |
535 | 654 | $fileo = $result->query->search[0]->title; |
536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
655 | + if (substr($fileo,-3) == 'pdf') { |
|
656 | + return false; |
|
657 | + } |
|
537 | 658 | $file = urlencode($fileo); |
538 | 659 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
539 | 660 | $data2 = $Common->getData($url2); |
@@ -604,18 +725,27 @@ discard block |
||
604 | 725 | $image_url = array(); |
605 | 726 | $image_url['thumbnail'] = $url_thumbnail; |
606 | 727 | $image_url['original'] = $url; |
607 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
608 | - else $exifCopyright = ''; |
|
609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
610 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
611 | - else $image_url['copyright'] = $source['source_website']; |
|
728 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
729 | + $exifCopyright = $this->getExifCopyright($url); |
|
730 | + } else { |
|
731 | + $exifCopyright = ''; |
|
732 | + } |
|
733 | + if ($exifCopyright != '') { |
|
734 | + $image_url['copyright'] = $exifCopyright; |
|
735 | + } elseif (isset($source['copyright'])) { |
|
736 | + $image_url['copyright'] = $source['copyright']; |
|
737 | + } else { |
|
738 | + $image_url['copyright'] = $source['source_website']; |
|
739 | + } |
|
612 | 740 | $image_url['source_website'] = $source['source_website']; |
613 | 741 | $image_url['source'] = $source['source']; |
614 | 742 | return $image_url; |
615 | 743 | } |
616 | 744 | } |
617 | 745 | return false; |
618 | - } else return false; |
|
746 | + } else { |
|
747 | + return false; |
|
748 | + } |
|
619 | 749 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
620 | 750 | $customsources = array(); |
621 | 751 | if (!isset($globalMarineImageCustomSources[0])) { |
@@ -640,18 +770,27 @@ discard block |
||
640 | 770 | $image_url = array(); |
641 | 771 | $image_url['thumbnail'] = $url_thumbnail; |
642 | 772 | $image_url['original'] = $url; |
643 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
644 | - else $exifCopyright = ''; |
|
645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
646 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
647 | - else $image_url['copyright'] = $source['source_website']; |
|
773 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
774 | + $exifCopyright = $this->getExifCopyright($url); |
|
775 | + } else { |
|
776 | + $exifCopyright = ''; |
|
777 | + } |
|
778 | + if ($exifCopyright != '') { |
|
779 | + $image_url['copyright'] = $exifCopyright; |
|
780 | + } elseif (isset($source['copyright'])) { |
|
781 | + $image_url['copyright'] = $source['copyright']; |
|
782 | + } else { |
|
783 | + $image_url['copyright'] = $source['source_website']; |
|
784 | + } |
|
648 | 785 | $image_url['source_website'] = $source['source_website']; |
649 | 786 | $image_url['source'] = $source['source']; |
650 | 787 | return $image_url; |
651 | 788 | } |
652 | 789 | } |
653 | 790 | return false; |
654 | - } else return false; |
|
791 | + } else { |
|
792 | + return false; |
|
793 | + } |
|
655 | 794 | } |
656 | 795 | } |
657 | 796 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | - * Get SQL query part for filter used |
|
14 | - * @param Array $filter the filter |
|
15 | - * @return Array the SQL part |
|
16 | - */ |
|
13 | + * Get SQL query part for filter used |
|
14 | + * @param Array $filter the filter |
|
15 | + * @return Array the SQL part |
|
16 | + */ |
|
17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $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,178 +157,178 @@ 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 | - */ |
|
326 | + /** |
|
327 | + * Gets all the archive spotter information |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | 332 | public function getMarineArchiveData($ident,$fammarine_id,$date) |
333 | 333 | { |
334 | 334 | $Marine = new Marine($this->db); |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | return $spotter_array; |
339 | 339 | } |
340 | 340 | |
341 | - /** |
|
342 | - * Delete all tracking data |
|
343 | - * |
|
344 | - */ |
|
341 | + /** |
|
342 | + * Delete all tracking data |
|
343 | + * |
|
344 | + */ |
|
345 | 345 | public function deleteMarineArchiveTrackData() |
346 | 346 | { |
347 | 347 | global $globalArchiveKeepTrackMonths, $globalDBdriver; |
@@ -360,34 +360,34 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
363 | - * Gets Minimal Live Marine data |
|
364 | - * |
|
365 | - * @return Array the spotter information |
|
366 | - * |
|
367 | - */ |
|
368 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
369 | - { |
|
370 | - global $globalDBdriver, $globalLiveInterval; |
|
371 | - date_default_timezone_set('UTC'); |
|
372 | - |
|
373 | - $filter_query = ''; |
|
374 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
375 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
376 | - } |
|
377 | - // Use spotter_output also ? |
|
378 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
379 | - $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 "; |
|
380 | - } |
|
381 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
382 | - $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 "; |
|
383 | - } |
|
384 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
385 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
386 | - } |
|
363 | + * Gets Minimal Live Marine data |
|
364 | + * |
|
365 | + * @return Array the spotter information |
|
366 | + * |
|
367 | + */ |
|
368 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
369 | + { |
|
370 | + global $globalDBdriver, $globalLiveInterval; |
|
371 | + date_default_timezone_set('UTC'); |
|
387 | 372 | |
388 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
389 | - if ($globalDBdriver == 'mysql') { |
|
390 | - /* |
|
373 | + $filter_query = ''; |
|
374 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
375 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
376 | + } |
|
377 | + // Use spotter_output also ? |
|
378 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
379 | + $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 "; |
|
380 | + } |
|
381 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
382 | + $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 "; |
|
383 | + } |
|
384 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
385 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
386 | + } |
|
387 | + |
|
388 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
389 | + if ($globalDBdriver == 'mysql') { |
|
390 | + /* |
|
391 | 391 | $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 |
392 | 392 | FROM marine_archive |
393 | 393 | 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'; |
@@ -406,56 +406,56 @@ discard block |
||
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
407 | 407 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
408 | 408 | '.$filter_query.' ORDER BY fammarine_id'; |
409 | - } else { |
|
410 | - //$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'; |
|
411 | - $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 |
|
409 | + } else { |
|
410 | + //$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'; |
|
411 | + $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 |
|
412 | 412 | FROM marine_archive |
413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
414 | 414 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
415 | 415 | '.$filter_query.' ORDER BY fammarine_id'; |
416 | - } |
|
417 | - //echo $query; |
|
418 | - try { |
|
419 | - $sth = $this->db->prepare($query); |
|
420 | - $sth->execute(); |
|
421 | - } catch(PDOException $e) { |
|
422 | - echo $e->getMessage(); |
|
423 | - die; |
|
424 | - } |
|
425 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
416 | + } |
|
417 | + //echo $query; |
|
418 | + try { |
|
419 | + $sth = $this->db->prepare($query); |
|
420 | + $sth->execute(); |
|
421 | + } catch(PDOException $e) { |
|
422 | + echo $e->getMessage(); |
|
423 | + die; |
|
424 | + } |
|
425 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
426 | 426 | |
427 | - return $spotter_array; |
|
428 | - } |
|
427 | + return $spotter_array; |
|
428 | + } |
|
429 | 429 | |
430 | 430 | /** |
431 | - * Gets Minimal Live Marine data |
|
432 | - * |
|
433 | - * @return Array the spotter information |
|
434 | - * |
|
435 | - */ |
|
436 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
437 | - { |
|
438 | - global $globalDBdriver, $globalLiveInterval; |
|
439 | - date_default_timezone_set('UTC'); |
|
440 | - |
|
441 | - $filter_query = ''; |
|
442 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
443 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
444 | - } |
|
445 | - // Should use spotter_output also ? |
|
446 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
447 | - $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 "; |
|
448 | - } |
|
449 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
450 | - $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 "; |
|
451 | - } |
|
452 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
453 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
454 | - } |
|
431 | + * Gets Minimal Live Marine data |
|
432 | + * |
|
433 | + * @return Array the spotter information |
|
434 | + * |
|
435 | + */ |
|
436 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
437 | + { |
|
438 | + global $globalDBdriver, $globalLiveInterval; |
|
439 | + date_default_timezone_set('UTC'); |
|
455 | 440 | |
456 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
457 | - if ($globalDBdriver == 'mysql') { |
|
458 | - /* |
|
441 | + $filter_query = ''; |
|
442 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
443 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
444 | + } |
|
445 | + // Should use spotter_output also ? |
|
446 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
447 | + $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 "; |
|
448 | + } |
|
449 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
450 | + $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 "; |
|
451 | + } |
|
452 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
453 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
454 | + } |
|
455 | + |
|
456 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
457 | + if ($globalDBdriver == 'mysql') { |
|
458 | + /* |
|
459 | 459 | $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 |
460 | 460 | FROM marine_archive |
461 | 461 | 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'; |
@@ -466,95 +466,95 @@ discard block |
||
466 | 466 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
467 | 467 | '.$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'; |
468 | 468 | |
469 | - } else { |
|
470 | - //$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'; |
|
471 | - /* |
|
469 | + } else { |
|
470 | + //$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'; |
|
471 | + /* |
|
472 | 472 | $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 |
473 | 473 | FROM marine_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$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'; |
477 | 477 | */ |
478 | - $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 |
|
478 | + $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 |
|
479 | 479 | FROM marine_archive_output |
480 | 480 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
481 | 481 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
482 | 482 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
483 | 483 | // .' 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'; |
484 | 484 | |
485 | - } |
|
486 | - //echo $query; |
|
487 | - try { |
|
488 | - $sth = $this->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - echo $e->getMessage(); |
|
492 | - die; |
|
493 | - } |
|
494 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
485 | + } |
|
486 | + //echo $query; |
|
487 | + try { |
|
488 | + $sth = $this->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + echo $e->getMessage(); |
|
492 | + die; |
|
493 | + } |
|
494 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
495 | 495 | |
496 | - return $spotter_array; |
|
497 | - } |
|
496 | + return $spotter_array; |
|
497 | + } |
|
498 | 498 | |
499 | 499 | /** |
500 | - * Gets count Live Marine data |
|
501 | - * |
|
502 | - * @return Array the spotter information |
|
503 | - * |
|
504 | - */ |
|
505 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
506 | - { |
|
507 | - global $globalDBdriver, $globalLiveInterval; |
|
508 | - date_default_timezone_set('UTC'); |
|
509 | - |
|
510 | - $filter_query = ''; |
|
511 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
512 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
513 | - } |
|
514 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
515 | - $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 "; |
|
516 | - } |
|
517 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
518 | - $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 "; |
|
519 | - } |
|
520 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
521 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
522 | - } |
|
500 | + * Gets count Live Marine data |
|
501 | + * |
|
502 | + * @return Array the spotter information |
|
503 | + * |
|
504 | + */ |
|
505 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
506 | + { |
|
507 | + global $globalDBdriver, $globalLiveInterval; |
|
508 | + date_default_timezone_set('UTC'); |
|
523 | 509 | |
524 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
525 | - if ($globalDBdriver == 'mysql') { |
|
510 | + $filter_query = ''; |
|
511 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
512 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
513 | + } |
|
514 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
515 | + $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 "; |
|
516 | + } |
|
517 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
518 | + $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 "; |
|
519 | + } |
|
520 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
521 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
522 | + } |
|
523 | + |
|
524 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
525 | + if ($globalDBdriver == 'mysql') { |
|
526 | 526 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
527 | 527 | FROM marine_archive l |
528 | 528 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
529 | - } else { |
|
529 | + } else { |
|
530 | 530 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
531 | - } |
|
532 | - //echo $query; |
|
533 | - try { |
|
534 | - $sth = $this->db->prepare($query); |
|
535 | - $sth->execute(); |
|
536 | - } catch(PDOException $e) { |
|
537 | - echo $e->getMessage(); |
|
538 | - die; |
|
539 | - } |
|
531 | + } |
|
532 | + //echo $query; |
|
533 | + try { |
|
534 | + $sth = $this->db->prepare($query); |
|
535 | + $sth->execute(); |
|
536 | + } catch(PDOException $e) { |
|
537 | + echo $e->getMessage(); |
|
538 | + die; |
|
539 | + } |
|
540 | 540 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
541 | 541 | $sth->closeCursor(); |
542 | - return $result['nb']; |
|
542 | + return $result['nb']; |
|
543 | 543 | |
544 | - } |
|
544 | + } |
|
545 | 545 | |
546 | 546 | |
547 | 547 | |
548 | 548 | // marine_archive_output |
549 | 549 | |
550 | - /** |
|
551 | - * Gets all the spotter information |
|
552 | - * |
|
553 | - * @return Array the spotter information |
|
554 | - * |
|
555 | - */ |
|
556 | - 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()) |
|
557 | - { |
|
550 | + /** |
|
551 | + * Gets all the spotter information |
|
552 | + * |
|
553 | + * @return Array the spotter information |
|
554 | + * |
|
555 | + */ |
|
556 | + 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()) |
|
557 | + { |
|
558 | 558 | global $globalTimezone, $globalDBdriver; |
559 | 559 | require_once(dirname(__FILE__).'/class.Translation.php'); |
560 | 560 | $Translation = new Translation($this->db); |
@@ -568,159 +568,159 @@ discard block |
||
568 | 568 | $filter_query = $this->getFilter($filters); |
569 | 569 | if ($q != "") |
570 | 570 | { |
571 | - if (!is_string($q)) |
|
572 | - { |
|
571 | + if (!is_string($q)) |
|
572 | + { |
|
573 | 573 | return false; |
574 | - } else { |
|
574 | + } else { |
|
575 | 575 | |
576 | 576 | $q_array = explode(" ", $q); |
577 | 577 | |
578 | 578 | foreach ($q_array as $q_item){ |
579 | - $additional_query .= " AND ("; |
|
580 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
594 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
595 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
596 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
597 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
598 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
599 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
600 | - $translate = $Translation->ident2icao($q_item); |
|
601 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
602 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
603 | - $additional_query .= ")"; |
|
579 | + $additional_query .= " AND ("; |
|
580 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
594 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
595 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
596 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
597 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
598 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
599 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
600 | + $translate = $Translation->ident2icao($q_item); |
|
601 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
602 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
603 | + $additional_query .= ")"; |
|
604 | + } |
|
604 | 605 | } |
605 | - } |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | if ($registration != "") |
609 | 609 | { |
610 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
611 | - if (!is_string($registration)) |
|
612 | - { |
|
610 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
611 | + if (!is_string($registration)) |
|
612 | + { |
|
613 | 613 | return false; |
614 | - } else { |
|
614 | + } else { |
|
615 | 615 | $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
616 | - } |
|
616 | + } |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | if ($aircraft_icao != "") |
620 | 620 | { |
621 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
622 | - if (!is_string($aircraft_icao)) |
|
623 | - { |
|
621 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
622 | + if (!is_string($aircraft_icao)) |
|
623 | + { |
|
624 | 624 | return false; |
625 | - } else { |
|
625 | + } else { |
|
626 | 626 | $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
627 | - } |
|
627 | + } |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | if ($aircraft_manufacturer != "") |
631 | 631 | { |
632 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
633 | - if (!is_string($aircraft_manufacturer)) |
|
634 | - { |
|
632 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
633 | + if (!is_string($aircraft_manufacturer)) |
|
634 | + { |
|
635 | 635 | return false; |
636 | - } else { |
|
636 | + } else { |
|
637 | 637 | $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
638 | - } |
|
638 | + } |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | if ($highlights == "true") |
642 | 642 | { |
643 | - if (!is_string($highlights)) |
|
644 | - { |
|
643 | + if (!is_string($highlights)) |
|
644 | + { |
|
645 | 645 | return false; |
646 | - } else { |
|
646 | + } else { |
|
647 | 647 | $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
648 | - } |
|
648 | + } |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | if ($airline_icao != "") |
652 | 652 | { |
653 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
654 | - if (!is_string($airline_icao)) |
|
655 | - { |
|
653 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
654 | + if (!is_string($airline_icao)) |
|
655 | + { |
|
656 | 656 | return false; |
657 | - } else { |
|
657 | + } else { |
|
658 | 658 | $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
659 | - } |
|
659 | + } |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | if ($airline_country != "") |
663 | 663 | { |
664 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
665 | - if (!is_string($airline_country)) |
|
666 | - { |
|
664 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
665 | + if (!is_string($airline_country)) |
|
666 | + { |
|
667 | 667 | return false; |
668 | - } else { |
|
668 | + } else { |
|
669 | 669 | $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
670 | - } |
|
670 | + } |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | if ($airline_type != "") |
674 | 674 | { |
675 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
676 | - if (!is_string($airline_type)) |
|
677 | - { |
|
675 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
676 | + if (!is_string($airline_type)) |
|
677 | + { |
|
678 | 678 | return false; |
679 | - } else { |
|
679 | + } else { |
|
680 | 680 | if ($airline_type == "passenger") |
681 | 681 | { |
682 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
682 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
683 | 683 | } |
684 | 684 | if ($airline_type == "cargo") |
685 | 685 | { |
686 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
686 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
687 | 687 | } |
688 | 688 | if ($airline_type == "military") |
689 | 689 | { |
690 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
690 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
691 | + } |
|
691 | 692 | } |
692 | - } |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | if ($airport != "") |
696 | 696 | { |
697 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
698 | - if (!is_string($airport)) |
|
699 | - { |
|
697 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
698 | + if (!is_string($airport)) |
|
699 | + { |
|
700 | 700 | return false; |
701 | - } else { |
|
701 | + } else { |
|
702 | 702 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
703 | - } |
|
703 | + } |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | if ($airport_country != "") |
707 | 707 | { |
708 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
709 | - if (!is_string($airport_country)) |
|
710 | - { |
|
708 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
709 | + if (!is_string($airport_country)) |
|
710 | + { |
|
711 | 711 | return false; |
712 | - } else { |
|
712 | + } else { |
|
713 | 713 | $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
714 | - } |
|
714 | + } |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | if ($callsign != "") |
718 | 718 | { |
719 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
720 | - if (!is_string($callsign)) |
|
721 | - { |
|
719 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
720 | + if (!is_string($callsign)) |
|
721 | + { |
|
722 | 722 | return false; |
723 | - } else { |
|
723 | + } else { |
|
724 | 724 | $translate = $Translation->ident2icao($callsign); |
725 | 725 | if ($translate != $callsign) { |
726 | 726 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
@@ -728,99 +728,99 @@ discard block |
||
728 | 728 | } else { |
729 | 729 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
730 | 730 | } |
731 | - } |
|
731 | + } |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | if ($owner != "") |
735 | 735 | { |
736 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
737 | - if (!is_string($owner)) |
|
738 | - { |
|
736 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
737 | + if (!is_string($owner)) |
|
738 | + { |
|
739 | 739 | return false; |
740 | - } else { |
|
740 | + } else { |
|
741 | 741 | $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
742 | - } |
|
742 | + } |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | if ($pilot_name != "") |
746 | 746 | { |
747 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
748 | - if (!is_string($pilot_name)) |
|
749 | - { |
|
747 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
748 | + if (!is_string($pilot_name)) |
|
749 | + { |
|
750 | 750 | return false; |
751 | - } else { |
|
751 | + } else { |
|
752 | 752 | $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
753 | - } |
|
753 | + } |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | if ($pilot_id != "") |
757 | 757 | { |
758 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
759 | - if (!is_string($pilot_id)) |
|
760 | - { |
|
758 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
759 | + if (!is_string($pilot_id)) |
|
760 | + { |
|
761 | 761 | return false; |
762 | - } else { |
|
762 | + } else { |
|
763 | 763 | $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
764 | - } |
|
764 | + } |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | if ($departure_airport_route != "") |
768 | 768 | { |
769 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
770 | - if (!is_string($departure_airport_route)) |
|
771 | - { |
|
769 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
770 | + if (!is_string($departure_airport_route)) |
|
771 | + { |
|
772 | 772 | return false; |
773 | - } else { |
|
773 | + } else { |
|
774 | 774 | $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
775 | - } |
|
775 | + } |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | if ($arrival_airport_route != "") |
779 | 779 | { |
780 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
781 | - if (!is_string($arrival_airport_route)) |
|
782 | - { |
|
780 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
781 | + if (!is_string($arrival_airport_route)) |
|
782 | + { |
|
783 | 783 | return false; |
784 | - } else { |
|
784 | + } else { |
|
785 | 785 | $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
786 | - } |
|
786 | + } |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | if ($altitude != "") |
790 | 790 | { |
791 | - $altitude_array = explode(",", $altitude); |
|
791 | + $altitude_array = explode(",", $altitude); |
|
792 | 792 | |
793 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
793 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
795 | 795 | |
796 | 796 | |
797 | - if ($altitude_array[1] != "") |
|
798 | - { |
|
797 | + if ($altitude_array[1] != "") |
|
798 | + { |
|
799 | 799 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
800 | 800 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
801 | 801 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
802 | - } else { |
|
802 | + } else { |
|
803 | 803 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
804 | 804 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
805 | - } |
|
805 | + } |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | if ($date_posted != "") |
809 | 809 | { |
810 | - $date_array = explode(",", $date_posted); |
|
810 | + $date_array = explode(",", $date_posted); |
|
811 | 811 | |
812 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
812 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
814 | 814 | |
815 | - if ($globalTimezone != '') { |
|
815 | + if ($globalTimezone != '') { |
|
816 | 816 | date_default_timezone_set($globalTimezone); |
817 | 817 | $datetime = new DateTime(); |
818 | 818 | $offset = $datetime->format('P'); |
819 | - } else $offset = '+00:00'; |
|
819 | + } else $offset = '+00:00'; |
|
820 | 820 | |
821 | 821 | |
822 | - if ($date_array[1] != "") |
|
823 | - { |
|
822 | + if ($date_array[1] != "") |
|
823 | + { |
|
824 | 824 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
825 | 825 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
826 | 826 | if ($globalDBdriver == 'mysql') { |
@@ -828,28 +828,28 @@ discard block |
||
828 | 828 | } else { |
829 | 829 | $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) "; |
830 | 830 | } |
831 | - } else { |
|
831 | + } else { |
|
832 | 832 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
833 | - if ($globalDBdriver == 'mysql') { |
|
833 | + if ($globalDBdriver == 'mysql') { |
|
834 | 834 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
835 | 835 | } else { |
836 | 836 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
837 | 837 | } |
838 | - } |
|
838 | + } |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | if ($limit != "") |
842 | 842 | { |
843 | - $limit_array = explode(",", $limit); |
|
843 | + $limit_array = explode(",", $limit); |
|
844 | 844 | |
845 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
845 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
847 | 847 | |
848 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
849 | - { |
|
848 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
849 | + { |
|
850 | 850 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
851 | 851 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
852 | - } |
|
852 | + } |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | |
@@ -880,33 +880,33 @@ discard block |
||
880 | 880 | $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
881 | 881 | |
882 | 882 | return $spotter_array; |
883 | - } |
|
883 | + } |
|
884 | 884 | |
885 | - public function deleteMarineArchiveData() |
|
886 | - { |
|
885 | + public function deleteMarineArchiveData() |
|
886 | + { |
|
887 | 887 | global $globalArchiveKeepMonths, $globalDBdriver; |
888 | - date_default_timezone_set('UTC'); |
|
889 | - if ($globalDBdriver == 'mysql') { |
|
888 | + date_default_timezone_set('UTC'); |
|
889 | + if ($globalDBdriver == 'mysql') { |
|
890 | 890 | $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
891 | 891 | } else { |
892 | 892 | $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
893 | 893 | } |
894 | - try { |
|
895 | - $sth = $this->db->prepare($query); |
|
896 | - $sth->execute(); |
|
897 | - } catch(PDOException $e) { |
|
898 | - return "error"; |
|
899 | - } |
|
894 | + try { |
|
895 | + $sth = $this->db->prepare($query); |
|
896 | + $sth->execute(); |
|
897 | + } catch(PDOException $e) { |
|
898 | + return "error"; |
|
899 | + } |
|
900 | 900 | } |
901 | 901 | |
902 | - /** |
|
903 | - * Gets all the spotter information based on the callsign |
|
904 | - * |
|
905 | - * @return Array the spotter information |
|
906 | - * |
|
907 | - */ |
|
908 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
909 | - { |
|
902 | + /** |
|
903 | + * Gets all the spotter information based on the callsign |
|
904 | + * |
|
905 | + * @return Array the spotter information |
|
906 | + * |
|
907 | + */ |
|
908 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
909 | + { |
|
910 | 910 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
911 | 911 | |
912 | 912 | date_default_timezone_set('UTC'); |
@@ -918,35 +918,35 @@ discard block |
||
918 | 918 | |
919 | 919 | if ($ident != "") |
920 | 920 | { |
921 | - if (!is_string($ident)) |
|
922 | - { |
|
921 | + if (!is_string($ident)) |
|
922 | + { |
|
923 | 923 | return false; |
924 | - } else { |
|
924 | + } else { |
|
925 | 925 | $additional_query = " AND (marine_archive_output.ident = :ident)"; |
926 | 926 | $query_values = array(':ident' => $ident); |
927 | - } |
|
927 | + } |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | if ($limit != "") |
931 | 931 | { |
932 | - $limit_array = explode(",", $limit); |
|
932 | + $limit_array = explode(",", $limit); |
|
933 | 933 | |
934 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
934 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
936 | 936 | |
937 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
938 | - { |
|
937 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
938 | + { |
|
939 | 939 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
940 | 940 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
941 | - } |
|
941 | + } |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | if ($sort != "") |
945 | 945 | { |
946 | - $search_orderby_array = $Marine->getOrderBy(); |
|
947 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
946 | + $search_orderby_array = $Marine->getOrderBy(); |
|
947 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
948 | 948 | } else { |
949 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
949 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -954,17 +954,17 @@ discard block |
||
954 | 954 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
955 | 955 | |
956 | 956 | return $spotter_array; |
957 | - } |
|
957 | + } |
|
958 | 958 | |
959 | 959 | |
960 | - /** |
|
961 | - * Gets all the spotter information based on the owner |
|
962 | - * |
|
963 | - * @return Array the spotter information |
|
964 | - * |
|
965 | - */ |
|
966 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
967 | - { |
|
960 | + /** |
|
961 | + * Gets all the spotter information based on the owner |
|
962 | + * |
|
963 | + * @return Array the spotter information |
|
964 | + * |
|
965 | + */ |
|
966 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
967 | + { |
|
968 | 968 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
969 | 969 | |
970 | 970 | date_default_timezone_set('UTC'); |
@@ -977,35 +977,35 @@ discard block |
||
977 | 977 | |
978 | 978 | if ($owner != "") |
979 | 979 | { |
980 | - if (!is_string($owner)) |
|
981 | - { |
|
980 | + if (!is_string($owner)) |
|
981 | + { |
|
982 | 982 | return false; |
983 | - } else { |
|
983 | + } else { |
|
984 | 984 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
985 | 985 | $query_values = array(':owner' => $owner); |
986 | - } |
|
986 | + } |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | if ($limit != "") |
990 | 990 | { |
991 | - $limit_array = explode(",", $limit); |
|
991 | + $limit_array = explode(",", $limit); |
|
992 | 992 | |
993 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
993 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
995 | 995 | |
996 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
997 | - { |
|
996 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
997 | + { |
|
998 | 998 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
999 | 999 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1000 | - } |
|
1000 | + } |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | if ($sort != "") |
1004 | 1004 | { |
1005 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1006 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1005 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1006 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1007 | 1007 | } else { |
1008 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1008 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1013,16 +1013,16 @@ discard block |
||
1013 | 1013 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1014 | 1014 | |
1015 | 1015 | return $spotter_array; |
1016 | - } |
|
1017 | - |
|
1018 | - /** |
|
1019 | - * Gets all the spotter information based on the pilot |
|
1020 | - * |
|
1021 | - * @return Array the spotter information |
|
1022 | - * |
|
1023 | - */ |
|
1024 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1025 | - { |
|
1016 | + } |
|
1017 | + |
|
1018 | + /** |
|
1019 | + * Gets all the spotter information based on the pilot |
|
1020 | + * |
|
1021 | + * @return Array the spotter information |
|
1022 | + * |
|
1023 | + */ |
|
1024 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1025 | + { |
|
1026 | 1026 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
1027 | 1027 | |
1028 | 1028 | date_default_timezone_set('UTC'); |
@@ -1041,24 +1041,24 @@ discard block |
||
1041 | 1041 | |
1042 | 1042 | if ($limit != "") |
1043 | 1043 | { |
1044 | - $limit_array = explode(",", $limit); |
|
1044 | + $limit_array = explode(",", $limit); |
|
1045 | 1045 | |
1046 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1046 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1048 | 1048 | |
1049 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1050 | - { |
|
1049 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1050 | + { |
|
1051 | 1051 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1052 | 1052 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1053 | - } |
|
1053 | + } |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | if ($sort != "") |
1057 | 1057 | { |
1058 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1059 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1058 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1059 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1060 | 1060 | } else { |
1061 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1061 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1066,16 +1066,16 @@ discard block |
||
1066 | 1066 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1067 | 1067 | |
1068 | 1068 | return $spotter_array; |
1069 | - } |
|
1070 | - |
|
1071 | - /** |
|
1072 | - * Gets all number of flight over countries |
|
1073 | - * |
|
1074 | - * @return Array the airline country list |
|
1075 | - * |
|
1076 | - */ |
|
1077 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1078 | - { |
|
1069 | + } |
|
1070 | + |
|
1071 | + /** |
|
1072 | + * Gets all number of flight over countries |
|
1073 | + * |
|
1074 | + * @return Array the airline country list |
|
1075 | + * |
|
1076 | + */ |
|
1077 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1078 | + { |
|
1079 | 1079 | global $globalDBdriver; |
1080 | 1080 | /* |
1081 | 1081 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1085,14 +1085,14 @@ discard block |
||
1085 | 1085 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1086 | 1086 | FROM countries c, marine_archive s |
1087 | 1087 | WHERE c.iso2 = s.over_country "; |
1088 | - if ($olderthanmonths > 0) { |
|
1089 | - if ($globalDBdriver == 'mysql') { |
|
1088 | + if ($olderthanmonths > 0) { |
|
1089 | + if ($globalDBdriver == 'mysql') { |
|
1090 | 1090 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1091 | 1091 | } else { |
1092 | 1092 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1093 | 1093 | } |
1094 | 1094 | } |
1095 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1095 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1096 | 1096 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1097 | 1097 | if ($limit) $query .= " LIMIT 0,10"; |
1098 | 1098 | |
@@ -1105,23 +1105,23 @@ discard block |
||
1105 | 1105 | |
1106 | 1106 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1107 | 1107 | { |
1108 | - $temp_array['flight_count'] = $row['nb']; |
|
1109 | - $temp_array['flight_country'] = $row['name']; |
|
1110 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1111 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1112 | - $flight_array[] = $temp_array; |
|
1108 | + $temp_array['flight_count'] = $row['nb']; |
|
1109 | + $temp_array['flight_country'] = $row['name']; |
|
1110 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1111 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1112 | + $flight_array[] = $temp_array; |
|
1113 | 1113 | } |
1114 | 1114 | return $flight_array; |
1115 | - } |
|
1116 | - |
|
1117 | - /** |
|
1118 | - * Gets all number of flight over countries |
|
1119 | - * |
|
1120 | - * @return Array the airline country list |
|
1121 | - * |
|
1122 | - */ |
|
1123 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1124 | - { |
|
1115 | + } |
|
1116 | + |
|
1117 | + /** |
|
1118 | + * Gets all number of flight over countries |
|
1119 | + * |
|
1120 | + * @return Array the airline country list |
|
1121 | + * |
|
1122 | + */ |
|
1123 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1124 | + { |
|
1125 | 1125 | global $globalDBdriver; |
1126 | 1126 | /* |
1127 | 1127 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1131,14 +1131,14 @@ discard block |
||
1131 | 1131 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1132 | 1132 | FROM countries c, marine_archive s, spotter_output o |
1133 | 1133 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
1134 | - if ($olderthanmonths > 0) { |
|
1135 | - if ($globalDBdriver == 'mysql') { |
|
1134 | + if ($olderthanmonths > 0) { |
|
1135 | + if ($globalDBdriver == 'mysql') { |
|
1136 | 1136 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1137 | 1137 | } else { |
1138 | 1138 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1139 | 1139 | } |
1140 | 1140 | } |
1141 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1141 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1142 | 1142 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1143 | 1143 | if ($limit) $query .= " LIMIT 0,10"; |
1144 | 1144 | |
@@ -1151,24 +1151,24 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1153 | 1153 | { |
1154 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1155 | - $temp_array['flight_count'] = $row['nb']; |
|
1156 | - $temp_array['flight_country'] = $row['name']; |
|
1157 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1158 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1159 | - $flight_array[] = $temp_array; |
|
1154 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1155 | + $temp_array['flight_count'] = $row['nb']; |
|
1156 | + $temp_array['flight_country'] = $row['name']; |
|
1157 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1158 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1159 | + $flight_array[] = $temp_array; |
|
1160 | 1160 | } |
1161 | 1161 | return $flight_array; |
1162 | - } |
|
1163 | - |
|
1164 | - /** |
|
1165 | - * Gets last spotter information based on a particular callsign |
|
1166 | - * |
|
1167 | - * @return Array the spotter information |
|
1168 | - * |
|
1169 | - */ |
|
1170 | - public function getDateArchiveMarineDataById($id,$date) |
|
1171 | - { |
|
1162 | + } |
|
1163 | + |
|
1164 | + /** |
|
1165 | + * Gets last spotter information based on a particular callsign |
|
1166 | + * |
|
1167 | + * @return Array the spotter information |
|
1168 | + * |
|
1169 | + */ |
|
1170 | + public function getDateArchiveMarineDataById($id,$date) |
|
1171 | + { |
|
1172 | 1172 | $Marine = new Marine($this->db); |
1173 | 1173 | date_default_timezone_set('UTC'); |
1174 | 1174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1176,16 +1176,16 @@ discard block |
||
1176 | 1176 | $date = date('c',$date); |
1177 | 1177 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1178 | 1178 | return $spotter_array; |
1179 | - } |
|
1180 | - |
|
1181 | - /** |
|
1182 | - * Gets all the spotter information based on a particular callsign |
|
1183 | - * |
|
1184 | - * @return Array the spotter information |
|
1185 | - * |
|
1186 | - */ |
|
1187 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1188 | - { |
|
1179 | + } |
|
1180 | + |
|
1181 | + /** |
|
1182 | + * Gets all the spotter information based on a particular callsign |
|
1183 | + * |
|
1184 | + * @return Array the spotter information |
|
1185 | + * |
|
1186 | + */ |
|
1187 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1188 | + { |
|
1189 | 1189 | $Marine = new Marine($this->db); |
1190 | 1190 | date_default_timezone_set('UTC'); |
1191 | 1191 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1193,16 +1193,16 @@ discard block |
||
1193 | 1193 | $date = date('c',$date); |
1194 | 1194 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1195 | 1195 | return $spotter_array; |
1196 | - } |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * Gets all the spotter information based on the airport |
|
1200 | - * |
|
1201 | - * @return Array the spotter information |
|
1202 | - * |
|
1203 | - */ |
|
1204 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1205 | - { |
|
1196 | + } |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * Gets all the spotter information based on the airport |
|
1200 | + * |
|
1201 | + * @return Array the spotter information |
|
1202 | + * |
|
1203 | + */ |
|
1204 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1205 | + { |
|
1206 | 1206 | global $global_query; |
1207 | 1207 | $Marine = new Marine($this->db); |
1208 | 1208 | date_default_timezone_set('UTC'); |
@@ -1213,35 +1213,35 @@ discard block |
||
1213 | 1213 | |
1214 | 1214 | if ($airport != "") |
1215 | 1215 | { |
1216 | - if (!is_string($airport)) |
|
1217 | - { |
|
1216 | + if (!is_string($airport)) |
|
1217 | + { |
|
1218 | 1218 | return false; |
1219 | - } else { |
|
1219 | + } else { |
|
1220 | 1220 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
1221 | 1221 | $query_values = array(':airport' => $airport); |
1222 | - } |
|
1222 | + } |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | if ($limit != "") |
1226 | 1226 | { |
1227 | - $limit_array = explode(",", $limit); |
|
1227 | + $limit_array = explode(",", $limit); |
|
1228 | 1228 | |
1229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1229 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1231 | 1231 | |
1232 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1233 | - { |
|
1232 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1233 | + { |
|
1234 | 1234 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1235 | 1235 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1236 | - } |
|
1236 | + } |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | if ($sort != "") |
1240 | 1240 | { |
1241 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1242 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1241 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1242 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1243 | 1243 | } else { |
1244 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1244 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | $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; |
@@ -1249,6 +1249,6 @@ discard block |
||
1249 | 1249 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1250 | 1250 | |
1251 | 1251 | return $spotter_array; |
1252 | - } |
|
1252 | + } |
|
1253 | 1253 | } |
1254 | 1254 | ?> |
1255 | 1255 | \ No newline at end of file |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | public function __construct($dbc = null) { |
7 | 7 | $Connection = new Connection($dbc); |
8 | 8 | $this->db = $Connection->db; |
9 | - if ($this->db === null) die('Error: No DB connection. (MarineArchive)'); |
|
9 | + if ($this->db === null) { |
|
10 | + die('Error: No DB connection. (MarineArchive)'); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | |
12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | if (isset($filter[0]['source'])) { |
28 | 30 | $filters = array_merge($filters,$filter); |
29 | 31 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
31 | 35 | $filter_query_join = ''; |
32 | 36 | $filter_query_where = ''; |
33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | 79 | } |
76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
80 | + if ($filter_query_where == '' && $where) { |
|
81 | + $filter_query_where = ' WHERE'; |
|
82 | + } elseif ($filter_query_where != '' && $and) { |
|
83 | + $filter_query_where .= ' AND'; |
|
84 | + } |
|
78 | 85 | if ($filter_query_where != '') { |
79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
88 | 95 | if ($over_country == '') { |
89 | 96 | $Marine = new Marine($this->db); |
90 | 97 | $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
92 | - else $country = ''; |
|
93 | - } else $country = $over_country; |
|
98 | + if (!empty($data_country)) { |
|
99 | + $country = $data_country['iso2']; |
|
100 | + } else { |
|
101 | + $country = ''; |
|
102 | + } |
|
103 | + } else { |
|
104 | + $country = $over_country; |
|
105 | + } |
|
94 | 106 | |
95 | 107 | //$country = $over_country; |
96 | 108 | // Route is not added in marine_archive |
@@ -598,7 +610,9 @@ discard block |
||
598 | 610 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
599 | 611 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
600 | 612 | $translate = $Translation->ident2icao($q_item); |
601 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
613 | + if ($translate != $q_item) { |
|
614 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
615 | + } |
|
602 | 616 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
603 | 617 | $additional_query .= ")"; |
604 | 618 | } |
@@ -816,7 +830,9 @@ discard block |
||
816 | 830 | date_default_timezone_set($globalTimezone); |
817 | 831 | $datetime = new DateTime(); |
818 | 832 | $offset = $datetime->format('P'); |
819 | - } else $offset = '+00:00'; |
|
833 | + } else { |
|
834 | + $offset = '+00:00'; |
|
835 | + } |
|
820 | 836 | |
821 | 837 | |
822 | 838 | if ($date_array[1] != "") |
@@ -1092,9 +1108,13 @@ discard block |
||
1092 | 1108 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1093 | 1109 | } |
1094 | 1110 | } |
1095 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1111 | + if ($sincedate != '') { |
|
1112 | + $query .= "AND date > '".$sincedate."' "; |
|
1113 | + } |
|
1096 | 1114 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1097 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1115 | + if ($limit) { |
|
1116 | + $query .= " LIMIT 0,10"; |
|
1117 | + } |
|
1098 | 1118 | |
1099 | 1119 | |
1100 | 1120 | $sth = $this->db->prepare($query); |
@@ -1138,9 +1158,13 @@ discard block |
||
1138 | 1158 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1139 | 1159 | } |
1140 | 1160 | } |
1141 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1161 | + if ($sincedate != '') { |
|
1162 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1163 | + } |
|
1142 | 1164 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1143 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1165 | + if ($limit) { |
|
1166 | + $query .= " LIMIT 0,10"; |
|
1167 | + } |
|
1144 | 1168 | |
1145 | 1169 | |
1146 | 1170 | $sth = $this->db->prepare($query); |
@@ -14,33 +14,33 @@ discard block |
||
14 | 14 | * @param Array $filter the filter |
15 | 15 | * @return Array the SQL part |
16 | 16 | */ |
17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
23 | 23 | } else { |
24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | if (isset($filter[0]['source'])) { |
28 | - $filters = array_merge($filters,$filter); |
|
28 | + $filters = array_merge($filters, $filter); |
|
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31 | 31 | $filter_query_join = ''; |
32 | 32 | $filter_query_where = ''; |
33 | - foreach($filters as $flt) { |
|
33 | + foreach ($filters as $flt) { |
|
34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
44 | 44 | } |
45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,42 +68,42 @@ discard block |
||
68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
69 | 69 | } |
70 | 70 | } |
71 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
72 | 72 | } |
73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
78 | 78 | if ($filter_query_where != '') { |
79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
80 | 80 | } |
81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
82 | 82 | return $filter_query; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // marine_archive |
86 | - public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
86 | + public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
87 | 87 | require_once(dirname(__FILE__).'/class.Marine.php'); |
88 | 88 | if ($over_country == '') { |
89 | 89 | $Marine = new Marine($this->db); |
90 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
90 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
92 | 92 | else $country = ''; |
93 | 93 | } else $country = $over_country; |
94 | 94 | |
95 | 95 | //$country = $over_country; |
96 | 96 | // Route is not added in marine_archive |
97 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
97 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
98 | 98 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
99 | 99 | |
100 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
100 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
101 | 101 | |
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | 105 | $sth->closeCursor(); |
106 | - } catch(PDOException $e) { |
|
106 | + } catch (PDOException $e) { |
|
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
109 | 109 | return "success"; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | |
124 | 124 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
125 | 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"; |
|
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 | 130 | return $spotter_array; |
131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
145 | 145 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
146 | 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"; |
|
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 | /* |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
159 | 159 | */ |
160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
160 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
161 | 161 | |
162 | 162 | return $spotter_array; |
163 | 163 | } |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | { |
173 | 173 | date_default_timezone_set('UTC'); |
174 | 174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
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 | 179 | try { |
180 | 180 | $sth = $this->db->prepare($query); |
181 | 181 | $sth->execute(array(':id' => $id)); |
182 | - } catch(PDOException $e) { |
|
182 | + } catch (PDOException $e) { |
|
183 | 183 | echo $e->getMessage(); |
184 | 184 | die; |
185 | 185 | } |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | { |
199 | 199 | date_default_timezone_set('UTC'); |
200 | 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"; |
|
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 | 205 | try { |
206 | 206 | $sth = $this->db->prepare($query); |
207 | 207 | $sth->execute(array(':id' => $id)); |
208 | - } catch(PDOException $e) { |
|
208 | + } catch (PDOException $e) { |
|
209 | 209 | echo $e->getMessage(); |
210 | 210 | die; |
211 | 211 | } |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | date_default_timezone_set('UTC'); |
228 | 228 | |
229 | 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"; |
|
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 | 232 | try { |
233 | 233 | $sth = $this->db->prepare($query); |
234 | 234 | $sth->execute(array(':ident' => $ident)); |
235 | - } catch(PDOException $e) { |
|
235 | + } catch (PDOException $e) { |
|
236 | 236 | echo $e->getMessage(); |
237 | 237 | die; |
238 | 238 | } |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | date_default_timezone_set('UTC'); |
254 | 254 | |
255 | 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"; |
|
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 | 258 | try { |
259 | 259 | $sth = $this->db->prepare($query); |
260 | 260 | $sth->execute(array(':id' => $id)); |
261 | - } catch(PDOException $e) { |
|
261 | + } catch (PDOException $e) { |
|
262 | 262 | echo $e->getMessage(); |
263 | 263 | die; |
264 | 264 | } |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | date_default_timezone_set('UTC'); |
280 | 280 | |
281 | 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"; |
|
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 | 284 | try { |
285 | 285 | $sth = $this->db->prepare($query); |
286 | 286 | $sth->execute(array(':id' => $id)); |
287 | - } catch(PDOException $e) { |
|
287 | + } catch (PDOException $e) { |
|
288 | 288 | echo $e->getMessage(); |
289 | 289 | die; |
290 | 290 | } |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | date_default_timezone_set('UTC'); |
307 | 307 | |
308 | 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"; |
|
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 | 312 | try { |
313 | 313 | $sth = $this->db->prepare($query); |
314 | 314 | $sth->execute(array(':ident' => $ident)); |
315 | - } catch(PDOException $e) { |
|
315 | + } catch (PDOException $e) { |
|
316 | 316 | echo $e->getMessage(); |
317 | 317 | die; |
318 | 318 | } |
@@ -329,12 +329,12 @@ discard block |
||
329 | 329 | * @return Array the spotter information |
330 | 330 | * |
331 | 331 | */ |
332 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
332 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
333 | 333 | { |
334 | 334 | $Marine = new Marine($this->db); |
335 | 335 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
336 | 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 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
337 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
338 | 338 | return $spotter_array; |
339 | 339 | } |
340 | 340 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | try { |
354 | 354 | $sth = $this->db->prepare($query); |
355 | 355 | $sth->execute(); |
356 | - } catch(PDOException $e) { |
|
356 | + } catch (PDOException $e) { |
|
357 | 357 | echo $e->getMessage(); |
358 | 358 | die; |
359 | 359 | } |
@@ -365,24 +365,24 @@ discard block |
||
365 | 365 | * @return Array the spotter information |
366 | 366 | * |
367 | 367 | */ |
368 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
368 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
369 | 369 | { |
370 | 370 | global $globalDBdriver, $globalLiveInterval; |
371 | 371 | date_default_timezone_set('UTC'); |
372 | 372 | |
373 | 373 | $filter_query = ''; |
374 | 374 | if (isset($filter['source']) && !empty($filter['source'])) { |
375 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
375 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
376 | 376 | } |
377 | 377 | // Use spotter_output also ? |
378 | 378 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
379 | - $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 "; |
|
379 | + $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 "; |
|
380 | 380 | } |
381 | 381 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
382 | 382 | $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 "; |
383 | 383 | } |
384 | 384 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
385 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
385 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
402 | 402 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
403 | 403 | */ |
404 | - $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 | + $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 |
|
405 | 405 | FROM marine_archive |
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
407 | 407 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
408 | 408 | '.$filter_query.' ORDER BY fammarine_id'; |
409 | 409 | } else { |
410 | 410 | //$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'; |
411 | - $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 |
|
411 | + $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 |
|
412 | 412 | FROM marine_archive |
413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
414 | 414 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | try { |
419 | 419 | $sth = $this->db->prepare($query); |
420 | 420 | $sth->execute(); |
421 | - } catch(PDOException $e) { |
|
421 | + } catch (PDOException $e) { |
|
422 | 422 | echo $e->getMessage(); |
423 | 423 | die; |
424 | 424 | } |
@@ -433,24 +433,24 @@ discard block |
||
433 | 433 | * @return Array the spotter information |
434 | 434 | * |
435 | 435 | */ |
436 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
436 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
437 | 437 | { |
438 | 438 | global $globalDBdriver, $globalLiveInterval; |
439 | 439 | date_default_timezone_set('UTC'); |
440 | 440 | |
441 | 441 | $filter_query = ''; |
442 | 442 | if (isset($filter['source']) && !empty($filter['source'])) { |
443 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
443 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
444 | 444 | } |
445 | 445 | // Should use spotter_output also ? |
446 | 446 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
447 | - $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 "; |
|
447 | + $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 "; |
|
448 | 448 | } |
449 | 449 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
450 | 450 | $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 "; |
451 | 451 | } |
452 | 452 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
453 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
453 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | FROM marine_archive |
461 | 461 | 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'; |
462 | 462 | */ |
463 | - $query = 'SELECT a.aircraft_shadow, 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 |
|
463 | + $query = 'SELECT a.aircraft_shadow, 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 |
|
464 | 464 | FROM marine_archive_output |
465 | 465 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
466 | 466 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$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'; |
477 | 477 | */ |
478 | - $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 |
|
478 | + $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 |
|
479 | 479 | FROM marine_archive_output |
480 | 480 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
481 | 481 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $this->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | echo $e->getMessage(); |
492 | 492 | die; |
493 | 493 | } |
@@ -502,23 +502,23 @@ discard block |
||
502 | 502 | * @return Array the spotter information |
503 | 503 | * |
504 | 504 | */ |
505 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
505 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
506 | 506 | { |
507 | 507 | global $globalDBdriver, $globalLiveInterval; |
508 | 508 | date_default_timezone_set('UTC'); |
509 | 509 | |
510 | 510 | $filter_query = ''; |
511 | 511 | if (isset($filter['source']) && !empty($filter['source'])) { |
512 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
512 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
513 | 513 | } |
514 | 514 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
515 | - $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 "; |
|
515 | + $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 "; |
|
516 | 516 | } |
517 | 517 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
518 | 518 | $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 "; |
519 | 519 | } |
520 | 520 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
521 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
521 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | try { |
534 | 534 | $sth = $this->db->prepare($query); |
535 | 535 | $sth->execute(); |
536 | - } catch(PDOException $e) { |
|
536 | + } catch (PDOException $e) { |
|
537 | 537 | echo $e->getMessage(); |
538 | 538 | die; |
539 | 539 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @return Array the spotter information |
554 | 554 | * |
555 | 555 | */ |
556 | - 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()) |
|
556 | + 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()) |
|
557 | 557 | { |
558 | 558 | global $globalTimezone, $globalDBdriver; |
559 | 559 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | |
576 | 576 | $q_array = explode(" ", $q); |
577 | 577 | |
578 | - foreach ($q_array as $q_item){ |
|
578 | + foreach ($q_array as $q_item) { |
|
579 | 579 | $additional_query .= " AND ("; |
580 | 580 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
581 | 581 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | if ($registration != "") |
609 | 609 | { |
610 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
610 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
611 | 611 | if (!is_string($registration)) |
612 | 612 | { |
613 | 613 | return false; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | if ($aircraft_icao != "") |
620 | 620 | { |
621 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
621 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
622 | 622 | if (!is_string($aircraft_icao)) |
623 | 623 | { |
624 | 624 | return false; |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | |
630 | 630 | if ($aircraft_manufacturer != "") |
631 | 631 | { |
632 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
632 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
633 | 633 | if (!is_string($aircraft_manufacturer)) |
634 | 634 | { |
635 | 635 | return false; |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | |
651 | 651 | if ($airline_icao != "") |
652 | 652 | { |
653 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
653 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
654 | 654 | if (!is_string($airline_icao)) |
655 | 655 | { |
656 | 656 | return false; |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | |
662 | 662 | if ($airline_country != "") |
663 | 663 | { |
664 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
664 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
665 | 665 | if (!is_string($airline_country)) |
666 | 666 | { |
667 | 667 | return false; |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | |
673 | 673 | if ($airline_type != "") |
674 | 674 | { |
675 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
675 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
676 | 676 | if (!is_string($airline_type)) |
677 | 677 | { |
678 | 678 | return false; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | if ($airport != "") |
696 | 696 | { |
697 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
697 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
698 | 698 | if (!is_string($airport)) |
699 | 699 | { |
700 | 700 | return false; |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | |
706 | 706 | if ($airport_country != "") |
707 | 707 | { |
708 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
708 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
709 | 709 | if (!is_string($airport_country)) |
710 | 710 | { |
711 | 711 | return false; |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | |
717 | 717 | if ($callsign != "") |
718 | 718 | { |
719 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
719 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
720 | 720 | if (!is_string($callsign)) |
721 | 721 | { |
722 | 722 | return false; |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | $translate = $Translation->ident2icao($callsign); |
725 | 725 | if ($translate != $callsign) { |
726 | 726 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
727 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
727 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
728 | 728 | } else { |
729 | 729 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
730 | 730 | } |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | |
734 | 734 | if ($owner != "") |
735 | 735 | { |
736 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
736 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
737 | 737 | if (!is_string($owner)) |
738 | 738 | { |
739 | 739 | return false; |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | |
745 | 745 | if ($pilot_name != "") |
746 | 746 | { |
747 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
747 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
748 | 748 | if (!is_string($pilot_name)) |
749 | 749 | { |
750 | 750 | return false; |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | |
756 | 756 | if ($pilot_id != "") |
757 | 757 | { |
758 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
758 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
759 | 759 | if (!is_string($pilot_id)) |
760 | 760 | { |
761 | 761 | return false; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | |
767 | 767 | if ($departure_airport_route != "") |
768 | 768 | { |
769 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
769 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
770 | 770 | if (!is_string($departure_airport_route)) |
771 | 771 | { |
772 | 772 | return false; |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | |
778 | 778 | if ($arrival_airport_route != "") |
779 | 779 | { |
780 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
780 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
781 | 781 | if (!is_string($arrival_airport_route)) |
782 | 782 | { |
783 | 783 | return false; |
@@ -790,8 +790,8 @@ discard block |
||
790 | 790 | { |
791 | 791 | $altitude_array = explode(",", $altitude); |
792 | 792 | |
793 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
793 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
794 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
795 | 795 | |
796 | 796 | |
797 | 797 | if ($altitude_array[1] != "") |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | { |
810 | 810 | $date_array = explode(",", $date_posted); |
811 | 811 | |
812 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
812 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
813 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
814 | 814 | |
815 | 815 | if ($globalTimezone != '') { |
816 | 816 | date_default_timezone_set($globalTimezone); |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | { |
843 | 843 | $limit_array = explode(",", $limit); |
844 | 844 | |
845 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
845 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
846 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
847 | 847 | |
848 | 848 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
849 | 849 | { |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | |
855 | 855 | |
856 | 856 | if ($origLat != "" && $origLon != "" && $dist != "") { |
857 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
858 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
857 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
858 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
859 | 859 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
860 | 860 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
861 | 861 | } else { |
@@ -872,12 +872,12 @@ discard block |
||
872 | 872 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
873 | 873 | } |
874 | 874 | |
875 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
875 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
876 | 876 | WHERE marine_archive_output.ident <> '' |
877 | 877 | ".$additional_query." |
878 | 878 | ".$filter_query.$orderby_query; |
879 | 879 | } |
880 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
880 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
881 | 881 | |
882 | 882 | return $spotter_array; |
883 | 883 | } |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | try { |
895 | 895 | $sth = $this->db->prepare($query); |
896 | 896 | $sth->execute(); |
897 | - } catch(PDOException $e) { |
|
897 | + } catch (PDOException $e) { |
|
898 | 898 | return "error"; |
899 | 899 | } |
900 | 900 | } |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | { |
932 | 932 | $limit_array = explode(",", $limit); |
933 | 933 | |
934 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
934 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
935 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
936 | 936 | |
937 | 937 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
938 | 938 | { |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | $query_values = array(); |
974 | 974 | $limit_query = ''; |
975 | 975 | $additional_query = ''; |
976 | - $filter_query = $this->getFilter($filter,true,true); |
|
976 | + $filter_query = $this->getFilter($filter, true, true); |
|
977 | 977 | |
978 | 978 | if ($owner != "") |
979 | 979 | { |
@@ -990,8 +990,8 @@ discard block |
||
990 | 990 | { |
991 | 991 | $limit_array = explode(",", $limit); |
992 | 992 | |
993 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
993 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
994 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
995 | 995 | |
996 | 996 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
997 | 997 | { |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | $query_values = array(); |
1032 | 1032 | $limit_query = ''; |
1033 | 1033 | $additional_query = ''; |
1034 | - $filter_query = $this->getFilter($filter,true,true); |
|
1034 | + $filter_query = $this->getFilter($filter, true, true); |
|
1035 | 1035 | |
1036 | 1036 | if ($pilot != "") |
1037 | 1037 | { |
@@ -1043,8 +1043,8 @@ discard block |
||
1043 | 1043 | { |
1044 | 1044 | $limit_array = explode(",", $limit); |
1045 | 1045 | |
1046 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1046 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1047 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1048 | 1048 | |
1049 | 1049 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1050 | 1050 | { |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * @return Array the airline country list |
1075 | 1075 | * |
1076 | 1076 | */ |
1077 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1077 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1078 | 1078 | { |
1079 | 1079 | global $globalDBdriver; |
1080 | 1080 | /* |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | $flight_array = array(); |
1104 | 1104 | $temp_array = array(); |
1105 | 1105 | |
1106 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1106 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1107 | 1107 | { |
1108 | 1108 | $temp_array['flight_count'] = $row['nb']; |
1109 | 1109 | $temp_array['flight_country'] = $row['name']; |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | * @return Array the airline country list |
1121 | 1121 | * |
1122 | 1122 | */ |
1123 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1123 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1124 | 1124 | { |
1125 | 1125 | global $globalDBdriver; |
1126 | 1126 | /* |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | $flight_array = array(); |
1150 | 1150 | $temp_array = array(); |
1151 | 1151 | |
1152 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1152 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1153 | 1153 | { |
1154 | 1154 | $temp_array['airline_icao'] = $row['airline_icao']; |
1155 | 1155 | $temp_array['flight_count'] = $row['nb']; |
@@ -1167,14 +1167,14 @@ discard block |
||
1167 | 1167 | * @return Array the spotter information |
1168 | 1168 | * |
1169 | 1169 | */ |
1170 | - public function getDateArchiveMarineDataById($id,$date) |
|
1170 | + public function getDateArchiveMarineDataById($id, $date) |
|
1171 | 1171 | { |
1172 | 1172 | $Marine = new Marine($this->db); |
1173 | 1173 | date_default_timezone_set('UTC'); |
1174 | 1174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1175 | 1175 | $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 AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1176 | - $date = date('c',$date); |
|
1177 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1176 | + $date = date('c', $date); |
|
1177 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1178 | 1178 | return $spotter_array; |
1179 | 1179 | } |
1180 | 1180 | |
@@ -1184,14 +1184,14 @@ discard block |
||
1184 | 1184 | * @return Array the spotter information |
1185 | 1185 | * |
1186 | 1186 | */ |
1187 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1187 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
1188 | 1188 | { |
1189 | 1189 | $Marine = new Marine($this->db); |
1190 | 1190 | date_default_timezone_set('UTC'); |
1191 | 1191 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1192 | 1192 | $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 AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1193 | - $date = date('c',$date); |
|
1194 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1193 | + $date = date('c', $date); |
|
1194 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1195 | 1195 | return $spotter_array; |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | * @return Array the spotter information |
1202 | 1202 | * |
1203 | 1203 | */ |
1204 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1204 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1205 | 1205 | { |
1206 | 1206 | global $global_query; |
1207 | 1207 | $Marine = new Marine($this->db); |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | $query_values = array(); |
1210 | 1210 | $limit_query = ''; |
1211 | 1211 | $additional_query = ''; |
1212 | - $filter_query = $this->getFilter($filters,true,true); |
|
1212 | + $filter_query = $this->getFilter($filters, true, true); |
|
1213 | 1213 | |
1214 | 1214 | if ($airport != "") |
1215 | 1215 | { |
@@ -1226,8 +1226,8 @@ discard block |
||
1226 | 1226 | { |
1227 | 1227 | $limit_array = explode(",", $limit); |
1228 | 1228 | |
1229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1229 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1230 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1231 | 1231 | |
1232 | 1232 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1233 | 1233 | { |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -794,10 +794,6 @@ discard block |
||
794 | 794 | * |
795 | 795 | * @param String $fammarine_id the ID from flightaware |
796 | 796 | * @param String $ident the flight ident |
797 | - * @param String $aircraft_icao the aircraft type |
|
798 | - * @param String $departure_airport_icao the departure airport |
|
799 | - * @param String $arrival_airport_icao the arrival airport |
|
800 | - * @return String success or false |
|
801 | 797 | * |
802 | 798 | */ |
803 | 799 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Gets all the spotter information based on the latest data entry |
|
91 | - * |
|
92 | - * @return Array the spotter information |
|
93 | - * |
|
94 | - */ |
|
90 | + * Gets all the spotter information based on the latest data entry |
|
91 | + * |
|
92 | + * @return Array the spotter information |
|
93 | + * |
|
94 | + */ |
|
95 | 95 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
96 | 96 | { |
97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | - * Gets Minimal Live Spotter data |
|
138 | - * |
|
139 | - * @return Array the spotter information |
|
140 | - * |
|
141 | - */ |
|
137 | + * Gets Minimal Live Spotter data |
|
138 | + * |
|
139 | + * @return Array the spotter information |
|
140 | + * |
|
141 | + */ |
|
142 | 142 | public function getMinLiveMarineData($filter = array()) |
143 | 143 | { |
144 | 144 | global $globalDBdriver, $globalLiveInterval; |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
171 | - * Gets Minimal Live Spotter data since xx seconds |
|
172 | - * |
|
173 | - * @return Array the spotter information |
|
174 | - * |
|
175 | - */ |
|
171 | + * Gets Minimal Live Spotter data since xx seconds |
|
172 | + * |
|
173 | + * @return Array the spotter information |
|
174 | + * |
|
175 | + */ |
|
176 | 176 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
177 | 177 | { |
178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | - * Gets number of latest data entry |
|
247 | - * |
|
248 | - * @return String number of entry |
|
249 | - * |
|
250 | - */ |
|
246 | + * Gets number of latest data entry |
|
247 | + * |
|
248 | + * @return String number of entry |
|
249 | + * |
|
250 | + */ |
|
251 | 251 | public function getLiveMarineCount($filter = array()) |
252 | 252 | { |
253 | 253 | global $globalDBdriver, $globalLiveInterval; |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | - * Gets all the spotter information based on the latest data entry and coord |
|
276 | - * |
|
277 | - * @return Array the spotter information |
|
278 | - * |
|
279 | - */ |
|
275 | + * Gets all the spotter information based on the latest data entry and coord |
|
276 | + * |
|
277 | + * @return Array the spotter information |
|
278 | + * |
|
279 | + */ |
|
280 | 280 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
281 | 281 | { |
282 | 282 | global $globalDBdriver, $globalLiveInterval; |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
303 | - * Gets all the spotter information based on the latest data entry and coord |
|
304 | - * |
|
305 | - * @return Array the spotter information |
|
306 | - * |
|
307 | - */ |
|
303 | + * Gets all the spotter information based on the latest data entry and coord |
|
304 | + * |
|
305 | + * @return Array the spotter information |
|
306 | + * |
|
307 | + */ |
|
308 | 308 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
309 | 309 | { |
310 | 310 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
376 | - * Gets all the spotter information based on a user's latitude and longitude |
|
377 | - * |
|
378 | - * @return Array the spotter information |
|
379 | - * |
|
380 | - */ |
|
376 | + * Gets all the spotter information based on a user's latitude and longitude |
|
377 | + * |
|
378 | + * @return Array the spotter information |
|
379 | + * |
|
380 | + */ |
|
381 | 381 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
382 | 382 | { |
383 | 383 | $Marine = new Marine($this->db); |
@@ -390,134 +390,134 @@ discard block |
||
390 | 390 | if ($lng != '') |
391 | 391 | { |
392 | 392 | if (!is_numeric($lng)) |
393 | - { |
|
394 | - return false; |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - if ($radius != '') |
|
399 | - { |
|
400 | - if (!is_numeric($radius)) |
|
401 | - { |
|
402 | - return false; |
|
403 | - } |
|
404 | - } |
|
393 | + { |
|
394 | + return false; |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + if ($radius != '') |
|
399 | + { |
|
400 | + if (!is_numeric($radius)) |
|
401 | + { |
|
402 | + return false; |
|
403 | + } |
|
404 | + } |
|
405 | 405 | $additional_query = ''; |
406 | 406 | if ($interval != '') |
407 | - { |
|
408 | - if (!is_string($interval)) |
|
409 | - { |
|
410 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
411 | - return false; |
|
412 | - } else { |
|
413 | - if ($interval == '1m') |
|
414 | - { |
|
415 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
416 | - } else if ($interval == '15m'){ |
|
417 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
418 | - } |
|
419 | - } |
|
420 | - } else { |
|
421 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
422 | - } |
|
423 | - |
|
424 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
407 | + { |
|
408 | + if (!is_string($interval)) |
|
409 | + { |
|
410 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
411 | + return false; |
|
412 | + } else { |
|
413 | + if ($interval == '1m') |
|
414 | + { |
|
415 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
416 | + } else if ($interval == '15m'){ |
|
417 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
418 | + } |
|
419 | + } |
|
420 | + } else { |
|
421 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
422 | + } |
|
423 | + |
|
424 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
425 | 425 | WHERE marine_live.latitude <> '' |
426 | 426 | AND marine_live.longitude <> '' |
427 | 427 | ".$additional_query." |
428 | 428 | HAVING distance < :radius |
429 | 429 | ORDER BY distance"; |
430 | 430 | |
431 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
431 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
432 | 432 | |
433 | - return $spotter_array; |
|
434 | - } |
|
433 | + return $spotter_array; |
|
434 | + } |
|
435 | 435 | |
436 | 436 | |
437 | - /** |
|
438 | - * Gets all the spotter information based on a particular callsign |
|
439 | - * |
|
440 | - * @return Array the spotter information |
|
441 | - * |
|
442 | - */ |
|
437 | + /** |
|
438 | + * Gets all the spotter information based on a particular callsign |
|
439 | + * |
|
440 | + * @return Array the spotter information |
|
441 | + * |
|
442 | + */ |
|
443 | 443 | public function getLastLiveMarineDataByIdent($ident) |
444 | 444 | { |
445 | 445 | $Marine = new Marine($this->db); |
446 | 446 | date_default_timezone_set('UTC'); |
447 | 447 | |
448 | 448 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
449 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
449 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
450 | 450 | |
451 | 451 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
452 | 452 | |
453 | 453 | return $spotter_array; |
454 | 454 | } |
455 | 455 | |
456 | - /** |
|
457 | - * Gets all the spotter information based on a particular callsign |
|
458 | - * |
|
459 | - * @return Array the spotter information |
|
460 | - * |
|
461 | - */ |
|
456 | + /** |
|
457 | + * Gets all the spotter information based on a particular callsign |
|
458 | + * |
|
459 | + * @return Array the spotter information |
|
460 | + * |
|
461 | + */ |
|
462 | 462 | public function getDateLiveMarineDataByIdent($ident,$date) |
463 | 463 | { |
464 | 464 | $Marine = new Marine($this->db); |
465 | 465 | date_default_timezone_set('UTC'); |
466 | 466 | |
467 | 467 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
468 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
468 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
469 | 469 | |
470 | - $date = date('c',$date); |
|
470 | + $date = date('c',$date); |
|
471 | 471 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
472 | 472 | |
473 | 473 | return $spotter_array; |
474 | 474 | } |
475 | 475 | |
476 | - /** |
|
477 | - * Gets last spotter information based on a particular callsign |
|
478 | - * |
|
479 | - * @return Array the spotter information |
|
480 | - * |
|
481 | - */ |
|
476 | + /** |
|
477 | + * Gets last spotter information based on a particular callsign |
|
478 | + * |
|
479 | + * @return Array the spotter information |
|
480 | + * |
|
481 | + */ |
|
482 | 482 | public function getLastLiveMarineDataById($id) |
483 | 483 | { |
484 | 484 | $Marine = new Marine($this->db); |
485 | 485 | date_default_timezone_set('UTC'); |
486 | 486 | |
487 | 487 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
488 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
488 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
489 | 489 | |
490 | 490 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
491 | 491 | |
492 | 492 | return $spotter_array; |
493 | 493 | } |
494 | 494 | |
495 | - /** |
|
496 | - * Gets last spotter information based on a particular callsign |
|
497 | - * |
|
498 | - * @return Array the spotter information |
|
499 | - * |
|
500 | - */ |
|
495 | + /** |
|
496 | + * Gets last spotter information based on a particular callsign |
|
497 | + * |
|
498 | + * @return Array the spotter information |
|
499 | + * |
|
500 | + */ |
|
501 | 501 | public function getDateLiveMarineDataById($id,$date) |
502 | 502 | { |
503 | 503 | $Marine = new Marine($this->db); |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | |
506 | 506 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
507 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | - $date = date('c',$date); |
|
507 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | + $date = date('c',$date); |
|
509 | 509 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
510 | 510 | |
511 | 511 | return $spotter_array; |
512 | 512 | } |
513 | 513 | |
514 | 514 | |
515 | - /** |
|
516 | - * Gets all the spotter information based on a particular id |
|
517 | - * |
|
518 | - * @return Array the spotter information |
|
519 | - * |
|
520 | - */ |
|
515 | + /** |
|
516 | + * Gets all the spotter information based on a particular id |
|
517 | + * |
|
518 | + * @return Array the spotter information |
|
519 | + * |
|
520 | + */ |
|
521 | 521 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
522 | 522 | { |
523 | 523 | global $globalDBdriver, $globalLiveInterval; |
@@ -545,18 +545,18 @@ discard block |
||
545 | 545 | return $spotter_array; |
546 | 546 | } |
547 | 547 | |
548 | - /** |
|
549 | - * Gets all the spotter information based on a particular ident |
|
550 | - * |
|
551 | - * @return Array the spotter information |
|
552 | - * |
|
553 | - */ |
|
548 | + /** |
|
549 | + * Gets all the spotter information based on a particular ident |
|
550 | + * |
|
551 | + * @return Array the spotter information |
|
552 | + * |
|
553 | + */ |
|
554 | 554 | public function getAllLiveMarineDataByIdent($ident) |
555 | 555 | { |
556 | 556 | date_default_timezone_set('UTC'); |
557 | 557 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
558 | 558 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
559 | - try { |
|
559 | + try { |
|
560 | 560 | |
561 | 561 | $sth = $this->db->prepare($query); |
562 | 562 | $sth->execute(array(':ident' => $ident)); |
@@ -570,23 +570,23 @@ discard block |
||
570 | 570 | |
571 | 571 | |
572 | 572 | /** |
573 | - * Deletes all info in the table |
|
574 | - * |
|
575 | - * @return String success or false |
|
576 | - * |
|
577 | - */ |
|
573 | + * Deletes all info in the table |
|
574 | + * |
|
575 | + * @return String success or false |
|
576 | + * |
|
577 | + */ |
|
578 | 578 | public function deleteLiveMarineData() |
579 | 579 | { |
580 | 580 | global $globalDBdriver; |
581 | 581 | if ($globalDBdriver == 'mysql') { |
582 | 582 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
583 | 583 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
584 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
584 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
585 | 585 | } else { |
586 | 586 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
587 | 587 | } |
588 | 588 | |
589 | - try { |
|
589 | + try { |
|
590 | 590 | |
591 | 591 | $sth = $this->db->prepare($query); |
592 | 592 | $sth->execute(); |
@@ -598,18 +598,18 @@ discard block |
||
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
601 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
602 | - * |
|
603 | - * @return String success or false |
|
604 | - * |
|
605 | - */ |
|
601 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
602 | + * |
|
603 | + * @return String success or false |
|
604 | + * |
|
605 | + */ |
|
606 | 606 | public function deleteLiveMarineDataNotUpdated() |
607 | 607 | { |
608 | 608 | global $globalDBdriver, $globalDebug; |
609 | 609 | if ($globalDBdriver == 'mysql') { |
610 | 610 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
611 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
612 | - try { |
|
611 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
612 | + try { |
|
613 | 613 | |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute(); |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | return "error"; |
618 | 618 | } |
619 | 619 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
620 | - $i = 0; |
|
621 | - $j =0; |
|
620 | + $i = 0; |
|
621 | + $j =0; |
|
622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
623 | 623 | foreach($all as $row) |
624 | 624 | { |
@@ -626,20 +626,20 @@ discard block |
||
626 | 626 | $j++; |
627 | 627 | if ($j == 30) { |
628 | 628 | if ($globalDebug) echo "."; |
629 | - try { |
|
629 | + try { |
|
630 | 630 | |
631 | 631 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
632 | 632 | $sth->execute(); |
633 | 633 | } catch(PDOException $e) { |
634 | 634 | return "error"; |
635 | 635 | } |
636 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
637 | - $j = 0; |
|
636 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
637 | + $j = 0; |
|
638 | 638 | } |
639 | 639 | $query_delete .= "'".$row['fammarine_id']."',"; |
640 | 640 | } |
641 | 641 | if ($i > 0) { |
642 | - try { |
|
642 | + try { |
|
643 | 643 | |
644 | 644 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
645 | 645 | $sth->execute(); |
@@ -650,9 +650,9 @@ discard block |
||
650 | 650 | return "success"; |
651 | 651 | } elseif ($globalDBdriver == 'pgsql') { |
652 | 652 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
653 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
654 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
655 | - try { |
|
653 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
654 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
655 | + try { |
|
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(); |
@@ -696,17 +696,17 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
699 | - * Deletes all info in the table for an ident |
|
700 | - * |
|
701 | - * @return String success or false |
|
702 | - * |
|
703 | - */ |
|
699 | + * Deletes all info in the table for an ident |
|
700 | + * |
|
701 | + * @return String success or false |
|
702 | + * |
|
703 | + */ |
|
704 | 704 | public function deleteLiveMarineDataByIdent($ident) |
705 | 705 | { |
706 | 706 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
707 | 707 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
708 | 708 | |
709 | - try { |
|
709 | + try { |
|
710 | 710 | |
711 | 711 | $sth = $this->db->prepare($query); |
712 | 712 | $sth->execute(array(':ident' => $ident)); |
@@ -718,17 +718,17 @@ discard block |
||
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
721 | - * Deletes all info in the table for an id |
|
722 | - * |
|
723 | - * @return String success or false |
|
724 | - * |
|
725 | - */ |
|
721 | + * Deletes all info in the table for an id |
|
722 | + * |
|
723 | + * @return String success or false |
|
724 | + * |
|
725 | + */ |
|
726 | 726 | public function deleteLiveMarineDataById($id) |
727 | 727 | { |
728 | 728 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
729 | 729 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
730 | 730 | |
731 | - try { |
|
731 | + try { |
|
732 | 732 | |
733 | 733 | $sth = $this->db->prepare($query); |
734 | 734 | $sth->execute(array(':id' => $id)); |
@@ -741,11 +741,11 @@ discard block |
||
741 | 741 | |
742 | 742 | |
743 | 743 | /** |
744 | - * Gets the aircraft ident within the last hour |
|
745 | - * |
|
746 | - * @return String the ident |
|
747 | - * |
|
748 | - */ |
|
744 | + * Gets the aircraft ident within the last hour |
|
745 | + * |
|
746 | + * @return String the ident |
|
747 | + * |
|
748 | + */ |
|
749 | 749 | public function getIdentFromLastHour($ident) |
750 | 750 | { |
751 | 751 | global $globalDBdriver, $globalTimezone; |
@@ -771,14 +771,14 @@ discard block |
||
771 | 771 | $ident_result = $row['ident']; |
772 | 772 | } |
773 | 773 | return $ident_result; |
774 | - } |
|
774 | + } |
|
775 | 775 | |
776 | 776 | /** |
777 | - * Check recent aircraft |
|
778 | - * |
|
779 | - * @return String the ident |
|
780 | - * |
|
781 | - */ |
|
777 | + * Check recent aircraft |
|
778 | + * |
|
779 | + * @return String the ident |
|
780 | + * |
|
781 | + */ |
|
782 | 782 | public function checkIdentRecent($ident) |
783 | 783 | { |
784 | 784 | global $globalDBdriver, $globalTimezone; |
@@ -804,14 +804,14 @@ discard block |
||
804 | 804 | $ident_result = $row['fammarine_id']; |
805 | 805 | } |
806 | 806 | return $ident_result; |
807 | - } |
|
807 | + } |
|
808 | 808 | |
809 | 809 | /** |
810 | - * Check recent aircraft by id |
|
811 | - * |
|
812 | - * @return String the ident |
|
813 | - * |
|
814 | - */ |
|
810 | + * Check recent aircraft by id |
|
811 | + * |
|
812 | + * @return String the ident |
|
813 | + * |
|
814 | + */ |
|
815 | 815 | public function checkIdRecent($id) |
816 | 816 | { |
817 | 817 | global $globalDBdriver, $globalTimezone; |
@@ -837,14 +837,14 @@ discard block |
||
837 | 837 | $ident_result = $row['fammarine_id']; |
838 | 838 | } |
839 | 839 | return $ident_result; |
840 | - } |
|
840 | + } |
|
841 | 841 | |
842 | 842 | /** |
843 | - * Check recent aircraft by mmsi |
|
844 | - * |
|
845 | - * @return String the ident |
|
846 | - * |
|
847 | - */ |
|
843 | + * Check recent aircraft by mmsi |
|
844 | + * |
|
845 | + * @return String the ident |
|
846 | + * |
|
847 | + */ |
|
848 | 848 | public function checkMMSIRecent($mmsi) |
849 | 849 | { |
850 | 850 | global $globalDBdriver, $globalTimezone; |
@@ -870,19 +870,19 @@ discard block |
||
870 | 870 | $ident_result = $row['fammarine_id']; |
871 | 871 | } |
872 | 872 | return $ident_result; |
873 | - } |
|
873 | + } |
|
874 | 874 | |
875 | 875 | /** |
876 | - * Adds a new spotter data |
|
877 | - * |
|
878 | - * @param String $fammarine_id the ID from flightaware |
|
879 | - * @param String $ident the flight ident |
|
880 | - * @param String $aircraft_icao the aircraft type |
|
881 | - * @param String $departure_airport_icao the departure airport |
|
882 | - * @param String $arrival_airport_icao the arrival airport |
|
883 | - * @return String success or false |
|
884 | - * |
|
885 | - */ |
|
876 | + * Adds a new spotter data |
|
877 | + * |
|
878 | + * @param String $fammarine_id the ID from flightaware |
|
879 | + * @param String $ident the flight ident |
|
880 | + * @param String $aircraft_icao the aircraft type |
|
881 | + * @param String $departure_airport_icao the departure airport |
|
882 | + * @param String $arrival_airport_icao the arrival airport |
|
883 | + * @return String success or false |
|
884 | + * |
|
885 | + */ |
|
886 | 886 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
887 | 887 | { |
888 | 888 | global $globalURL, $globalArchive, $globalDebug; |
@@ -953,10 +953,10 @@ discard block |
||
953 | 953 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
954 | 954 | |
955 | 955 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | - if ($arrival_date == '') $arrival_date = NULL; |
|
959 | - $query = ''; |
|
956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | + if ($arrival_date == '') $arrival_date = NULL; |
|
959 | + $query = ''; |
|
960 | 960 | if ($globalArchive) { |
961 | 961 | if ($globalDebug) echo '-- Delete previous data -- '; |
962 | 962 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @param Array $filter the filter |
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
73 | 73 | } |
74 | 74 | } |
75 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
75 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
76 | 76 | } |
77 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
78 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
78 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
79 | 79 | } |
80 | 80 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
81 | 81 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
82 | 82 | if ($filter_query_where != '') { |
83 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
83 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
84 | 84 | } |
85 | 85 | $filter_query = $filter_query_join.$filter_query_where; |
86 | 86 | return $filter_query; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | if ($limit != '') |
104 | 104 | { |
105 | 105 | $limit_array = explode(',', $limit); |
106 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
107 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
107 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
108 | 108 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
109 | 109 | { |
110 | 110 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
120 | 120 | } |
121 | 121 | } |
122 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
122 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
123 | 123 | |
124 | 124 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
125 | 125 | if ($globalDBdriver == 'mysql') { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } else { |
129 | 129 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
130 | 130 | } |
131 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
131 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
132 | 132 | |
133 | 133 | return $spotter_array; |
134 | 134 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | global $globalDBdriver, $globalLiveInterval; |
145 | 145 | date_default_timezone_set('UTC'); |
146 | 146 | |
147 | - $filter_query = $this->getFilter($filter,true,true); |
|
147 | + $filter_query = $this->getFilter($filter, true, true); |
|
148 | 148 | |
149 | 149 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
150 | 150 | if ($globalDBdriver == 'mysql') { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | try { |
159 | 159 | $sth = $this->db->prepare($query); |
160 | 160 | $sth->execute(); |
161 | - } catch(PDOException $e) { |
|
161 | + } catch (PDOException $e) { |
|
162 | 162 | echo $e->getMessage(); |
163 | 163 | die; |
164 | 164 | } |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | * @return Array the spotter information |
174 | 174 | * |
175 | 175 | */ |
176 | - public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
|
176 | + public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false) |
|
177 | 177 | { |
178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
179 | 179 | date_default_timezone_set('UTC'); |
180 | 180 | $usecoord = false; |
181 | 181 | if (is_array($coord) && !empty($coord)) { |
182 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
183 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
184 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
185 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
182 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
183 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
184 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
185 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
186 | 186 | $usecoord = true; |
187 | 187 | } |
188 | - $filter_query = $this->getFilter($filter,true,true); |
|
188 | + $filter_query = $this->getFilter($filter, true, true); |
|
189 | 189 | |
190 | 190 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
191 | 191 | if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | try { |
235 | 235 | $sth = $this->db->prepare($query); |
236 | 236 | $sth->execute(); |
237 | - } catch(PDOException $e) { |
|
237 | + } catch (PDOException $e) { |
|
238 | 238 | echo $e->getMessage(); |
239 | 239 | die; |
240 | 240 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | public function getLiveMarineCount($filter = array()) |
252 | 252 | { |
253 | 253 | global $globalDBdriver, $globalLiveInterval; |
254 | - $filter_query = $this->getFilter($filter,true,true); |
|
254 | + $filter_query = $this->getFilter($filter, true, true); |
|
255 | 255 | |
256 | 256 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
257 | 257 | if ($globalDBdriver == 'mysql') { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | try { |
263 | 263 | $sth = $this->db->prepare($query); |
264 | 264 | $sth->execute(); |
265 | - } catch(PDOException $e) { |
|
265 | + } catch (PDOException $e) { |
|
266 | 266 | echo $e->getMessage(); |
267 | 267 | die; |
268 | 268 | } |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | $filter_query = $this->getFilter($filter); |
286 | 286 | |
287 | 287 | if (is_array($coord)) { |
288 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
289 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
290 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
291 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
288 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
289 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
290 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
291 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
292 | 292 | } else return array(); |
293 | 293 | if ($globalDBdriver == 'mysql') { |
294 | 294 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
311 | 311 | $Marine = new Marine($this->db); |
312 | 312 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
313 | - $filter_query = $this->getFilter($filter,true,true); |
|
313 | + $filter_query = $this->getFilter($filter, true, true); |
|
314 | 314 | |
315 | 315 | if (is_array($coord)) { |
316 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
317 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
318 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
319 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
316 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
317 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
318 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
319 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
320 | 320 | } else return array(); |
321 | 321 | /* |
322 | 322 | if ($globalDBdriver == 'mysql') { |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | */ |
332 | 332 | if ($globalDBdriver == 'mysql') { |
333 | 333 | if (isset($globalArchive) && $globalArchive === TRUE) { |
334 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
334 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
335 | 335 | FROM marine_live |
336 | 336 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date |
337 | 337 | AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
338 | 338 | AND marine_live.latitude <> 0 AND marine_live.longitude <> 0'; |
339 | 339 | } else { |
340 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
340 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
341 | 341 | FROM marine_live |
342 | 342 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
343 | 343 | FROM marine_live l |
@@ -349,14 +349,14 @@ discard block |
||
349 | 349 | } |
350 | 350 | } else { |
351 | 351 | if (isset($globalArchive) && $globalArchive === TRUE) { |
352 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
352 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
353 | 353 | FROM marine_live |
354 | 354 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date |
355 | 355 | AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
356 | 356 | AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
357 | 357 | AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'"; |
358 | 358 | } else { |
359 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
359 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
360 | 360 | FROM marine_live |
361 | 361 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
362 | 362 | FROM marine_live l |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | if ($interval == '1m') |
414 | 414 | { |
415 | 415 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
416 | - } else if ($interval == '15m'){ |
|
416 | + } else if ($interval == '15m') { |
|
417 | 417 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
418 | 418 | } |
419 | 419 | } |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
422 | 422 | } |
423 | 423 | |
424 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
424 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
425 | 425 | WHERE marine_live.latitude <> '' |
426 | 426 | AND marine_live.longitude <> '' |
427 | 427 | ".$additional_query." |
428 | 428 | HAVING distance < :radius |
429 | 429 | ORDER BY distance"; |
430 | 430 | |
431 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
431 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
432 | 432 | |
433 | 433 | return $spotter_array; |
434 | 434 | } |
@@ -446,9 +446,9 @@ discard block |
||
446 | 446 | date_default_timezone_set('UTC'); |
447 | 447 | |
448 | 448 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
449 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
449 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
450 | 450 | |
451 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
451 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
452 | 452 | |
453 | 453 | return $spotter_array; |
454 | 454 | } |
@@ -459,16 +459,16 @@ discard block |
||
459 | 459 | * @return Array the spotter information |
460 | 460 | * |
461 | 461 | */ |
462 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
462 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
463 | 463 | { |
464 | 464 | $Marine = new Marine($this->db); |
465 | 465 | date_default_timezone_set('UTC'); |
466 | 466 | |
467 | 467 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
468 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
468 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
469 | 469 | |
470 | - $date = date('c',$date); |
|
471 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
470 | + $date = date('c', $date); |
|
471 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
472 | 472 | |
473 | 473 | return $spotter_array; |
474 | 474 | } |
@@ -485,9 +485,9 @@ discard block |
||
485 | 485 | date_default_timezone_set('UTC'); |
486 | 486 | |
487 | 487 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
488 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
488 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
489 | 489 | |
490 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
490 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
491 | 491 | |
492 | 492 | return $spotter_array; |
493 | 493 | } |
@@ -498,15 +498,15 @@ discard block |
||
498 | 498 | * @return Array the spotter information |
499 | 499 | * |
500 | 500 | */ |
501 | - public function getDateLiveMarineDataById($id,$date) |
|
501 | + public function getDateLiveMarineDataById($id, $date) |
|
502 | 502 | { |
503 | 503 | $Marine = new Marine($this->db); |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | |
506 | 506 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
507 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | - $date = date('c',$date); |
|
509 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
507 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | + $date = date('c', $date); |
|
509 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
510 | 510 | |
511 | 511 | return $spotter_array; |
512 | 512 | } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @return Array the spotter information |
519 | 519 | * |
520 | 520 | */ |
521 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
521 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
522 | 522 | { |
523 | 523 | global $globalDBdriver, $globalLiveInterval; |
524 | 524 | date_default_timezone_set('UTC'); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | try { |
538 | 538 | $sth = $this->db->prepare($query); |
539 | 539 | $sth->execute(array(':id' => $id)); |
540 | - } catch(PDOException $e) { |
|
540 | + } catch (PDOException $e) { |
|
541 | 541 | echo $e->getMessage(); |
542 | 542 | die; |
543 | 543 | } |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | { |
556 | 556 | date_default_timezone_set('UTC'); |
557 | 557 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
558 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
558 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
559 | 559 | try { |
560 | 560 | |
561 | 561 | $sth = $this->db->prepare($query); |
562 | 562 | $sth->execute(array(':ident' => $ident)); |
563 | - } catch(PDOException $e) { |
|
563 | + } catch (PDOException $e) { |
|
564 | 564 | echo $e->getMessage(); |
565 | 565 | die; |
566 | 566 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | |
591 | 591 | $sth = $this->db->prepare($query); |
592 | 592 | $sth->execute(); |
593 | - } catch(PDOException $e) { |
|
593 | + } catch (PDOException $e) { |
|
594 | 594 | return "error"; |
595 | 595 | } |
596 | 596 | |
@@ -613,14 +613,14 @@ discard block |
||
613 | 613 | |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute(); |
616 | - } catch(PDOException $e) { |
|
616 | + } catch (PDOException $e) { |
|
617 | 617 | return "error"; |
618 | 618 | } |
619 | 619 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
620 | 620 | $i = 0; |
621 | - $j =0; |
|
621 | + $j = 0; |
|
622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
623 | - foreach($all as $row) |
|
623 | + foreach ($all as $row) |
|
624 | 624 | { |
625 | 625 | $i++; |
626 | 626 | $j++; |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | if ($globalDebug) echo "."; |
629 | 629 | try { |
630 | 630 | |
631 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
631 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
632 | 632 | $sth->execute(); |
633 | - } catch(PDOException $e) { |
|
633 | + } catch (PDOException $e) { |
|
634 | 634 | return "error"; |
635 | 635 | } |
636 | 636 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | if ($i > 0) { |
642 | 642 | try { |
643 | 643 | |
644 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
644 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
645 | 645 | $sth->execute(); |
646 | - } catch(PDOException $e) { |
|
646 | + } catch (PDOException $e) { |
|
647 | 647 | return "error"; |
648 | 648 | } |
649 | 649 | } |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(); |
659 | - } catch(PDOException $e) { |
|
659 | + } catch (PDOException $e) { |
|
660 | 660 | return "error"; |
661 | 661 | } |
662 | 662 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -704,13 +704,13 @@ discard block |
||
704 | 704 | public function deleteLiveMarineDataByIdent($ident) |
705 | 705 | { |
706 | 706 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
707 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
707 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
708 | 708 | |
709 | 709 | try { |
710 | 710 | |
711 | 711 | $sth = $this->db->prepare($query); |
712 | 712 | $sth->execute(array(':ident' => $ident)); |
713 | - } catch(PDOException $e) { |
|
713 | + } catch (PDOException $e) { |
|
714 | 714 | return "error"; |
715 | 715 | } |
716 | 716 | |
@@ -726,13 +726,13 @@ discard block |
||
726 | 726 | public function deleteLiveMarineDataById($id) |
727 | 727 | { |
728 | 728 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
729 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
729 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
730 | 730 | |
731 | 731 | try { |
732 | 732 | |
733 | 733 | $sth = $this->db->prepare($query); |
734 | 734 | $sth->execute(array(':id' => $id)); |
735 | - } catch(PDOException $e) { |
|
735 | + } catch (PDOException $e) { |
|
736 | 736 | return "error"; |
737 | 737 | } |
738 | 738 | |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | { |
751 | 751 | global $globalDBdriver, $globalTimezone; |
752 | 752 | if ($globalDBdriver == 'mysql') { |
753 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
753 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
754 | 754 | WHERE marine_live.ident = :ident |
755 | 755 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
756 | 756 | AND marine_live.date < UTC_TIMESTAMP()'; |
757 | 757 | $query_data = array(':ident' => $ident); |
758 | 758 | } else { |
759 | - $query = "SELECT marine_live.ident FROM marine_live |
|
759 | + $query = "SELECT marine_live.ident FROM marine_live |
|
760 | 760 | WHERE marine_live.ident = :ident |
761 | 761 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
762 | 762 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -765,8 +765,8 @@ discard block |
||
765 | 765 | |
766 | 766 | $sth = $this->db->prepare($query); |
767 | 767 | $sth->execute($query_data); |
768 | - $ident_result=''; |
|
769 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
768 | + $ident_result = ''; |
|
769 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
770 | 770 | { |
771 | 771 | $ident_result = $row['ident']; |
772 | 772 | } |
@@ -783,13 +783,13 @@ discard block |
||
783 | 783 | { |
784 | 784 | global $globalDBdriver, $globalTimezone; |
785 | 785 | if ($globalDBdriver == 'mysql') { |
786 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
786 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
787 | 787 | WHERE marine_live.ident = :ident |
788 | 788 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
789 | 789 | // AND marine_live.date < UTC_TIMESTAMP()"; |
790 | 790 | $query_data = array(':ident' => $ident); |
791 | 791 | } else { |
792 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
792 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
793 | 793 | WHERE marine_live.ident = :ident |
794 | 794 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
795 | 795 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -798,8 +798,8 @@ discard block |
||
798 | 798 | |
799 | 799 | $sth = $this->db->prepare($query); |
800 | 800 | $sth->execute($query_data); |
801 | - $ident_result=''; |
|
802 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
801 | + $ident_result = ''; |
|
802 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
803 | 803 | { |
804 | 804 | $ident_result = $row['fammarine_id']; |
805 | 805 | } |
@@ -816,13 +816,13 @@ discard block |
||
816 | 816 | { |
817 | 817 | global $globalDBdriver, $globalTimezone; |
818 | 818 | if ($globalDBdriver == 'mysql') { |
819 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
819 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
820 | 820 | WHERE marine_live.fammarine_id = :id |
821 | 821 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
822 | 822 | // AND marine_live.date < UTC_TIMESTAMP()"; |
823 | 823 | $query_data = array(':id' => $id); |
824 | 824 | } else { |
825 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
825 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
826 | 826 | WHERE marine_live.fammarine_id = :id |
827 | 827 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
828 | 828 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -831,8 +831,8 @@ discard block |
||
831 | 831 | |
832 | 832 | $sth = $this->db->prepare($query); |
833 | 833 | $sth->execute($query_data); |
834 | - $ident_result=''; |
|
835 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
834 | + $ident_result = ''; |
|
835 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
836 | 836 | { |
837 | 837 | $ident_result = $row['fammarine_id']; |
838 | 838 | } |
@@ -849,13 +849,13 @@ discard block |
||
849 | 849 | { |
850 | 850 | global $globalDBdriver, $globalTimezone; |
851 | 851 | if ($globalDBdriver == 'mysql') { |
852 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
852 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
853 | 853 | WHERE marine_live.mmsi = :mmsi |
854 | 854 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
855 | 855 | // AND marine_live.date < UTC_TIMESTAMP()"; |
856 | 856 | $query_data = array(':mmsi' => $mmsi); |
857 | 857 | } else { |
858 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
858 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
859 | 859 | WHERE marine_live.mmsi = :mmsi |
860 | 860 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
861 | 861 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -864,8 +864,8 @@ discard block |
||
864 | 864 | |
865 | 865 | $sth = $this->db->prepare($query); |
866 | 866 | $sth->execute($query_data); |
867 | - $ident_result=''; |
|
868 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
867 | + $ident_result = ''; |
|
868 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
869 | 869 | { |
870 | 870 | $ident_result = $row['fammarine_id']; |
871 | 871 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | * @return String success or false |
884 | 884 | * |
885 | 885 | */ |
886 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
886 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
887 | 887 | { |
888 | 888 | global $globalURL, $globalArchive, $globalDebug; |
889 | 889 | $Common = new Common(); |
@@ -935,26 +935,26 @@ discard block |
||
935 | 935 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
936 | 936 | |
937 | 937 | |
938 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
939 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
940 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
941 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
942 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
943 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
944 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
945 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
946 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
947 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
948 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
949 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
950 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
951 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
952 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
953 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
938 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
939 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
940 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
941 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
942 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
943 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
944 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
945 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
946 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
947 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
948 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
949 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
950 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
951 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
952 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
953 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
954 | 954 | |
955 | 955 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
957 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
958 | 958 | if ($arrival_date == '') $arrival_date = NULL; |
959 | 959 | $query = ''; |
960 | 960 | if ($globalArchive) { |
@@ -964,19 +964,19 @@ discard block |
||
964 | 964 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
965 | 965 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
966 | 966 | |
967 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
967 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
968 | 968 | try { |
969 | 969 | $sth = $this->db->prepare($query); |
970 | 970 | $sth->execute($query_values); |
971 | 971 | $sth->closeCursor(); |
972 | - } catch(PDOException $e) { |
|
972 | + } catch (PDOException $e) { |
|
973 | 973 | return "error : ".$e->getMessage(); |
974 | 974 | } |
975 | 975 | |
976 | 976 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
977 | 977 | if ($globalDebug) echo '(Add to Marine archive : '; |
978 | 978 | $MarineArchive = new MarineArchive($this->db); |
979 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
|
979 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country); |
|
980 | 980 | if ($globalDebug) echo $result.')'; |
981 | 981 | } |
982 | 982 | return "success"; |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | |
985 | 985 | public function getOrderBy() |
986 | 986 | { |
987 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
987 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
988 | 988 | return $orderby; |
989 | 989 | } |
990 | 990 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (MarineLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (MarineLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -77,8 +81,11 @@ discard block |
||
77 | 81 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
78 | 82 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
79 | 83 | } |
80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
84 | + if ($filter_query_where == '' && $where) { |
|
85 | + $filter_query_where = ' WHERE'; |
|
86 | + } elseif ($filter_query_where != '' && $and) { |
|
87 | + $filter_query_where .= ' AND'; |
|
88 | + } |
|
82 | 89 | if ($filter_query_where != '') { |
83 | 90 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
84 | 91 | } |
@@ -119,9 +126,13 @@ discard block |
||
119 | 126 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
120 | 127 | } |
121 | 128 | } |
122 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
129 | + if ($orderby_query == '') { |
|
130 | + $orderby_query= ' ORDER BY date DESC'; |
|
131 | + } |
|
123 | 132 | |
124 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
133 | + if (!isset($globalLiveInterval)) { |
|
134 | + $globalLiveInterval = '200'; |
|
135 | + } |
|
125 | 136 | if ($globalDBdriver == 'mysql') { |
126 | 137 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
127 | 138 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -146,7 +157,9 @@ discard block |
||
146 | 157 | |
147 | 158 | $filter_query = $this->getFilter($filter,true,true); |
148 | 159 | |
149 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
160 | + if (!isset($globalLiveInterval)) { |
|
161 | + $globalLiveInterval = '200'; |
|
162 | + } |
|
150 | 163 | if ($globalDBdriver == 'mysql') { |
151 | 164 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
152 | 165 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -187,48 +200,72 @@ discard block |
||
187 | 200 | } |
188 | 201 | $filter_query = $this->getFilter($filter,true,true); |
189 | 202 | |
190 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
191 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
203 | + if (!isset($globalLiveInterval)) { |
|
204 | + $globalLiveInterval = '200'; |
|
205 | + } |
|
206 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
207 | + $globalMap3DMarinesLimit = '300'; |
|
208 | + } |
|
192 | 209 | if ($globalDBdriver == 'mysql') { |
193 | 210 | if (isset($globalArchive) && $globalArchive === TRUE) { |
194 | 211 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
195 | 212 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
196 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
213 | + if ($usecoord) { |
|
214 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
215 | + } |
|
197 | 216 | $query .= "UNION |
198 | 217 | SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
199 | 218 | FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date"; |
200 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
219 | + if ($usecoord) { |
|
220 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
221 | + } |
|
201 | 222 | $query .= ") AS marine |
202 | 223 | WHERE latitude <> '0' AND longitude <> '0' |
203 | 224 | ORDER BY fammarine_id, date"; |
204 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
225 | + if ($limit) { |
|
226 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
227 | + } |
|
205 | 228 | } else { |
206 | 229 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
207 | 230 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
208 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
231 | + if ($usecoord) { |
|
232 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
233 | + } |
|
209 | 234 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
210 | 235 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
211 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
236 | + if ($limit) { |
|
237 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
238 | + } |
|
212 | 239 | } |
213 | 240 | } else { |
214 | 241 | if (isset($globalArchive) && $globalArchive === TRUE) { |
215 | 242 | $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
216 | 243 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
217 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
244 | + if ($usecoord) { |
|
245 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
246 | + } |
|
218 | 247 | $query .= "UNION |
219 | 248 | SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
220 | 249 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date"; |
221 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
250 | + if ($usecoord) { |
|
251 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
252 | + } |
|
222 | 253 | $query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' "; |
223 | 254 | $query .= "ORDER BY fammarine_id, date"; |
224 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
255 | + if ($limit) { |
|
256 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
257 | + } |
|
225 | 258 | } else { |
226 | 259 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
227 | 260 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date "; |
228 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
261 | + if ($usecoord) { |
|
262 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
263 | + } |
|
229 | 264 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
230 | 265 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
231 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
266 | + if ($limit) { |
|
267 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
268 | + } |
|
232 | 269 | } |
233 | 270 | } |
234 | 271 | try { |
@@ -253,7 +290,9 @@ discard block |
||
253 | 290 | global $globalDBdriver, $globalLiveInterval; |
254 | 291 | $filter_query = $this->getFilter($filter,true,true); |
255 | 292 | |
256 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
293 | + if (!isset($globalLiveInterval)) { |
|
294 | + $globalLiveInterval = '200'; |
|
295 | + } |
|
257 | 296 | if ($globalDBdriver == 'mysql') { |
258 | 297 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
259 | 298 | } else { |
@@ -281,7 +320,9 @@ discard block |
||
281 | 320 | { |
282 | 321 | global $globalDBdriver, $globalLiveInterval; |
283 | 322 | $Marine = new Marine($this->db); |
284 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
323 | + if (!isset($globalLiveInterval)) { |
|
324 | + $globalLiveInterval = '200'; |
|
325 | + } |
|
285 | 326 | $filter_query = $this->getFilter($filter); |
286 | 327 | |
287 | 328 | if (is_array($coord)) { |
@@ -289,7 +330,9 @@ discard block |
||
289 | 330 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
290 | 331 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
291 | 332 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
292 | - } else return array(); |
|
333 | + } else { |
|
334 | + return array(); |
|
335 | + } |
|
293 | 336 | if ($globalDBdriver == 'mysql') { |
294 | 337 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
295 | 338 | } else { |
@@ -309,7 +352,9 @@ discard block |
||
309 | 352 | { |
310 | 353 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
311 | 354 | $Marine = new Marine($this->db); |
312 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
355 | + if (!isset($globalLiveInterval)) { |
|
356 | + $globalLiveInterval = '200'; |
|
357 | + } |
|
313 | 358 | $filter_query = $this->getFilter($filter,true,true); |
314 | 359 | |
315 | 360 | if (is_array($coord)) { |
@@ -317,7 +362,9 @@ discard block |
||
317 | 362 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
318 | 363 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
319 | 364 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
320 | - } else return array(); |
|
365 | + } else { |
|
366 | + return array(); |
|
367 | + } |
|
321 | 368 | /* |
322 | 369 | if ($globalDBdriver == 'mysql') { |
323 | 370 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
@@ -526,11 +573,15 @@ discard block |
||
526 | 573 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
527 | 574 | if ($globalDBdriver == 'mysql') { |
528 | 575 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
529 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
576 | + if ($liveinterval) { |
|
577 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
578 | + } |
|
530 | 579 | $query .= ' ORDER BY date'; |
531 | 580 | } else { |
532 | 581 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
533 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
582 | + if ($liveinterval) { |
|
583 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
584 | + } |
|
534 | 585 | $query .= ' ORDER BY date'; |
535 | 586 | } |
536 | 587 | |
@@ -625,7 +676,9 @@ discard block |
||
625 | 676 | $i++; |
626 | 677 | $j++; |
627 | 678 | if ($j == 30) { |
628 | - if ($globalDebug) echo "."; |
|
679 | + if ($globalDebug) { |
|
680 | + echo "."; |
|
681 | + } |
|
629 | 682 | try { |
630 | 683 | |
631 | 684 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -905,7 +958,9 @@ discard block |
||
905 | 958 | { |
906 | 959 | return false; |
907 | 960 | } |
908 | - } else return ''; |
|
961 | + } else { |
|
962 | + return ''; |
|
963 | + } |
|
909 | 964 | |
910 | 965 | if ($longitude != '') |
911 | 966 | { |
@@ -913,7 +968,9 @@ discard block |
||
913 | 968 | { |
914 | 969 | return false; |
915 | 970 | } |
916 | - } else return ''; |
|
971 | + } else { |
|
972 | + return ''; |
|
973 | + } |
|
917 | 974 | |
918 | 975 | |
919 | 976 | if ($heading != '') |
@@ -922,7 +979,9 @@ discard block |
||
922 | 979 | { |
923 | 980 | return false; |
924 | 981 | } |
925 | - } else $heading = 0; |
|
982 | + } else { |
|
983 | + $heading = 0; |
|
984 | + } |
|
926 | 985 | |
927 | 986 | if ($groundspeed != '') |
928 | 987 | { |
@@ -930,9 +989,13 @@ discard block |
||
930 | 989 | { |
931 | 990 | return false; |
932 | 991 | } |
933 | - } else $groundspeed = 0; |
|
992 | + } else { |
|
993 | + $groundspeed = 0; |
|
994 | + } |
|
934 | 995 | date_default_timezone_set('UTC'); |
935 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
996 | + if ($date == '') { |
|
997 | + $date = date("Y-m-d H:i:s", time()); |
|
998 | + } |
|
936 | 999 | |
937 | 1000 | |
938 | 1001 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -953,12 +1016,20 @@ discard block |
||
953 | 1016 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
954 | 1017 | |
955 | 1018 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1019 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1020 | + $groundspeed = 0; |
|
1021 | + } |
|
1022 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1023 | + $heading = 0; |
|
1024 | + } |
|
1025 | + if ($arrival_date == '') { |
|
1026 | + $arrival_date = NULL; |
|
1027 | + } |
|
959 | 1028 | $query = ''; |
960 | 1029 | if ($globalArchive) { |
961 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1030 | + if ($globalDebug) { |
|
1031 | + echo '-- Delete previous data -- '; |
|
1032 | + } |
|
962 | 1033 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
963 | 1034 | } |
964 | 1035 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
@@ -974,10 +1045,14 @@ discard block |
||
974 | 1045 | } |
975 | 1046 | |
976 | 1047 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
977 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
1048 | + if ($globalDebug) { |
|
1049 | + echo '(Add to Marine archive : '; |
|
1050 | + } |
|
978 | 1051 | $MarineArchive = new MarineArchive($this->db); |
979 | 1052 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
980 | - if ($globalDebug) echo $result.')'; |
|
1053 | + if ($globalDebug) { |
|
1054 | + echo $result.')'; |
|
1055 | + } |
|
981 | 1056 | } |
982 | 1057 | return "success"; |
983 | 1058 | } |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $ident = ''; |
4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
4 | +if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST, 'ident', FILTER_SANITIZE_STRING); |
|
5 | +if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
6 | 6 | if ($ident != '') |
7 | 7 | { |
8 | 8 | if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |
@@ -1,13 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $ident = ''; |
4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
4 | +if (isset($_POST['ident'])) { |
|
5 | + $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
6 | +} |
|
7 | +if (isset($_GET['ident'])) { |
|
8 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
9 | +} |
|
6 | 10 | if ($ident != '') |
7 | 11 | { |
8 | - if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
9 | - else header('Location: '.$globalURL.'/ident/'.$ident); |
|
10 | -} else { |
|
12 | + if (isset($_GET['marine'])) { |
|
13 | + header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
14 | + } else { |
|
15 | + header('Location: '.$globalURL.'/ident/'.$ident); |
|
16 | + } |
|
17 | + } else { |
|
11 | 18 | if ($globalURL == '') { |
12 | 19 | header('Location: /'); |
13 | 20 | } else { |
@@ -4,21 +4,21 @@ discard block |
||
4 | 4 | |
5 | 5 | $type = ''; |
6 | 6 | if (isset($_GET['marine'])) { |
7 | - require_once('require/class.Marine.php');; |
|
7 | + require_once('require/class.Marine.php'); ; |
|
8 | 8 | require_once('require/class.MarineLive.php'); |
9 | - $MarineLive=new MarineLive(); |
|
9 | + $MarineLive = new MarineLive(); |
|
10 | 10 | $type = 'marine'; |
11 | 11 | $page_url = $globalURL.'/marine/currently'; |
12 | 12 | } elseif (isset($_GET['tracker'])) { |
13 | - require_once('require/class.Tracker.php');; |
|
13 | + require_once('require/class.Tracker.php'); ; |
|
14 | 14 | require_once('require/class.TrackerLive.php'); |
15 | - $TrackerLive=new TrackerLive(); |
|
15 | + $TrackerLive = new TrackerLive(); |
|
16 | 16 | $type = 'tracker'; |
17 | 17 | $page_url = $globalURL.'/tracker/currently'; |
18 | 18 | } else { |
19 | - require_once('require/class.Spotter.php');; |
|
19 | + require_once('require/class.Spotter.php'); ; |
|
20 | 20 | require_once('require/class.SpotterLive.php'); |
21 | - $SpotterLive=new SpotterLive(); |
|
21 | + $SpotterLive = new SpotterLive(); |
|
22 | 22 | $type = 'aircraft'; |
23 | 23 | $page_url = $globalURL.'/currently'; |
24 | 24 | } |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | $title = "Current Activity"; |
27 | 27 | require_once('header.php'); |
28 | 28 | //calculuation for the pagination |
29 | -if(!isset($_GET['limit'])) |
|
29 | +if (!isset($_GET['limit'])) |
|
30 | 30 | { |
31 | 31 | $limit_start = 0; |
32 | 32 | $limit_end = 25; |
33 | 33 | $absolute_difference = 25; |
34 | -} else { |
|
34 | +} else { |
|
35 | 35 | $limit_explode = explode(",", $_GET['limit']); |
36 | 36 | $limit_start = $limit_explode[0]; |
37 | 37 | $limit_end = $limit_explode[1]; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
55 | 55 | elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
56 | 56 | |
57 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
57 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
58 | 58 | if ($sort != '') { |
59 | 59 | if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
60 | 60 | elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $limit_start = 0; |
32 | 32 | $limit_end = 25; |
33 | 33 | $absolute_difference = 25; |
34 | -} else { |
|
34 | +} else { |
|
35 | 35 | $limit_explode = explode(",", $_GET['limit']); |
36 | 36 | $limit_start = $limit_explode[0]; |
37 | 37 | $limit_end = $limit_explode[1]; |
@@ -50,20 +50,32 @@ discard block |
||
50 | 50 | print '</div>'; |
51 | 51 | |
52 | 52 | print '<div class="table column">'; |
53 | -if ($type == 'aircraft') print '<p>'._("The table below shows the detailed information of all current flights.").'</p>'; |
|
54 | -elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
|
55 | -elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
|
53 | +if ($type == 'aircraft') { |
|
54 | + print '<p>'._("The table below shows the detailed information of all current flights.").'</p>'; |
|
55 | +} elseif ($type == 'marine') { |
|
56 | + print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
|
57 | +} elseif ($type == 'tracker') { |
|
58 | + print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
|
59 | +} |
|
56 | 60 | |
57 | 61 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
58 | 62 | if ($sort != '') { |
59 | - if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
|
60 | - elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
|
61 | - elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort); |
|
62 | -} else { |
|
63 | - if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference); |
|
64 | - elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference); |
|
65 | - elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference); |
|
66 | -} |
|
63 | + if ($type == 'aircraft') { |
|
64 | + $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
|
65 | + } elseif ($type == 'marine') { |
|
66 | + $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
|
67 | + } elseif ($type == 'tracker') { |
|
68 | + $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort); |
|
69 | + } |
|
70 | + } else { |
|
71 | + if ($type == 'aircraft') { |
|
72 | + $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference); |
|
73 | + } elseif ($type == 'marine') { |
|
74 | + $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference); |
|
75 | + } elseif ($type == 'tracker') { |
|
76 | + $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference); |
|
77 | + } |
|
78 | + } |
|
67 | 79 | |
68 | 80 | if (!empty($spotter_array)) |
69 | 81 | { |
@@ -3,7 +3,7 @@ |
||
3 | 3 | $type = 'aircraft'; |
4 | 4 | if (isset($_GET['marine'])) $type = 'marine'; |
5 | 5 | elseif (isset($_GET['tracker'])) $type = 'tracker'; |
6 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
6 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
7 | 7 | if ($date == '') $date = date('Y-m-d'); |
8 | 8 | if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date); |
9 | 9 | elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date); |
@@ -1,11 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $type = 'aircraft'; |
4 | -if (isset($_GET['marine'])) $type = 'marine'; |
|
5 | -elseif (isset($_GET['tracker'])) $type = 'tracker'; |
|
4 | +if (isset($_GET['marine'])) { |
|
5 | + $type = 'marine'; |
|
6 | +} elseif (isset($_GET['tracker'])) { |
|
7 | + $type = 'tracker'; |
|
8 | +} |
|
6 | 9 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
7 | -if ($date == '') $date = date('Y-m-d'); |
|
8 | -if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date); |
|
9 | -elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date); |
|
10 | -else header('Location: '.$globalURL.'/date/'.$date); |
|
10 | +if ($date == '') { |
|
11 | + $date = date('Y-m-d'); |
|
12 | +} |
|
13 | +if ($type == 'marine') { |
|
14 | + header('Location: '.$globalURL.'/marine/date/'.$date); |
|
15 | +} elseif ($type == 'tracker') { |
|
16 | + header('Location: '.$globalURL.'/tracker/date/'.$date); |
|
17 | +} else { |
|
18 | + header('Location: '.$globalURL.'/date/'.$date); |
|
19 | +} |
|
11 | 20 | ?> |
12 | 21 | \ No newline at end of file |