@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
| 4 | 4 | |
| 5 | -class Marine{ |
|
| 5 | +class Marine { |
|
| 6 | 6 | public $db; |
| 7 | 7 | |
| 8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 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 spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.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'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.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,7 +72,7 @@ discard block |
||
| 72 | 72 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 73 | 73 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 74 | 74 | if ($filter_query_where != '') { |
| 75 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 75 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 76 | 76 | } |
| 77 | 77 | $filter_query = $filter_query_join.$filter_query_where; |
| 78 | 78 | return $filter_query; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @return Array the spotter information |
| 88 | 88 | * |
| 89 | 89 | */ |
| 90 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 90 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 91 | 91 | { |
| 92 | 92 | date_default_timezone_set('UTC'); |
| 93 | 93 | if (!is_string($query)) |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | $sth = $this->db->prepare($query.$limitQuery); |
| 108 | 108 | $sth->execute($params); |
| 109 | 109 | } catch (PDOException $e) { |
| 110 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 110 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 111 | 111 | exit(); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $num_rows = 0; |
| 115 | 115 | $spotter_array = array(); |
| 116 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 116 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 117 | 117 | { |
| 118 | 118 | $num_rows++; |
| 119 | 119 | $temp_array = array(); |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 147 | 147 | |
| 148 | - if($temp_array['mmsi'] != "") |
|
| 148 | + if ($temp_array['mmsi'] != "") |
|
| 149 | 149 | { |
| 150 | 150 | $Image = new Image($this->db); |
| 151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 151 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 152 | 152 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 153 | 153 | unset($Image); |
| 154 | 154 | if (count($image_array) > 0) { |
@@ -184,17 +184,17 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 186 | 186 | } else { |
| 187 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 187 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 188 | 188 | } |
| 189 | 189 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 190 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 191 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 190 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 191 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 192 | 192 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 193 | 193 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 194 | 194 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 195 | 195 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 196 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 197 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 196 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 197 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 198 | 198 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | if ($limit != "") |
| 228 | 228 | { |
| 229 | 229 | $limit_array = explode(",", $limit); |
| 230 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 231 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 230 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 231 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 232 | 232 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 233 | 233 | { |
| 234 | 234 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | } else { |
| 243 | 243 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 244 | 244 | } |
| 245 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 246 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 245 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 246 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 247 | 247 | return $spotter_array; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | if ($id == '') return array(); |
| 262 | 262 | $additional_query = "marine_output.fammarine_id = :id"; |
| 263 | 263 | $query_values = array(':id' => $id); |
| 264 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 265 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 264 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 265 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 266 | 266 | return $spotter_array; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $query_values = array(); |
| 282 | 282 | $limit_query = ''; |
| 283 | 283 | $additional_query = ''; |
| 284 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 284 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 285 | 285 | if ($ident != "") |
| 286 | 286 | { |
| 287 | 287 | if (!is_string($ident)) |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | { |
| 298 | 298 | $limit_array = explode(",", $limit); |
| 299 | 299 | |
| 300 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 301 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 300 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 301 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 302 | 302 | |
| 303 | 303 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 304 | 304 | { |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | return $spotter_array; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 325 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 326 | 326 | { |
| 327 | 327 | global $global_query, $globalTimezone, $globalDBdriver; |
| 328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $limit_query = ''; |
| 331 | 331 | $additional_query = ''; |
| 332 | 332 | |
| 333 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 333 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 334 | 334 | |
| 335 | 335 | if ($date != "") |
| 336 | 336 | { |
@@ -356,8 +356,8 @@ discard block |
||
| 356 | 356 | { |
| 357 | 357 | $limit_array = explode(",", $limit); |
| 358 | 358 | |
| 359 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 360 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 359 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 360 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 361 | 361 | |
| 362 | 362 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 363 | 363 | { |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | * @return Array list of source name |
| 389 | 389 | * |
| 390 | 390 | */ |
| 391 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 391 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 392 | 392 | { |
| 393 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 393 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 394 | 394 | $query_values = array(); |
| 395 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 395 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 396 | 396 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 397 | 397 | if ($type != '') { |
| 398 | 398 | $query_values = array(':type' => $type); |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | $source_array = array(); |
| 408 | 408 | $temp_array = array(); |
| 409 | 409 | |
| 410 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 410 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 411 | 411 | { |
| 412 | 412 | $temp_array['source_name'] = $row['source_name']; |
| 413 | 413 | $source_array[] = $temp_array; |
@@ -424,8 +424,8 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function getAllIdents($filters = array()) |
| 426 | 426 | { |
| 427 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 428 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 427 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 428 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 429 | 429 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 430 | 430 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 431 | 431 | |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $ident_array = array(); |
| 436 | 436 | $temp_array = array(); |
| 437 | 437 | |
| 438 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 438 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 439 | 439 | { |
| 440 | 440 | $temp_array['ident'] = $row['ident']; |
| 441 | 441 | $ident_array[] = $temp_array; |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | public function getIdentity($mmsi) |
| 454 | 454 | { |
| 455 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 455 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 456 | 456 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 457 | 457 | $sth = $this->db->prepare($query); |
| 458 | 458 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -477,12 +477,12 @@ discard block |
||
| 477 | 477 | } else $offset = '+00:00'; |
| 478 | 478 | |
| 479 | 479 | if ($globalDBdriver == 'mysql') { |
| 480 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 480 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 481 | 481 | FROM marine_output |
| 482 | 482 | WHERE marine_output.date <> '' |
| 483 | 483 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
| 484 | 484 | } else { |
| 485 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 485 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 486 | 486 | FROM marine_output |
| 487 | 487 | WHERE marine_output.date <> '' |
| 488 | 488 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | $date_array = array(); |
| 495 | 495 | $temp_array = array(); |
| 496 | 496 | |
| 497 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 497 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 498 | 498 | { |
| 499 | 499 | $temp_array['date'] = $row['date']; |
| 500 | 500 | |
@@ -513,11 +513,11 @@ discard block |
||
| 513 | 513 | * @return String success or false |
| 514 | 514 | * |
| 515 | 515 | */ |
| 516 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 516 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 517 | 517 | { |
| 518 | 518 | |
| 519 | 519 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 520 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 520 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 521 | 521 | |
| 522 | 522 | try { |
| 523 | 523 | $sth = $this->db->prepare($query); |
@@ -539,11 +539,11 @@ discard block |
||
| 539 | 539 | * @return String success or false |
| 540 | 540 | * |
| 541 | 541 | */ |
| 542 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
| 542 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
| 543 | 543 | { |
| 544 | 544 | |
| 545 | 545 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 546 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 546 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
| 547 | 547 | |
| 548 | 548 | try { |
| 549 | 549 | $sth = $this->db->prepare($query); |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 567 | 567 | { |
| 568 | 568 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 569 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 569 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 570 | 570 | |
| 571 | 571 | try { |
| 572 | 572 | $sth = $this->db->prepare($query); |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @param String $verticalrate vertival rate of flight |
| 605 | 605 | * @return String success or false |
| 606 | 606 | */ |
| 607 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
| 607 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
| 608 | 608 | { |
| 609 | 609 | global $globalURL, $globalMarineImageFetch; |
| 610 | 610 | |
@@ -671,31 +671,31 @@ discard block |
||
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | |
| 674 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 674 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 675 | 675 | { |
| 676 | 676 | $date = date("Y-m-d H:i:s", time()); |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 680 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 681 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 682 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 683 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 684 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 685 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 686 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 687 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 688 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 689 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 690 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 691 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 692 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 679 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 680 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 681 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 682 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 683 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 684 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 685 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 686 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 687 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 688 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 689 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 690 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 691 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 692 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 693 | 693 | |
| 694 | 694 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 695 | 695 | $Image = new Image($this->db); |
| 696 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 696 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 697 | 697 | if (!isset($image_array[0]['mmsi'])) { |
| 698 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 698 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 699 | 699 | } |
| 700 | 700 | unset($Image); |
| 701 | 701 | } |
@@ -707,10 +707,10 @@ discard block |
||
| 707 | 707 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 708 | 708 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 709 | 709 | if ($arrival_date == '') $arrival_date = NULL; |
| 710 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 710 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 711 | 711 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 712 | 712 | |
| 713 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 713 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 714 | 714 | try { |
| 715 | 715 | |
| 716 | 716 | $sth = $this->db->prepare($query); |
@@ -735,13 +735,13 @@ discard block |
||
| 735 | 735 | { |
| 736 | 736 | global $globalDBdriver, $globalTimezone; |
| 737 | 737 | if ($globalDBdriver == 'mysql') { |
| 738 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 738 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 739 | 739 | WHERE marine_output.ident = :ident |
| 740 | 740 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 741 | 741 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 742 | 742 | $query_data = array(':ident' => $ident); |
| 743 | 743 | } else { |
| 744 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 744 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 745 | 745 | WHERE marine_output.ident = :ident |
| 746 | 746 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 747 | 747 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -750,8 +750,8 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | $sth = $this->db->prepare($query); |
| 752 | 752 | $sth->execute($query_data); |
| 753 | - $ident_result=''; |
|
| 754 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 753 | + $ident_result = ''; |
|
| 754 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 755 | 755 | { |
| 756 | 756 | $ident_result = $row['ident']; |
| 757 | 757 | } |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | return false; |
| 778 | 778 | } else { |
| 779 | 779 | $q_array = explode(" ", $q); |
| 780 | - foreach ($q_array as $q_item){ |
|
| 781 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 780 | + foreach ($q_array as $q_item) { |
|
| 781 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 782 | 782 | $additional_query .= " AND ("; |
| 783 | 783 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 784 | 784 | $additional_query .= ")"; |
@@ -786,11 +786,11 @@ discard block |
||
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | if ($globalDBdriver == 'mysql') { |
| 789 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 789 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 790 | 790 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 791 | 791 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 792 | 792 | } else { |
| 793 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 793 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 794 | 794 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 795 | 795 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 796 | 796 | } |
@@ -809,16 +809,16 @@ discard block |
||
| 809 | 809 | * |
| 810 | 810 | */ |
| 811 | 811 | |
| 812 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 812 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 813 | 813 | { |
| 814 | 814 | global $globalDBdriver, $globalArchive; |
| 815 | 815 | //$filter_query = $this->getFilter($filters,true,true); |
| 816 | - $Connection= new Connection($this->db); |
|
| 816 | + $Connection = new Connection($this->db); |
|
| 817 | 817 | if (!$Connection->tableExists('countries')) return array(); |
| 818 | 818 | require_once('class.SpotterLive.php'); |
| 819 | 819 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 820 | 820 | $MarineLive = new MarineLive($this->db); |
| 821 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
| 821 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
| 822 | 822 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 823 | 823 | if ($olderthanmonths > 0) { |
| 824 | 824 | if ($globalDBdriver == 'mysql') { |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | } else { |
| 839 | 839 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
| 840 | 840 | $MarineArchive = new MarineArchive($this->db); |
| 841 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
| 841 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
| 842 | 842 | $filter_query .= " over_country <> ''"; |
| 843 | 843 | if ($olderthanmonths > 0) { |
| 844 | 844 | if ($globalDBdriver == 'mysql') { |
@@ -866,7 +866,7 @@ discard block |
||
| 866 | 866 | $flight_array = array(); |
| 867 | 867 | $temp_array = array(); |
| 868 | 868 | |
| 869 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 869 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 870 | 870 | { |
| 871 | 871 | $temp_array['marine_count'] = $row['nb']; |
| 872 | 872 | $temp_array['marine_country'] = $row['name']; |
@@ -885,11 +885,11 @@ discard block |
||
| 885 | 885 | * @return Array the callsign list |
| 886 | 886 | * |
| 887 | 887 | */ |
| 888 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 888 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 889 | 889 | { |
| 890 | 890 | global $globalDBdriver; |
| 891 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 892 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 891 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 892 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 893 | 893 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 894 | 894 | if ($olderthanmonths > 0) { |
| 895 | 895 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -903,28 +903,28 @@ discard block |
||
| 903 | 903 | if ($year != '') { |
| 904 | 904 | if ($globalDBdriver == 'mysql') { |
| 905 | 905 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 906 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 906 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 907 | 907 | } else { |
| 908 | 908 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 909 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 909 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 910 | 910 | } |
| 911 | 911 | } |
| 912 | 912 | if ($month != '') { |
| 913 | 913 | if ($globalDBdriver == 'mysql') { |
| 914 | 914 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 915 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 915 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 916 | 916 | } else { |
| 917 | 917 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 918 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 918 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 919 | 919 | } |
| 920 | 920 | } |
| 921 | 921 | if ($day != '') { |
| 922 | 922 | if ($globalDBdriver == 'mysql') { |
| 923 | 923 | $query .= " AND DAY(marine_output.date) = :day"; |
| 924 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 924 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 925 | 925 | } else { |
| 926 | 926 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 927 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 927 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 928 | 928 | } |
| 929 | 929 | } |
| 930 | 930 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | $callsign_array = array(); |
| 937 | 937 | $temp_array = array(); |
| 938 | 938 | |
| 939 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 939 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 940 | 940 | { |
| 941 | 941 | $temp_array['callsign_icao'] = $row['ident']; |
| 942 | 942 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | $date_array = array(); |
| 989 | 989 | $temp_array = array(); |
| 990 | 990 | |
| 991 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 991 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 992 | 992 | { |
| 993 | 993 | $temp_array['date_name'] = $row['date_name']; |
| 994 | 994 | $temp_array['date_count'] = $row['date_count']; |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | $datetime = new DateTime(); |
| 1015 | 1015 | $offset = $datetime->format('P'); |
| 1016 | 1016 | } else $offset = '+00:00'; |
| 1017 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1017 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1018 | 1018 | if ($globalDBdriver == 'mysql') { |
| 1019 | 1019 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1020 | 1020 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | $date_array = array(); |
| 1036 | 1036 | $temp_array = array(); |
| 1037 | 1037 | |
| 1038 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1038 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1039 | 1039 | { |
| 1040 | 1040 | $temp_array['date_name'] = $row['date_name']; |
| 1041 | 1041 | $temp_array['date_count'] = $row['date_count']; |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | $datetime = new DateTime(); |
| 1061 | 1061 | $offset = $datetime->format('P'); |
| 1062 | 1062 | } else $offset = '+00:00'; |
| 1063 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1063 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1064 | 1064 | if ($globalDBdriver == 'mysql') { |
| 1065 | 1065 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1066 | 1066 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | $date_array = array(); |
| 1082 | 1082 | $temp_array = array(); |
| 1083 | 1083 | |
| 1084 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1084 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1085 | 1085 | { |
| 1086 | 1086 | $temp_array['date_name'] = $row['date_name']; |
| 1087 | 1087 | $temp_array['date_count'] = $row['date_count']; |
@@ -1128,7 +1128,7 @@ discard block |
||
| 1128 | 1128 | $date_array = array(); |
| 1129 | 1129 | $temp_array = array(); |
| 1130 | 1130 | |
| 1131 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1131 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1132 | 1132 | { |
| 1133 | 1133 | $temp_array['month_name'] = $row['month_name']; |
| 1134 | 1134 | $temp_array['year_name'] = $row['year_name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | $datetime = new DateTime(); |
| 1158 | 1158 | $offset = $datetime->format('P'); |
| 1159 | 1159 | } else $offset = '+00:00'; |
| 1160 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1160 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1161 | 1161 | if ($globalDBdriver == 'mysql') { |
| 1162 | 1162 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 1163 | 1163 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1178,7 +1178,7 @@ discard block |
||
| 1178 | 1178 | $date_array = array(); |
| 1179 | 1179 | $temp_array = array(); |
| 1180 | 1180 | |
| 1181 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1181 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1182 | 1182 | { |
| 1183 | 1183 | $temp_array['year_name'] = $row['year_name']; |
| 1184 | 1184 | $temp_array['month_name'] = $row['month_name']; |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | * @return Array the hour list |
| 1199 | 1199 | * |
| 1200 | 1200 | */ |
| 1201 | - public function countAllHours($orderby,$filters = array()) |
|
| 1201 | + public function countAllHours($orderby, $filters = array()) |
|
| 1202 | 1202 | { |
| 1203 | 1203 | global $globalTimezone, $globalDBdriver; |
| 1204 | 1204 | if ($globalTimezone != '') { |
@@ -1246,7 +1246,7 @@ discard block |
||
| 1246 | 1246 | $hour_array = array(); |
| 1247 | 1247 | $temp_array = array(); |
| 1248 | 1248 | |
| 1249 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1249 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1250 | 1250 | { |
| 1251 | 1251 | $temp_array['hour_name'] = $row['hour_name']; |
| 1252 | 1252 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1268,8 +1268,8 @@ discard block |
||
| 1268 | 1268 | public function countAllHoursByDate($date, $filters = array()) |
| 1269 | 1269 | { |
| 1270 | 1270 | global $globalTimezone, $globalDBdriver; |
| 1271 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1272 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1271 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1272 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1273 | 1273 | if ($globalTimezone != '') { |
| 1274 | 1274 | date_default_timezone_set($globalTimezone); |
| 1275 | 1275 | $datetime = new DateTime($date); |
@@ -1277,12 +1277,12 @@ discard block |
||
| 1277 | 1277 | } else $offset = '+00:00'; |
| 1278 | 1278 | |
| 1279 | 1279 | if ($globalDBdriver == 'mysql') { |
| 1280 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1280 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1281 | 1281 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1282 | 1282 | GROUP BY hour_name |
| 1283 | 1283 | ORDER BY hour_name ASC"; |
| 1284 | 1284 | } else { |
| 1285 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1285 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1286 | 1286 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1287 | 1287 | GROUP BY hour_name |
| 1288 | 1288 | ORDER BY hour_name ASC"; |
@@ -1294,7 +1294,7 @@ discard block |
||
| 1294 | 1294 | $hour_array = array(); |
| 1295 | 1295 | $temp_array = array(); |
| 1296 | 1296 | |
| 1297 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1297 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1298 | 1298 | { |
| 1299 | 1299 | $temp_array['hour_name'] = $row['hour_name']; |
| 1300 | 1300 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1316,8 +1316,8 @@ discard block |
||
| 1316 | 1316 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1317 | 1317 | { |
| 1318 | 1318 | global $globalTimezone, $globalDBdriver; |
| 1319 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1320 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1319 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1320 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1321 | 1321 | if ($globalTimezone != '') { |
| 1322 | 1322 | date_default_timezone_set($globalTimezone); |
| 1323 | 1323 | $datetime = new DateTime(); |
@@ -1325,12 +1325,12 @@ discard block |
||
| 1325 | 1325 | } else $offset = '+00:00'; |
| 1326 | 1326 | |
| 1327 | 1327 | if ($globalDBdriver == 'mysql') { |
| 1328 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1328 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1329 | 1329 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1330 | 1330 | GROUP BY hour_name |
| 1331 | 1331 | ORDER BY hour_name ASC"; |
| 1332 | 1332 | } else { |
| 1333 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1333 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1334 | 1334 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1335 | 1335 | GROUP BY hour_name |
| 1336 | 1336 | ORDER BY hour_name ASC"; |
@@ -1338,12 +1338,12 @@ discard block |
||
| 1338 | 1338 | |
| 1339 | 1339 | |
| 1340 | 1340 | $sth = $this->db->prepare($query); |
| 1341 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1341 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1342 | 1342 | |
| 1343 | 1343 | $hour_array = array(); |
| 1344 | 1344 | $temp_array = array(); |
| 1345 | 1345 | |
| 1346 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1346 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1347 | 1347 | { |
| 1348 | 1348 | $temp_array['hour_name'] = $row['hour_name']; |
| 1349 | 1349 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1362,33 +1362,33 @@ discard block |
||
| 1362 | 1362 | * @return Integer the number of vessels |
| 1363 | 1363 | * |
| 1364 | 1364 | */ |
| 1365 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
| 1365 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
| 1366 | 1366 | { |
| 1367 | 1367 | global $globalDBdriver; |
| 1368 | 1368 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
| 1369 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1369 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1370 | 1370 | $query_values = array(); |
| 1371 | 1371 | $query = ''; |
| 1372 | 1372 | if ($year != '') { |
| 1373 | 1373 | if ($globalDBdriver == 'mysql') { |
| 1374 | 1374 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1375 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1375 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1376 | 1376 | } else { |
| 1377 | 1377 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1378 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1378 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1379 | 1379 | } |
| 1380 | 1380 | } |
| 1381 | 1381 | if ($month != '') { |
| 1382 | 1382 | if ($globalDBdriver == 'mysql') { |
| 1383 | 1383 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1384 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1384 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1385 | 1385 | } else { |
| 1386 | 1386 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1387 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1387 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1388 | 1388 | } |
| 1389 | 1389 | } |
| 1390 | 1390 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1391 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1392 | 1392 | |
| 1393 | 1393 | $sth = $this->db->prepare($queryi); |
| 1394 | 1394 | $sth->execute($query_values); |
@@ -1401,32 +1401,32 @@ discard block |
||
| 1401 | 1401 | * @return Integer the number of vessels |
| 1402 | 1402 | * |
| 1403 | 1403 | */ |
| 1404 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
| 1404 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
| 1405 | 1405 | { |
| 1406 | 1406 | global $globalDBdriver; |
| 1407 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1407 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1408 | 1408 | $query_values = array(); |
| 1409 | 1409 | $query = ''; |
| 1410 | 1410 | if ($year != '') { |
| 1411 | 1411 | if ($globalDBdriver == 'mysql') { |
| 1412 | 1412 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1413 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1413 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1414 | 1414 | } else { |
| 1415 | 1415 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1416 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1416 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1417 | 1417 | } |
| 1418 | 1418 | } |
| 1419 | 1419 | if ($month != '') { |
| 1420 | 1420 | if ($globalDBdriver == 'mysql') { |
| 1421 | 1421 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1422 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1422 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1423 | 1423 | } else { |
| 1424 | 1424 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1425 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1425 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | 1428 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1429 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1430 | 1430 | |
| 1431 | 1431 | $sth = $this->db->prepare($queryi); |
| 1432 | 1432 | $sth->execute($query_values); |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | public function countAllHoursFromToday($filters = array()) |
| 1444 | 1444 | { |
| 1445 | 1445 | global $globalTimezone, $globalDBdriver; |
| 1446 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1446 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1447 | 1447 | if ($globalTimezone != '') { |
| 1448 | 1448 | date_default_timezone_set($globalTimezone); |
| 1449 | 1449 | $datetime = new DateTime(); |
@@ -1451,12 +1451,12 @@ discard block |
||
| 1451 | 1451 | } else $offset = '+00:00'; |
| 1452 | 1452 | |
| 1453 | 1453 | if ($globalDBdriver == 'mysql') { |
| 1454 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1454 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1455 | 1455 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1456 | 1456 | GROUP BY hour_name |
| 1457 | 1457 | ORDER BY hour_name ASC"; |
| 1458 | 1458 | } else { |
| 1459 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1459 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1460 | 1460 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1461 | 1461 | GROUP BY hour_name |
| 1462 | 1462 | ORDER BY hour_name ASC"; |
@@ -1468,7 +1468,7 @@ discard block |
||
| 1468 | 1468 | $hour_array = array(); |
| 1469 | 1469 | $temp_array = array(); |
| 1470 | 1470 | |
| 1471 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1471 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1472 | 1472 | { |
| 1473 | 1473 | $temp_array['hour_name'] = $row['hour_name']; |
| 1474 | 1474 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1487,9 +1487,9 @@ discard block |
||
| 1487 | 1487 | */ |
| 1488 | 1488 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1489 | 1489 | { |
| 1490 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1490 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1491 | 1491 | |
| 1492 | - $query = "SELECT marine_output.marine_id |
|
| 1492 | + $query = "SELECT marine_output.marine_id |
|
| 1493 | 1493 | FROM marine_output |
| 1494 | 1494 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1495 | 1495 | |
@@ -1497,7 +1497,7 @@ discard block |
||
| 1497 | 1497 | $sth = $this->db->prepare($query); |
| 1498 | 1498 | $sth->execute(); |
| 1499 | 1499 | |
| 1500 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1500 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1501 | 1501 | { |
| 1502 | 1502 | return $row['marine_id']; |
| 1503 | 1503 | } |
@@ -1522,23 +1522,23 @@ discard block |
||
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | $current_date = date("Y-m-d H:i:s"); |
| 1525 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1525 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1526 | 1526 | |
| 1527 | 1527 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1528 | 1528 | |
| 1529 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1529 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1530 | 1530 | $years = $time_array['years']; |
| 1531 | 1531 | |
| 1532 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1532 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1533 | 1533 | $months = $time_array['months']; |
| 1534 | 1534 | |
| 1535 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1535 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1536 | 1536 | $days = $time_array['days']; |
| 1537 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1537 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1538 | 1538 | $hours = $time_array['hours']; |
| 1539 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1539 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1540 | 1540 | $minutes = $time_array['minutes']; |
| 1541 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1541 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1542 | 1542 | |
| 1543 | 1543 | return $time_array; |
| 1544 | 1544 | } |
@@ -1561,63 +1561,63 @@ discard block |
||
| 1561 | 1561 | $temp_array['direction_degree'] = $direction; |
| 1562 | 1562 | $temp_array['direction_shortname'] = "N"; |
| 1563 | 1563 | $temp_array['direction_fullname'] = "North"; |
| 1564 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1564 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1565 | 1565 | $temp_array['direction_degree'] = $direction; |
| 1566 | 1566 | $temp_array['direction_shortname'] = "NNE"; |
| 1567 | 1567 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1568 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1568 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1569 | 1569 | $temp_array['direction_degree'] = $direction; |
| 1570 | 1570 | $temp_array['direction_shortname'] = "NE"; |
| 1571 | 1571 | $temp_array['direction_fullname'] = "Northeast"; |
| 1572 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1572 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1573 | 1573 | $temp_array['direction_degree'] = $direction; |
| 1574 | 1574 | $temp_array['direction_shortname'] = "ENE"; |
| 1575 | 1575 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1576 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1576 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1577 | 1577 | $temp_array['direction_degree'] = $direction; |
| 1578 | 1578 | $temp_array['direction_shortname'] = "E"; |
| 1579 | 1579 | $temp_array['direction_fullname'] = "East"; |
| 1580 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1580 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1581 | 1581 | $temp_array['direction_degree'] = $direction; |
| 1582 | 1582 | $temp_array['direction_shortname'] = "ESE"; |
| 1583 | 1583 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1584 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1584 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1585 | 1585 | $temp_array['direction_degree'] = $direction; |
| 1586 | 1586 | $temp_array['direction_shortname'] = "SE"; |
| 1587 | 1587 | $temp_array['direction_fullname'] = "Southeast"; |
| 1588 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1588 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1589 | 1589 | $temp_array['direction_degree'] = $direction; |
| 1590 | 1590 | $temp_array['direction_shortname'] = "SSE"; |
| 1591 | 1591 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1592 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1592 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1593 | 1593 | $temp_array['direction_degree'] = $direction; |
| 1594 | 1594 | $temp_array['direction_shortname'] = "S"; |
| 1595 | 1595 | $temp_array['direction_fullname'] = "South"; |
| 1596 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1596 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1597 | 1597 | $temp_array['direction_degree'] = $direction; |
| 1598 | 1598 | $temp_array['direction_shortname'] = "SSW"; |
| 1599 | 1599 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1600 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1600 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1601 | 1601 | $temp_array['direction_degree'] = $direction; |
| 1602 | 1602 | $temp_array['direction_shortname'] = "SW"; |
| 1603 | 1603 | $temp_array['direction_fullname'] = "Southwest"; |
| 1604 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1604 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1605 | 1605 | $temp_array['direction_degree'] = $direction; |
| 1606 | 1606 | $temp_array['direction_shortname'] = "WSW"; |
| 1607 | 1607 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1608 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1608 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1609 | 1609 | $temp_array['direction_degree'] = $direction; |
| 1610 | 1610 | $temp_array['direction_shortname'] = "W"; |
| 1611 | 1611 | $temp_array['direction_fullname'] = "West"; |
| 1612 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1612 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1613 | 1613 | $temp_array['direction_degree'] = $direction; |
| 1614 | 1614 | $temp_array['direction_shortname'] = "WNW"; |
| 1615 | 1615 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1616 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1616 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1617 | 1617 | $temp_array['direction_degree'] = $direction; |
| 1618 | 1618 | $temp_array['direction_shortname'] = "NW"; |
| 1619 | 1619 | $temp_array['direction_fullname'] = "Northwest"; |
| 1620 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1620 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1621 | 1621 | $temp_array['direction_degree'] = $direction; |
| 1622 | 1622 | $temp_array['direction_shortname'] = "NNW"; |
| 1623 | 1623 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1634,11 +1634,11 @@ discard block |
||
| 1634 | 1634 | * @param Float $longitude longitute of the flight |
| 1635 | 1635 | * @return String the countrie |
| 1636 | 1636 | */ |
| 1637 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1637 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1638 | 1638 | { |
| 1639 | 1639 | global $globalDBdriver, $globalDebug; |
| 1640 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1641 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1640 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1641 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1642 | 1642 | |
| 1643 | 1643 | $Connection = new Connection($this->db); |
| 1644 | 1644 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1678,7 +1678,7 @@ discard block |
||
| 1678 | 1678 | public function getCountryFromISO2($iso2) |
| 1679 | 1679 | { |
| 1680 | 1680 | global $globalDBdriver, $globalDebug; |
| 1681 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1681 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1682 | 1682 | |
| 1683 | 1683 | $Connection = new Connection($this->db); |
| 1684 | 1684 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1726,7 +1726,7 @@ discard block |
||
| 1726 | 1726 | |
| 1727 | 1727 | $bitly_data = json_decode($bitly_data); |
| 1728 | 1728 | $bitly_url = ''; |
| 1729 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1729 | + if ($bitly_data->status_txt = "OK") { |
|
| 1730 | 1730 | $bitly_url = $bitly_data->data->url; |
| 1731 | 1731 | } |
| 1732 | 1732 | |
@@ -1740,11 +1740,11 @@ discard block |
||
| 1740 | 1740 | * @return Array the vessel type list |
| 1741 | 1741 | * |
| 1742 | 1742 | */ |
| 1743 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 1743 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1744 | 1744 | { |
| 1745 | 1745 | global $globalDBdriver; |
| 1746 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1747 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
| 1746 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1747 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
| 1748 | 1748 | FROM marine_output ".$filter_query." marine_output.type <> ''"; |
| 1749 | 1749 | if ($olderthanmonths > 0) { |
| 1750 | 1750 | if ($globalDBdriver == 'mysql') { |
@@ -1764,28 +1764,28 @@ discard block |
||
| 1764 | 1764 | if ($year != '') { |
| 1765 | 1765 | if ($globalDBdriver == 'mysql') { |
| 1766 | 1766 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1767 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1767 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1768 | 1768 | } else { |
| 1769 | 1769 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1770 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1770 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1771 | 1771 | } |
| 1772 | 1772 | } |
| 1773 | 1773 | if ($month != '') { |
| 1774 | 1774 | if ($globalDBdriver == 'mysql') { |
| 1775 | 1775 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1776 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1776 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1777 | 1777 | } else { |
| 1778 | 1778 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1779 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1779 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1780 | 1780 | } |
| 1781 | 1781 | } |
| 1782 | 1782 | if ($day != '') { |
| 1783 | 1783 | if ($globalDBdriver == 'mysql') { |
| 1784 | 1784 | $query .= " AND DAY(marine_output.date) = :day"; |
| 1785 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1785 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1786 | 1786 | } else { |
| 1787 | 1787 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 1788 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1788 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1789 | 1789 | } |
| 1790 | 1790 | } |
| 1791 | 1791 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
@@ -1794,7 +1794,7 @@ discard block |
||
| 1794 | 1794 | $sth->execute($query_values); |
| 1795 | 1795 | $marine_array = array(); |
| 1796 | 1796 | $temp_array = array(); |
| 1797 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1797 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1798 | 1798 | { |
| 1799 | 1799 | $temp_array['marine_type'] = $row['marine_type']; |
| 1800 | 1800 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
@@ -1805,7 +1805,7 @@ discard block |
||
| 1805 | 1805 | |
| 1806 | 1806 | public function getOrderBy() |
| 1807 | 1807 | { |
| 1808 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 1808 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 1809 | 1809 | |
| 1810 | 1810 | return $orderby; |
| 1811 | 1811 | |
@@ -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' => $over_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' => $over_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,13 +329,13 @@ 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 | - $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"; |
|
| 336 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 337 | 337 | |
| 338 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 338 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
| 339 | 339 | |
| 340 | 340 | return $spotter_array; |
| 341 | 341 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | try { |
| 349 | 349 | $sth = $this->db->prepare($query); |
| 350 | 350 | $sth->execute(); |
| 351 | - } catch(PDOException $e) { |
|
| 351 | + } catch (PDOException $e) { |
|
| 352 | 352 | echo $e->getMessage(); |
| 353 | 353 | die; |
| 354 | 354 | } |
@@ -360,24 +360,24 @@ discard block |
||
| 360 | 360 | * @return Array the spotter information |
| 361 | 361 | * |
| 362 | 362 | */ |
| 363 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 363 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
| 364 | 364 | { |
| 365 | 365 | global $globalDBdriver, $globalLiveInterval; |
| 366 | 366 | date_default_timezone_set('UTC'); |
| 367 | 367 | |
| 368 | 368 | $filter_query = ''; |
| 369 | 369 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 370 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 370 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 371 | 371 | } |
| 372 | 372 | // Use spotter_output also ? |
| 373 | 373 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 374 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 374 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 375 | 375 | } |
| 376 | 376 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 377 | 377 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 378 | 378 | } |
| 379 | 379 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 380 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 380 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -396,14 +396,14 @@ discard block |
||
| 396 | 396 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 397 | 397 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 398 | 398 | */ |
| 399 | - $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 |
|
| 399 | + $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 |
|
| 400 | 400 | FROM marine_archive |
| 401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 402 | 402 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 403 | 403 | '.$filter_query.' ORDER BY fammarine_id'; |
| 404 | 404 | } else { |
| 405 | 405 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
| 406 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 406 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 407 | 407 | FROM marine_archive |
| 408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 409 | 409 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | try { |
| 414 | 414 | $sth = $this->db->prepare($query); |
| 415 | 415 | $sth->execute(); |
| 416 | - } catch(PDOException $e) { |
|
| 416 | + } catch (PDOException $e) { |
|
| 417 | 417 | echo $e->getMessage(); |
| 418 | 418 | die; |
| 419 | 419 | } |
@@ -428,24 +428,24 @@ discard block |
||
| 428 | 428 | * @return Array the spotter information |
| 429 | 429 | * |
| 430 | 430 | */ |
| 431 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 431 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
| 432 | 432 | { |
| 433 | 433 | global $globalDBdriver, $globalLiveInterval; |
| 434 | 434 | date_default_timezone_set('UTC'); |
| 435 | 435 | |
| 436 | 436 | $filter_query = ''; |
| 437 | 437 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 438 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 438 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 439 | 439 | } |
| 440 | 440 | // Should use spotter_output also ? |
| 441 | 441 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 442 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 442 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 443 | 443 | } |
| 444 | 444 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 445 | 445 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 446 | 446 | } |
| 447 | 447 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 448 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 448 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | FROM marine_archive |
| 456 | 456 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 457 | 457 | */ |
| 458 | - $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 |
|
| 458 | + $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 |
|
| 459 | 459 | FROM marine_archive_output |
| 460 | 460 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 461 | 461 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 471 | 471 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 472 | 472 | */ |
| 473 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 473 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 474 | 474 | FROM marine_archive_output |
| 475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 476 | 476 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | try { |
| 483 | 483 | $sth = $this->db->prepare($query); |
| 484 | 484 | $sth->execute(); |
| 485 | - } catch(PDOException $e) { |
|
| 485 | + } catch (PDOException $e) { |
|
| 486 | 486 | echo $e->getMessage(); |
| 487 | 487 | die; |
| 488 | 488 | } |
@@ -497,23 +497,23 @@ discard block |
||
| 497 | 497 | * @return Array the spotter information |
| 498 | 498 | * |
| 499 | 499 | */ |
| 500 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 500 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
| 501 | 501 | { |
| 502 | 502 | global $globalDBdriver, $globalLiveInterval; |
| 503 | 503 | date_default_timezone_set('UTC'); |
| 504 | 504 | |
| 505 | 505 | $filter_query = ''; |
| 506 | 506 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 507 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 507 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 508 | 508 | } |
| 509 | 509 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 510 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 510 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 511 | 511 | } |
| 512 | 512 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 513 | 513 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 514 | 514 | } |
| 515 | 515 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 516 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 516 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | try { |
| 529 | 529 | $sth = $this->db->prepare($query); |
| 530 | 530 | $sth->execute(); |
| 531 | - } catch(PDOException $e) { |
|
| 531 | + } catch (PDOException $e) { |
|
| 532 | 532 | echo $e->getMessage(); |
| 533 | 533 | die; |
| 534 | 534 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * @return Array the spotter information |
| 549 | 549 | * |
| 550 | 550 | */ |
| 551 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 551 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 552 | 552 | { |
| 553 | 553 | global $globalTimezone, $globalDBdriver; |
| 554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | $q_array = explode(" ", $q); |
| 572 | 572 | |
| 573 | - foreach ($q_array as $q_item){ |
|
| 573 | + foreach ($q_array as $q_item) { |
|
| 574 | 574 | $additional_query .= " AND ("; |
| 575 | 575 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 576 | 576 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | if ($registration != "") |
| 604 | 604 | { |
| 605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 605 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 606 | 606 | if (!is_string($registration)) |
| 607 | 607 | { |
| 608 | 608 | return false; |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | if ($aircraft_icao != "") |
| 615 | 615 | { |
| 616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 616 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 617 | 617 | if (!is_string($aircraft_icao)) |
| 618 | 618 | { |
| 619 | 619 | return false; |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | |
| 625 | 625 | if ($aircraft_manufacturer != "") |
| 626 | 626 | { |
| 627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 628 | 628 | if (!is_string($aircraft_manufacturer)) |
| 629 | 629 | { |
| 630 | 630 | return false; |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | if ($airline_icao != "") |
| 647 | 647 | { |
| 648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 648 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 649 | 649 | if (!is_string($airline_icao)) |
| 650 | 650 | { |
| 651 | 651 | return false; |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | if ($airline_country != "") |
| 658 | 658 | { |
| 659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 659 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 660 | 660 | if (!is_string($airline_country)) |
| 661 | 661 | { |
| 662 | 662 | return false; |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | if ($airline_type != "") |
| 669 | 669 | { |
| 670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 670 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 671 | 671 | if (!is_string($airline_type)) |
| 672 | 672 | { |
| 673 | 673 | return false; |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | |
| 690 | 690 | if ($airport != "") |
| 691 | 691 | { |
| 692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 692 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 693 | 693 | if (!is_string($airport)) |
| 694 | 694 | { |
| 695 | 695 | return false; |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | |
| 701 | 701 | if ($airport_country != "") |
| 702 | 702 | { |
| 703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 703 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 704 | 704 | if (!is_string($airport_country)) |
| 705 | 705 | { |
| 706 | 706 | return false; |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | if ($callsign != "") |
| 713 | 713 | { |
| 714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 714 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 715 | 715 | if (!is_string($callsign)) |
| 716 | 716 | { |
| 717 | 717 | return false; |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | $translate = $Translation->ident2icao($callsign); |
| 720 | 720 | if ($translate != $callsign) { |
| 721 | 721 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
| 722 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 722 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 723 | 723 | } else { |
| 724 | 724 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
| 725 | 725 | } |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | |
| 729 | 729 | if ($owner != "") |
| 730 | 730 | { |
| 731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 731 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 732 | 732 | if (!is_string($owner)) |
| 733 | 733 | { |
| 734 | 734 | return false; |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | |
| 740 | 740 | if ($pilot_name != "") |
| 741 | 741 | { |
| 742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 742 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 743 | 743 | if (!is_string($pilot_name)) |
| 744 | 744 | { |
| 745 | 745 | return false; |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | if ($pilot_id != "") |
| 752 | 752 | { |
| 753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 753 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 754 | 754 | if (!is_string($pilot_id)) |
| 755 | 755 | { |
| 756 | 756 | return false; |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | |
| 762 | 762 | if ($departure_airport_route != "") |
| 763 | 763 | { |
| 764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 764 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 765 | 765 | if (!is_string($departure_airport_route)) |
| 766 | 766 | { |
| 767 | 767 | return false; |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | |
| 773 | 773 | if ($arrival_airport_route != "") |
| 774 | 774 | { |
| 775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 775 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 776 | 776 | if (!is_string($arrival_airport_route)) |
| 777 | 777 | { |
| 778 | 778 | return false; |
@@ -785,8 +785,8 @@ discard block |
||
| 785 | 785 | { |
| 786 | 786 | $altitude_array = explode(",", $altitude); |
| 787 | 787 | |
| 788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 788 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 789 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 790 | 790 | |
| 791 | 791 | |
| 792 | 792 | if ($altitude_array[1] != "") |
@@ -804,8 +804,8 @@ discard block |
||
| 804 | 804 | { |
| 805 | 805 | $date_array = explode(",", $date_posted); |
| 806 | 806 | |
| 807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 807 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 808 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 809 | 809 | |
| 810 | 810 | if ($globalTimezone != '') { |
| 811 | 811 | date_default_timezone_set($globalTimezone); |
@@ -837,8 +837,8 @@ discard block |
||
| 837 | 837 | { |
| 838 | 838 | $limit_array = explode(",", $limit); |
| 839 | 839 | |
| 840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 840 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 841 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 842 | 842 | |
| 843 | 843 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 844 | 844 | { |
@@ -849,8 +849,8 @@ discard block |
||
| 849 | 849 | |
| 850 | 850 | |
| 851 | 851 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 852 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 853 | - $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 |
|
| 852 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 853 | + $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 |
|
| 854 | 854 | 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)) |
| 855 | 855 | 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"; |
| 856 | 856 | } else { |
@@ -867,12 +867,12 @@ discard block |
||
| 867 | 867 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 870 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 871 | 871 | WHERE marine_archive_output.ident <> '' |
| 872 | 872 | ".$additional_query." |
| 873 | 873 | ".$filter_query.$orderby_query; |
| 874 | 874 | } |
| 875 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 875 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 876 | 876 | |
| 877 | 877 | return $spotter_array; |
| 878 | 878 | } |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | try { |
| 890 | 890 | $sth = $this->db->prepare($query); |
| 891 | 891 | $sth->execute(); |
| 892 | - } catch(PDOException $e) { |
|
| 892 | + } catch (PDOException $e) { |
|
| 893 | 893 | return "error"; |
| 894 | 894 | } |
| 895 | 895 | } |
@@ -926,8 +926,8 @@ discard block |
||
| 926 | 926 | { |
| 927 | 927 | $limit_array = explode(",", $limit); |
| 928 | 928 | |
| 929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 929 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 930 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 931 | 931 | |
| 932 | 932 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 933 | 933 | { |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | $query_values = array(); |
| 969 | 969 | $limit_query = ''; |
| 970 | 970 | $additional_query = ''; |
| 971 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 971 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 972 | 972 | |
| 973 | 973 | if ($owner != "") |
| 974 | 974 | { |
@@ -985,8 +985,8 @@ discard block |
||
| 985 | 985 | { |
| 986 | 986 | $limit_array = explode(",", $limit); |
| 987 | 987 | |
| 988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 988 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 990 | 990 | |
| 991 | 991 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 992 | 992 | { |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | $query_values = array(); |
| 1027 | 1027 | $limit_query = ''; |
| 1028 | 1028 | $additional_query = ''; |
| 1029 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1029 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1030 | 1030 | |
| 1031 | 1031 | if ($pilot != "") |
| 1032 | 1032 | { |
@@ -1038,8 +1038,8 @@ discard block |
||
| 1038 | 1038 | { |
| 1039 | 1039 | $limit_array = explode(",", $limit); |
| 1040 | 1040 | |
| 1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1041 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1042 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1043 | 1043 | |
| 1044 | 1044 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1045 | 1045 | { |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | * @return Array the airline country list |
| 1070 | 1070 | * |
| 1071 | 1071 | */ |
| 1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1072 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1073 | 1073 | { |
| 1074 | 1074 | global $globalDBdriver; |
| 1075 | 1075 | /* |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | $flight_array = array(); |
| 1099 | 1099 | $temp_array = array(); |
| 1100 | 1100 | |
| 1101 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1101 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1102 | 1102 | { |
| 1103 | 1103 | $temp_array['flight_count'] = $row['nb']; |
| 1104 | 1104 | $temp_array['flight_country'] = $row['name']; |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | * @return Array the airline country list |
| 1116 | 1116 | * |
| 1117 | 1117 | */ |
| 1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1118 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1119 | 1119 | { |
| 1120 | 1120 | global $globalDBdriver; |
| 1121 | 1121 | /* |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | $flight_array = array(); |
| 1145 | 1145 | $temp_array = array(); |
| 1146 | 1146 | |
| 1147 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1147 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1148 | 1148 | { |
| 1149 | 1149 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1150 | 1150 | $temp_array['flight_count'] = $row['nb']; |
@@ -1162,14 +1162,14 @@ discard block |
||
| 1162 | 1162 | * @return Array the spotter information |
| 1163 | 1163 | * |
| 1164 | 1164 | */ |
| 1165 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1165 | + public function getDateArchiveMarineDataById($id, $date) |
|
| 1166 | 1166 | { |
| 1167 | 1167 | $Marine = new Marine($this->db); |
| 1168 | 1168 | date_default_timezone_set('UTC'); |
| 1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1170 | 1170 | $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'; |
| 1171 | - $date = date('c',$date); |
|
| 1172 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1171 | + $date = date('c', $date); |
|
| 1172 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1173 | 1173 | return $spotter_array; |
| 1174 | 1174 | } |
| 1175 | 1175 | |
@@ -1179,14 +1179,14 @@ discard block |
||
| 1179 | 1179 | * @return Array the spotter information |
| 1180 | 1180 | * |
| 1181 | 1181 | */ |
| 1182 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1182 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
| 1183 | 1183 | { |
| 1184 | 1184 | $Marine = new Marine($this->db); |
| 1185 | 1185 | date_default_timezone_set('UTC'); |
| 1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1187 | 1187 | $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'; |
| 1188 | - $date = date('c',$date); |
|
| 1189 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1188 | + $date = date('c', $date); |
|
| 1189 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1190 | 1190 | return $spotter_array; |
| 1191 | 1191 | } |
| 1192 | 1192 | |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | * @return Array the spotter information |
| 1197 | 1197 | * |
| 1198 | 1198 | */ |
| 1199 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1199 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1200 | 1200 | { |
| 1201 | 1201 | global $global_query; |
| 1202 | 1202 | $Marine = new Marine($this->db); |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | $query_values = array(); |
| 1205 | 1205 | $limit_query = ''; |
| 1206 | 1206 | $additional_query = ''; |
| 1207 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1207 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1208 | 1208 | |
| 1209 | 1209 | if ($airport != "") |
| 1210 | 1210 | { |
@@ -1221,8 +1221,8 @@ discard block |
||
| 1221 | 1221 | { |
| 1222 | 1222 | $limit_array = explode(",", $limit); |
| 1223 | 1223 | |
| 1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1224 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1225 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1226 | 1226 | |
| 1227 | 1227 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1228 | 1228 | { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $Connection = new Connection($this->db); |
| 55 | 55 | $sth = $Connection->db->prepare($query); |
| 56 | 56 | $sth->execute(); |
| 57 | - } catch(PDOException $e) { |
|
| 57 | + } catch (PDOException $e) { |
|
| 58 | 58 | return "error : ".$e->getMessage(); |
| 59 | 59 | } |
| 60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $Connection = new Connection($this->db); |
| 71 | 71 | $sth = $Connection->db->prepare($query); |
| 72 | 72 | $sth->execute(); |
| 73 | - } catch(PDOException $e) { |
|
| 73 | + } catch (PDOException $e) { |
|
| 74 | 74 | return "error : ".$e->getMessage(); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | public function parse($data) { |
| 79 | 79 | //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
| 80 | 80 | $codes = implode('|', array_keys($this->texts)); |
| 81 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
| 81 | + $regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#'; |
|
| 82 | 82 | //$pieces = explode(' ',$data); |
| 83 | - $pieces = preg_split('/\s/',$data); |
|
| 83 | + $pieces = preg_split('/\s/', $data); |
|
| 84 | 84 | $pos = 0; |
| 85 | 85 | if ($pieces[0] == 'METAR') $pos++; |
| 86 | 86 | elseif ($pieces[0] == 'SPECI') $pos++; |
@@ -88,25 +88,25 @@ discard block |
||
| 88 | 88 | $result = array(); |
| 89 | 89 | $result['location'] = $pieces[$pos]; |
| 90 | 90 | $pos++; |
| 91 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
| 92 | - $result['time'] = substr($pieces[$pos],2,4); |
|
| 91 | + $result['dayofmonth'] = substr($pieces[$pos], 0, 2); |
|
| 92 | + $result['time'] = substr($pieces[$pos], 2, 4); |
|
| 93 | 93 | $c = count($pieces); |
| 94 | - for($pos++; $pos < $c; $pos++) { |
|
| 94 | + for ($pos++; $pos < $c; $pos++) { |
|
| 95 | 95 | $piece = $pieces[$pos]; |
| 96 | 96 | if ($piece == 'RMK') break; |
| 97 | 97 | if ($piece == 'AUTO') $result['auto'] = true; |
| 98 | 98 | if ($piece == 'COR') $result['correction'] = true; |
| 99 | 99 | // Wind Speed |
| 100 | 100 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 101 | - $result['wind']['direction'] = (float)$matches[1]; |
|
| 101 | + $result['wind']['direction'] = (float) $matches[1]; |
|
| 102 | 102 | $result['wind']['unit'] = $matches[4]; |
| 103 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 104 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 105 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 106 | - $result['wind']['gust'] = (float)$matches[3]; |
|
| 103 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2); |
|
| 104 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2); |
|
| 105 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2); |
|
| 106 | + $result['wind']['gust'] = (float) $matches[3]; |
|
| 107 | 107 | $result['wind']['unit'] = $matches[4]; |
| 108 | - $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
|
| 109 | - $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
|
| 108 | + $result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0; |
|
| 109 | + $result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | // Temperature |
| 129 | 129 | if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
| 130 | - $temp = (float)$matches[1]; |
|
| 130 | + $temp = (float) $matches[1]; |
|
| 131 | 131 | if ($matches[1]{0} == 'M') { |
| 132 | - $temp = ((float)substr($matches[1], 1)) * -1; |
|
| 132 | + $temp = ((float) substr($matches[1], 1))*-1; |
|
| 133 | 133 | } |
| 134 | 134 | $result['temperature'] = $temp; |
| 135 | - $dew = (float)$matches[2]; |
|
| 135 | + $dew = (float) $matches[2]; |
|
| 136 | 136 | if ($matches[2]{0} == 'M') { |
| 137 | - $dew = ((float)substr($matches[2], 1)) * -1; |
|
| 137 | + $dew = ((float) substr($matches[2], 1))*-1; |
|
| 138 | 138 | } |
| 139 | 139 | $result['dew'] = $dew; |
| 140 | 140 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $result['QNH'] = $matches[2]; |
| 147 | 147 | } else { |
| 148 | 148 | // inHg |
| 149 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
| 149 | + $result['QNH'] = round(($matches[2]/100)*33.86389, 2); |
|
| 150 | 150 | } |
| 151 | 151 | /* |
| 152 | 152 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
@@ -167,12 +167,12 @@ discard block |
||
| 167 | 167 | // Visibility |
| 168 | 168 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
| 169 | 169 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
| 170 | - $result['visibility'] = (float)$matches[3] * 1609.34; |
|
| 170 | + $result['visibility'] = (float) $matches[3]*1609.34; |
|
| 171 | 171 | } else { |
| 172 | 172 | if ($matches[1] == '9999') { |
| 173 | 173 | $result['visibility'] = '> 10000'; |
| 174 | 174 | } else { |
| 175 | - $result['visibility'] = (float)$matches[1]; |
|
| 175 | + $result['visibility'] = (float) $matches[1]; |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | if (preg_match('#^CAVOK$#', $piece, $matches)) { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
| 195 | 195 | elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
| 196 | 196 | $cloud['type_code'] = $type; |
| 197 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
| 197 | + $cloud['level'] = round(((float) $matches[2])*100*0.3048); |
|
| 198 | 198 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
| 199 | 199 | $result['cloud'][] = $cloud; |
| 200 | 200 | } |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | $rvr['runway'] = $matches[1]; |
| 205 | 205 | $rvr['assessment'] = $matches[2]; |
| 206 | 206 | $rvr['rvr'] = $matches[3]; |
| 207 | - $rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0; |
|
| 208 | - $rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : ''; |
|
| 207 | + $rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0; |
|
| 208 | + $rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : ''; |
|
| 209 | 209 | $result['RVR'] = $rvr; |
| 210 | 210 | } |
| 211 | 211 | //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | $result['RVR']['friction'] = $matches[5]; |
| 219 | 219 | } |
| 220 | 220 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 221 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 222 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 221 | + if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 222 | + else $range = array('exact' => (float) $matches[2], 'unit' => 'M'); |
|
| 223 | 223 | if (isset($matches[3])) { |
| 224 | 224 | $range = Array( |
| 225 | - 'from' => (float)$matches[2], |
|
| 226 | - 'to' => (float)$matches[4], |
|
| 225 | + 'from' => (float) $matches[2], |
|
| 226 | + 'to' => (float) $matches[4], |
|
| 227 | 227 | 'unit' => $matches[5] ? 'FT' : 'M' |
| 228 | 228 | ); |
| 229 | 229 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | try { |
| 272 | 272 | $sth = $this->db->prepare($query); |
| 273 | 273 | $sth->execute($query_values); |
| 274 | - } catch(PDOException $e) { |
|
| 274 | + } catch (PDOException $e) { |
|
| 275 | 275 | return "error : ".$e->getMessage(); |
| 276 | 276 | } |
| 277 | 277 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -281,19 +281,19 @@ discard block |
||
| 281 | 281 | return $all; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - public function addMETAR($location,$metar,$date) { |
|
| 284 | + public function addMETAR($location, $metar, $date) { |
|
| 285 | 285 | global $globalDBdriver; |
| 286 | - $date = date('Y-m-d H:i:s',strtotime($date)); |
|
| 286 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 287 | 287 | if ($globalDBdriver == 'mysql') { |
| 288 | 288 | $query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar"; |
| 289 | 289 | } else { |
| 290 | 290 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
| 291 | 291 | } |
| 292 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
| 292 | + $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar)); |
|
| 293 | 293 | try { |
| 294 | 294 | $sth = $this->db->prepare($query); |
| 295 | 295 | $sth->execute($query_values); |
| 296 | - } catch(PDOException $e) { |
|
| 296 | + } catch (PDOException $e) { |
|
| 297 | 297 | return "error : ".$e->getMessage(); |
| 298 | 298 | } |
| 299 | 299 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | try { |
| 305 | 305 | $sth = $this->db->prepare($query); |
| 306 | 306 | $sth->execute($query_values); |
| 307 | - } catch(PDOException $e) { |
|
| 307 | + } catch (PDOException $e) { |
|
| 308 | 308 | return "error : ".$e->getMessage(); |
| 309 | 309 | } |
| 310 | 310 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | try { |
| 315 | 315 | $sth = $this->db->prepare($query); |
| 316 | 316 | $sth->execute(); |
| 317 | - } catch(PDOException $e) { |
|
| 317 | + } catch (PDOException $e) { |
|
| 318 | 318 | return "error : ".$e->getMessage(); |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -325,27 +325,27 @@ discard block |
||
| 325 | 325 | date_default_timezone_set("UTC"); |
| 326 | 326 | $Common = new Common(); |
| 327 | 327 | if (isset($globalIVAO) && $globalIVAO) { |
| 328 | - $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 329 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
| 328 | + $Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
| 329 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r"); |
|
| 330 | 330 | } else { |
| 331 | - $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 332 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
| 331 | + $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
| 332 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r"); |
|
| 333 | 333 | } |
| 334 | 334 | if ($handle) { |
| 335 | 335 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
| 336 | 336 | $date = ''; |
| 337 | 337 | if ($globalTransaction) $this->db->beginTransaction(); |
| 338 | - while(($line = fgets($handle,4096)) !== false) { |
|
| 339 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 338 | + while (($line = fgets($handle, 4096)) !== false) { |
|
| 339 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 340 | 340 | $date = $line; |
| 341 | 341 | } elseif ($line != '') { |
| 342 | 342 | if ($date == '') $date = date('Y/m/d H:m'); |
| 343 | 343 | $pos = 0; |
| 344 | - $pieces = preg_split('/\s/',$line); |
|
| 344 | + $pieces = preg_split('/\s/', $line); |
|
| 345 | 345 | if ($pieces[0] == 'METAR') $pos++; |
| 346 | 346 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 347 | 347 | $location = $pieces[$pos]; |
| 348 | - echo $this->addMETAR($location,$line,$date); |
|
| 348 | + echo $this->addMETAR($location, $line, $date); |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | fclose($handle); |
@@ -359,22 +359,22 @@ discard block |
||
| 359 | 359 | if ($globalMETARurl == '') return array(); |
| 360 | 360 | date_default_timezone_set("UTC"); |
| 361 | 361 | $Common = new Common(); |
| 362 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
| 362 | + $url = str_replace('{icao}', $icao, $globalMETARurl); |
|
| 363 | 363 | $cycle = $Common->getData($url); |
| 364 | 364 | $date = ''; |
| 365 | - foreach(explode("\n",$cycle) as $line) { |
|
| 366 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
| 365 | + foreach (explode("\n", $cycle) as $line) { |
|
| 366 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
| 367 | 367 | $date = $line; |
| 368 | 368 | } |
| 369 | 369 | if ($line != '') { |
| 370 | 370 | if ($date == '') $date = date('Y/m/d H:m'); |
| 371 | 371 | $pos = 0; |
| 372 | - $pieces = preg_split('/\s/',$line); |
|
| 372 | + $pieces = preg_split('/\s/', $line); |
|
| 373 | 373 | if ($pieces[0] == 'METAR') $pos++; |
| 374 | 374 | if (strlen($pieces[$pos]) != 4) $pos++; |
| 375 | 375 | $location = $pieces[$pos]; |
| 376 | 376 | if (strlen($location == 4)) { |
| 377 | - $this->addMETAR($location,$line,$date); |
|
| 377 | + $this->addMETAR($location, $line, $date); |
|
| 378 | 378 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 379 | 379 | } else return array(); |
| 380 | 380 | } |
@@ -14,62 +14,62 @@ 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['airlines']) && !empty($flt['airlines'])) { |
| 35 | 35 | if ($flt['airlines'][0] != '') { |
| 36 | 36 | if (isset($flt['source'])) { |
| 37 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 37 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 38 | 38 | } else { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 51 | 51 | if (isset($flt['source'])) { |
| 52 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 52 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 53 | 53 | } else { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 58 | 58 | if (isset($flt['source'])) { |
| 59 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 59 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 60 | 60 | } else { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 65 | 65 | if (isset($flt['source'])) { |
| 66 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 66 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 71 | 71 | if ($filter['airlines'][0] != '') { |
| 72 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 72 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
| 78 | 78 | } |
| 79 | 79 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 80 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 80 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 83 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 86 | 86 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
| 87 | 87 | } |
| 88 | 88 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 89 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 89 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 90 | 90 | } |
| 91 | 91 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 92 | 92 | $filter_query_date = ''; |
@@ -112,41 +112,41 @@ discard block |
||
| 112 | 112 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 115 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 116 | 116 | } |
| 117 | 117 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 118 | 118 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 119 | 119 | if ($filter_query_where != '') { |
| 120 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 120 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 121 | 121 | } |
| 122 | 122 | $filter_query = $filter_query_join.$filter_query_where; |
| 123 | 123 | return $filter_query; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Spotter_archive |
| 127 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 127 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
| 128 | 128 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 129 | 129 | if ($over_country == '') { |
| 130 | 130 | $Spotter = new Spotter($this->db); |
| 131 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 131 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 132 | 132 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 133 | 133 | else $country = ''; |
| 134 | 134 | } else $country = $over_country; |
| 135 | - if ($airline_type === NULL) $airline_type =''; |
|
| 135 | + if ($airline_type === NULL) $airline_type = ''; |
|
| 136 | 136 | |
| 137 | 137 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 138 | 138 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
| 139 | 139 | |
| 140 | 140 | // Route is not added in spotter_archive |
| 141 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 141 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 142 | 142 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name,:real_altitude)"; |
| 143 | 143 | |
| 144 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name,':real_altitude' => $real_altitude); |
|
| 144 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name, ':real_altitude' => $real_altitude); |
|
| 145 | 145 | try { |
| 146 | 146 | $sth = $this->db->prepare($query); |
| 147 | 147 | $sth->execute($query_values); |
| 148 | 148 | $sth->closeCursor(); |
| 149 | - } catch(PDOException $e) { |
|
| 149 | + } catch (PDOException $e) { |
|
| 150 | 150 | return "error : ".$e->getMessage(); |
| 151 | 151 | } |
| 152 | 152 | return "success"; |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 168 | 168 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 169 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 169 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 170 | 170 | |
| 171 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 171 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
| 172 | 172 | |
| 173 | 173 | return $spotter_array; |
| 174 | 174 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 188 | 188 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
| 189 | 189 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 190 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 190 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 191 | 191 | |
| 192 | 192 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 193 | 193 | /* |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 202 | 202 | */ |
| 203 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 203 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
| 204 | 204 | |
| 205 | 205 | return $spotter_array; |
| 206 | 206 | } |
@@ -215,14 +215,14 @@ discard block |
||
| 215 | 215 | { |
| 216 | 216 | date_default_timezone_set('UTC'); |
| 217 | 217 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 218 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 218 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 219 | 219 | |
| 220 | 220 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 221 | 221 | |
| 222 | 222 | try { |
| 223 | 223 | $sth = $this->db->prepare($query); |
| 224 | 224 | $sth->execute(array(':id' => $id)); |
| 225 | - } catch(PDOException $e) { |
|
| 225 | + } catch (PDOException $e) { |
|
| 226 | 226 | echo $e->getMessage(); |
| 227 | 227 | die; |
| 228 | 228 | } |
@@ -241,14 +241,14 @@ discard block |
||
| 241 | 241 | { |
| 242 | 242 | date_default_timezone_set('UTC'); |
| 243 | 243 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 244 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 244 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
| 245 | 245 | |
| 246 | 246 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 247 | 247 | |
| 248 | 248 | try { |
| 249 | 249 | $sth = $this->db->prepare($query); |
| 250 | 250 | $sth->execute(array(':id' => $id)); |
| 251 | - } catch(PDOException $e) { |
|
| 251 | + } catch (PDOException $e) { |
|
| 252 | 252 | echo $e->getMessage(); |
| 253 | 253 | die; |
| 254 | 254 | } |
@@ -270,12 +270,12 @@ discard block |
||
| 270 | 270 | date_default_timezone_set('UTC'); |
| 271 | 271 | |
| 272 | 272 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 273 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 273 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 274 | 274 | |
| 275 | 275 | try { |
| 276 | 276 | $sth = $this->db->prepare($query); |
| 277 | 277 | $sth->execute(array(':ident' => $ident)); |
| 278 | - } catch(PDOException $e) { |
|
| 278 | + } catch (PDOException $e) { |
|
| 279 | 279 | echo $e->getMessage(); |
| 280 | 280 | die; |
| 281 | 281 | } |
@@ -296,12 +296,12 @@ discard block |
||
| 296 | 296 | date_default_timezone_set('UTC'); |
| 297 | 297 | |
| 298 | 298 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 299 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 299 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 300 | 300 | |
| 301 | 301 | try { |
| 302 | 302 | $sth = $this->db->prepare($query); |
| 303 | 303 | $sth->execute(array(':id' => $id)); |
| 304 | - } catch(PDOException $e) { |
|
| 304 | + } catch (PDOException $e) { |
|
| 305 | 305 | echo $e->getMessage(); |
| 306 | 306 | die; |
| 307 | 307 | } |
@@ -322,12 +322,12 @@ discard block |
||
| 322 | 322 | date_default_timezone_set('UTC'); |
| 323 | 323 | |
| 324 | 324 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 325 | - $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 325 | + $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 326 | 326 | |
| 327 | 327 | try { |
| 328 | 328 | $sth = $this->db->prepare($query); |
| 329 | 329 | $sth->execute(array(':id' => $id)); |
| 330 | - } catch(PDOException $e) { |
|
| 330 | + } catch (PDOException $e) { |
|
| 331 | 331 | echo $e->getMessage(); |
| 332 | 332 | die; |
| 333 | 333 | } |
@@ -349,13 +349,13 @@ discard block |
||
| 349 | 349 | date_default_timezone_set('UTC'); |
| 350 | 350 | |
| 351 | 351 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 352 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 352 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 353 | 353 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 354 | 354 | |
| 355 | 355 | try { |
| 356 | 356 | $sth = $this->db->prepare($query); |
| 357 | 357 | $sth->execute(array(':ident' => $ident)); |
| 358 | - } catch(PDOException $e) { |
|
| 358 | + } catch (PDOException $e) { |
|
| 359 | 359 | echo $e->getMessage(); |
| 360 | 360 | die; |
| 361 | 361 | } |
@@ -372,13 +372,13 @@ discard block |
||
| 372 | 372 | * @return Array the spotter information |
| 373 | 373 | * |
| 374 | 374 | */ |
| 375 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
| 375 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
| 376 | 376 | { |
| 377 | 377 | $Spotter = new Spotter($this->db); |
| 378 | 378 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 379 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 379 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 380 | 380 | |
| 381 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 381 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
| 382 | 382 | |
| 383 | 383 | return $spotter_array; |
| 384 | 384 | } |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | try { |
| 395 | 395 | $sth = $this->db->prepare($query); |
| 396 | 396 | $sth->execute(); |
| 397 | - } catch(PDOException $e) { |
|
| 397 | + } catch (PDOException $e) { |
|
| 398 | 398 | echo $e->getMessage(); |
| 399 | 399 | die; |
| 400 | 400 | } |
@@ -406,24 +406,24 @@ discard block |
||
| 406 | 406 | * @return Array the spotter information |
| 407 | 407 | * |
| 408 | 408 | */ |
| 409 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
| 409 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
| 410 | 410 | { |
| 411 | 411 | global $globalDBdriver, $globalLiveInterval; |
| 412 | 412 | date_default_timezone_set('UTC'); |
| 413 | 413 | |
| 414 | 414 | $filter_query = ''; |
| 415 | 415 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 416 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 416 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 417 | 417 | } |
| 418 | 418 | // Use spotter_output also ? |
| 419 | 419 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 420 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 420 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 421 | 421 | } |
| 422 | 422 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 423 | 423 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 424 | 424 | } |
| 425 | 425 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 426 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 426 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -442,14 +442,14 @@ discard block |
||
| 442 | 442 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
| 443 | 443 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 444 | 444 | */ |
| 445 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 445 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 446 | 446 | FROM spotter_archive |
| 447 | 447 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 448 | 448 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 449 | 449 | '.$filter_query.' ORDER BY flightaware_id'; |
| 450 | 450 | } else { |
| 451 | 451 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
| 452 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 452 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 453 | 453 | FROM spotter_archive |
| 454 | 454 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
| 455 | 455 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | try { |
| 460 | 460 | $sth = $this->db->prepare($query); |
| 461 | 461 | $sth->execute(); |
| 462 | - } catch(PDOException $e) { |
|
| 462 | + } catch (PDOException $e) { |
|
| 463 | 463 | echo $e->getMessage(); |
| 464 | 464 | die; |
| 465 | 465 | } |
@@ -474,24 +474,24 @@ discard block |
||
| 474 | 474 | * @return Array the spotter information |
| 475 | 475 | * |
| 476 | 476 | */ |
| 477 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
| 477 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
| 478 | 478 | { |
| 479 | 479 | global $globalDBdriver, $globalLiveInterval; |
| 480 | 480 | date_default_timezone_set('UTC'); |
| 481 | 481 | |
| 482 | 482 | $filter_query = ''; |
| 483 | 483 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 484 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 484 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 485 | 485 | } |
| 486 | 486 | // Should use spotter_output also ? |
| 487 | 487 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 488 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 488 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 489 | 489 | } |
| 490 | 490 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 491 | 491 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 492 | 492 | } |
| 493 | 493 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 494 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 494 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | FROM spotter_archive |
| 502 | 502 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 503 | 503 | */ |
| 504 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 504 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 505 | 505 | FROM spotter_archive_output |
| 506 | 506 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
| 507 | 507 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 517 | 517 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 518 | 518 | */ |
| 519 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 519 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 520 | 520 | FROM spotter_archive_output |
| 521 | 521 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 522 | 522 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | try { |
| 529 | 529 | $sth = $this->db->prepare($query); |
| 530 | 530 | $sth->execute(); |
| 531 | - } catch(PDOException $e) { |
|
| 531 | + } catch (PDOException $e) { |
|
| 532 | 532 | echo $e->getMessage(); |
| 533 | 533 | die; |
| 534 | 534 | } |
@@ -543,23 +543,23 @@ discard block |
||
| 543 | 543 | * @return Array the spotter information |
| 544 | 544 | * |
| 545 | 545 | */ |
| 546 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
| 546 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
| 547 | 547 | { |
| 548 | 548 | global $globalDBdriver, $globalLiveInterval; |
| 549 | 549 | date_default_timezone_set('UTC'); |
| 550 | 550 | |
| 551 | 551 | $filter_query = ''; |
| 552 | 552 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 554 | 554 | } |
| 555 | 555 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 556 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 556 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 557 | 557 | } |
| 558 | 558 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 559 | 559 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 560 | 560 | } |
| 561 | 561 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | try { |
| 575 | 575 | $sth = $this->db->prepare($query); |
| 576 | 576 | $sth->execute(); |
| 577 | - } catch(PDOException $e) { |
|
| 577 | + } catch (PDOException $e) { |
|
| 578 | 578 | echo $e->getMessage(); |
| 579 | 579 | die; |
| 580 | 580 | } |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | * @return Array the spotter information |
| 595 | 595 | * |
| 596 | 596 | */ |
| 597 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 597 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 598 | 598 | { |
| 599 | 599 | global $globalTimezone, $globalDBdriver; |
| 600 | 600 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | $q_array = explode(" ", $q); |
| 618 | 618 | |
| 619 | - foreach ($q_array as $q_item){ |
|
| 619 | + foreach ($q_array as $q_item) { |
|
| 620 | 620 | $additional_query .= " AND ("; |
| 621 | 621 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 622 | 622 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | if ($registration != "") |
| 650 | 650 | { |
| 651 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 651 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 652 | 652 | if (!is_string($registration)) |
| 653 | 653 | { |
| 654 | 654 | return false; |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | |
| 660 | 660 | if ($aircraft_icao != "") |
| 661 | 661 | { |
| 662 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 662 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 663 | 663 | if (!is_string($aircraft_icao)) |
| 664 | 664 | { |
| 665 | 665 | return false; |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | if ($aircraft_manufacturer != "") |
| 672 | 672 | { |
| 673 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 673 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 674 | 674 | if (!is_string($aircraft_manufacturer)) |
| 675 | 675 | { |
| 676 | 676 | return false; |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | if ($airline_icao != "") |
| 693 | 693 | { |
| 694 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 694 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 695 | 695 | if (!is_string($airline_icao)) |
| 696 | 696 | { |
| 697 | 697 | return false; |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | |
| 703 | 703 | if ($airline_country != "") |
| 704 | 704 | { |
| 705 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 705 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 706 | 706 | if (!is_string($airline_country)) |
| 707 | 707 | { |
| 708 | 708 | return false; |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | |
| 714 | 714 | if ($airline_type != "") |
| 715 | 715 | { |
| 716 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 716 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 717 | 717 | if (!is_string($airline_type)) |
| 718 | 718 | { |
| 719 | 719 | return false; |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | if ($airport != "") |
| 737 | 737 | { |
| 738 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 738 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 739 | 739 | if (!is_string($airport)) |
| 740 | 740 | { |
| 741 | 741 | return false; |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | if ($airport_country != "") |
| 748 | 748 | { |
| 749 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 749 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 750 | 750 | if (!is_string($airport_country)) |
| 751 | 751 | { |
| 752 | 752 | return false; |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | if ($callsign != "") |
| 759 | 759 | { |
| 760 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 760 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 761 | 761 | if (!is_string($callsign)) |
| 762 | 762 | { |
| 763 | 763 | return false; |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | $translate = $Translation->ident2icao($callsign); |
| 766 | 766 | if ($translate != $callsign) { |
| 767 | 767 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
| 768 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 768 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 769 | 769 | } else { |
| 770 | 770 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 771 | 771 | } |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | |
| 775 | 775 | if ($owner != "") |
| 776 | 776 | { |
| 777 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 777 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 778 | 778 | if (!is_string($owner)) |
| 779 | 779 | { |
| 780 | 780 | return false; |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | if ($pilot_name != "") |
| 787 | 787 | { |
| 788 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 788 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 789 | 789 | if (!is_string($pilot_name)) |
| 790 | 790 | { |
| 791 | 791 | return false; |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | if ($pilot_id != "") |
| 798 | 798 | { |
| 799 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 799 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 800 | 800 | if (!is_string($pilot_id)) |
| 801 | 801 | { |
| 802 | 802 | return false; |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | if ($departure_airport_route != "") |
| 809 | 809 | { |
| 810 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 810 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 811 | 811 | if (!is_string($departure_airport_route)) |
| 812 | 812 | { |
| 813 | 813 | return false; |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | if ($arrival_airport_route != "") |
| 820 | 820 | { |
| 821 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 821 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 822 | 822 | if (!is_string($arrival_airport_route)) |
| 823 | 823 | { |
| 824 | 824 | return false; |
@@ -831,8 +831,8 @@ discard block |
||
| 831 | 831 | { |
| 832 | 832 | $altitude_array = explode(",", $altitude); |
| 833 | 833 | |
| 834 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 835 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 834 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 835 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 836 | 836 | |
| 837 | 837 | |
| 838 | 838 | if ($altitude_array[1] != "") |
@@ -850,8 +850,8 @@ discard block |
||
| 850 | 850 | { |
| 851 | 851 | $date_array = explode(",", $date_posted); |
| 852 | 852 | |
| 853 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 854 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 853 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 854 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 855 | 855 | |
| 856 | 856 | if ($globalTimezone != '') { |
| 857 | 857 | date_default_timezone_set($globalTimezone); |
@@ -883,8 +883,8 @@ discard block |
||
| 883 | 883 | { |
| 884 | 884 | $limit_array = explode(",", $limit); |
| 885 | 885 | |
| 886 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 887 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 886 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 887 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 888 | 888 | |
| 889 | 889 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 890 | 890 | { |
@@ -895,8 +895,8 @@ discard block |
||
| 895 | 895 | |
| 896 | 896 | |
| 897 | 897 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 898 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 899 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 898 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 899 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 900 | 900 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 901 | 901 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 902 | 902 | } else { |
@@ -913,12 +913,12 @@ discard block |
||
| 913 | 913 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 916 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 917 | 917 | WHERE spotter_archive_output.ident <> '' |
| 918 | 918 | ".$additional_query." |
| 919 | 919 | ".$filter_query.$orderby_query; |
| 920 | 920 | } |
| 921 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
| 921 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
| 922 | 922 | |
| 923 | 923 | return $spotter_array; |
| 924 | 924 | } |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | try { |
| 936 | 936 | $sth = $this->db->prepare($query); |
| 937 | 937 | $sth->execute(); |
| 938 | - } catch(PDOException $e) { |
|
| 938 | + } catch (PDOException $e) { |
|
| 939 | 939 | return "error"; |
| 940 | 940 | } |
| 941 | 941 | } |
@@ -972,8 +972,8 @@ discard block |
||
| 972 | 972 | { |
| 973 | 973 | $limit_array = explode(",", $limit); |
| 974 | 974 | |
| 975 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 976 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 975 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 976 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 977 | 977 | |
| 978 | 978 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 979 | 979 | { |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | $query_values = array(); |
| 1015 | 1015 | $limit_query = ''; |
| 1016 | 1016 | $additional_query = ''; |
| 1017 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1017 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1018 | 1018 | |
| 1019 | 1019 | if ($owner != "") |
| 1020 | 1020 | { |
@@ -1031,8 +1031,8 @@ discard block |
||
| 1031 | 1031 | { |
| 1032 | 1032 | $limit_array = explode(",", $limit); |
| 1033 | 1033 | |
| 1034 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1034 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1036 | 1036 | |
| 1037 | 1037 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1038 | 1038 | { |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | $query_values = array(); |
| 1073 | 1073 | $limit_query = ''; |
| 1074 | 1074 | $additional_query = ''; |
| 1075 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1075 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1076 | 1076 | |
| 1077 | 1077 | if ($pilot != "") |
| 1078 | 1078 | { |
@@ -1084,8 +1084,8 @@ discard block |
||
| 1084 | 1084 | { |
| 1085 | 1085 | $limit_array = explode(",", $limit); |
| 1086 | 1086 | |
| 1087 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1088 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1087 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1088 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1089 | 1089 | |
| 1090 | 1090 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1091 | 1091 | { |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | * @return Array the airline country list |
| 1116 | 1116 | * |
| 1117 | 1117 | */ |
| 1118 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1118 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1119 | 1119 | { |
| 1120 | 1120 | global $globalDBdriver; |
| 1121 | 1121 | /* |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | $flight_array = array(); |
| 1145 | 1145 | $temp_array = array(); |
| 1146 | 1146 | |
| 1147 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1147 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1148 | 1148 | { |
| 1149 | 1149 | $temp_array['flight_count'] = $row['nb']; |
| 1150 | 1150 | $temp_array['flight_country'] = $row['name']; |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | * @return Array the airline country list |
| 1162 | 1162 | * |
| 1163 | 1163 | */ |
| 1164 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1164 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1165 | 1165 | { |
| 1166 | 1166 | global $globalDBdriver; |
| 1167 | 1167 | /* |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | $flight_array = array(); |
| 1191 | 1191 | $temp_array = array(); |
| 1192 | 1192 | |
| 1193 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1193 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1194 | 1194 | { |
| 1195 | 1195 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1196 | 1196 | $temp_array['flight_count'] = $row['nb']; |
@@ -1208,14 +1208,14 @@ discard block |
||
| 1208 | 1208 | * @return Array the spotter information |
| 1209 | 1209 | * |
| 1210 | 1210 | */ |
| 1211 | - public function getDateArchiveSpotterDataById($id,$date) |
|
| 1211 | + public function getDateArchiveSpotterDataById($id, $date) |
|
| 1212 | 1212 | { |
| 1213 | 1213 | $Spotter = new Spotter($this->db); |
| 1214 | 1214 | date_default_timezone_set('UTC'); |
| 1215 | 1215 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1216 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1217 | - $date = date('c',$date); |
|
| 1218 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1216 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1217 | + $date = date('c', $date); |
|
| 1218 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1219 | 1219 | return $spotter_array; |
| 1220 | 1220 | } |
| 1221 | 1221 | |
@@ -1225,14 +1225,14 @@ discard block |
||
| 1225 | 1225 | * @return Array the spotter information |
| 1226 | 1226 | * |
| 1227 | 1227 | */ |
| 1228 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
| 1228 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
| 1229 | 1229 | { |
| 1230 | 1230 | $Spotter = new Spotter($this->db); |
| 1231 | 1231 | date_default_timezone_set('UTC'); |
| 1232 | 1232 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1233 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1234 | - $date = date('c',$date); |
|
| 1235 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1233 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1234 | + $date = date('c', $date); |
|
| 1235 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1236 | 1236 | return $spotter_array; |
| 1237 | 1237 | } |
| 1238 | 1238 | |
@@ -1242,7 +1242,7 @@ discard block |
||
| 1242 | 1242 | * @return Array the spotter information |
| 1243 | 1243 | * |
| 1244 | 1244 | */ |
| 1245 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1245 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1246 | 1246 | { |
| 1247 | 1247 | global $global_query; |
| 1248 | 1248 | $Spotter = new Spotter($this->db); |
@@ -1250,7 +1250,7 @@ discard block |
||
| 1250 | 1250 | $query_values = array(); |
| 1251 | 1251 | $limit_query = ''; |
| 1252 | 1252 | $additional_query = ''; |
| 1253 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1253 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1254 | 1254 | |
| 1255 | 1255 | if ($airport != "") |
| 1256 | 1256 | { |
@@ -1267,8 +1267,8 @@ discard block |
||
| 1267 | 1267 | { |
| 1268 | 1268 | $limit_array = explode(",", $limit); |
| 1269 | 1269 | |
| 1270 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1271 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1270 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1271 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1272 | 1272 | |
| 1273 | 1273 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1274 | 1274 | { |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | try { |
| 983 | 983 | $sth = $this->db->prepare($query); |
| 984 | 984 | $sth->execute($query_values); |
| 985 | - } catch(PDOException $e) { |
|
| 985 | + } catch (PDOException $e) { |
|
| 986 | 986 | echo "error : ".$e->getMessage(); |
| 987 | 987 | } |
| 988 | 988 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1000,19 +1000,19 @@ discard block |
||
| 1000 | 1000 | try { |
| 1001 | 1001 | $sth = $this->db->prepare($query); |
| 1002 | 1002 | $sth->execute($query_values); |
| 1003 | - } catch(PDOException $e) { |
|
| 1003 | + } catch (PDOException $e) { |
|
| 1004 | 1004 | echo "error : ".$e->getMessage(); |
| 1005 | 1005 | } |
| 1006 | 1006 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1007 | 1007 | return $all; |
| 1008 | 1008 | } |
| 1009 | 1009 | public function getAllNOTAMtext() { |
| 1010 | - $query = 'SELECT full_notam FROM notam'; |
|
| 1010 | + $query = 'SELECT full_notam FROM notam'; |
|
| 1011 | 1011 | $query_values = array(); |
| 1012 | 1012 | try { |
| 1013 | 1013 | $sth = $this->db->prepare($query); |
| 1014 | 1014 | $sth->execute($query_values); |
| 1015 | - } catch(PDOException $e) { |
|
| 1015 | + } catch (PDOException $e) { |
|
| 1016 | 1016 | echo "error : ".$e->getMessage(); |
| 1017 | 1017 | } |
| 1018 | 1018 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1021,13 +1021,13 @@ discard block |
||
| 1021 | 1021 | public function createNOTAMtextFile($filename) { |
| 1022 | 1022 | $allnotam_result = $this->getAllNOTAMtext(); |
| 1023 | 1023 | $notamtext = ''; |
| 1024 | - foreach($allnotam_result as $notam) { |
|
| 1024 | + foreach ($allnotam_result as $notam) { |
|
| 1025 | 1025 | $notamtext .= '%%'."\n"; |
| 1026 | 1026 | $notamtext .= $notam['full_notam']; |
| 1027 | 1027 | $notamtext .= "\n".'%%'."\n"; |
| 1028 | 1028 | } |
| 1029 | 1029 | //$allnotam = implode('\n%%%%\n',$allnotam_result); |
| 1030 | - file_put_contents($filename,$notamtext); |
|
| 1030 | + file_put_contents($filename, $notamtext); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | public function parseNOTAMtextFile($filename) { |
| 1033 | 1033 | $data = file_get_contents($filename); |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | try { |
| 1049 | 1049 | $sth = $this->db->prepare($query); |
| 1050 | 1050 | $sth->execute($query_values); |
| 1051 | - } catch(PDOException $e) { |
|
| 1051 | + } catch (PDOException $e) { |
|
| 1052 | 1052 | echo "error : ".$e->getMessage(); |
| 1053 | 1053 | } |
| 1054 | 1054 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1057,10 +1057,10 @@ discard block |
||
| 1057 | 1057 | public function getAllNOTAMbyCoord($coord) { |
| 1058 | 1058 | global $globalDBdriver; |
| 1059 | 1059 | if (is_array($coord)) { |
| 1060 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1061 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1062 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1060 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1061 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1062 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1064 | 1064 | if ($minlat > $maxlat) { |
| 1065 | 1065 | $tmplat = $minlat; |
| 1066 | 1066 | $minlat = $maxlat; |
@@ -1082,19 +1082,19 @@ discard block |
||
| 1082 | 1082 | try { |
| 1083 | 1083 | $sth = $this->db->prepare($query); |
| 1084 | 1084 | $sth->execute($query_values); |
| 1085 | - } catch(PDOException $e) { |
|
| 1085 | + } catch (PDOException $e) { |
|
| 1086 | 1086 | echo "error : ".$e->getMessage(); |
| 1087 | 1087 | } |
| 1088 | 1088 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1089 | 1089 | return $all; |
| 1090 | 1090 | } |
| 1091 | - public function getAllNOTAMbyCoordScope($coord,$scope) { |
|
| 1091 | + public function getAllNOTAMbyCoordScope($coord, $scope) { |
|
| 1092 | 1092 | global $globalDBdriver; |
| 1093 | 1093 | if (is_array($coord)) { |
| 1094 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1095 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1096 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1097 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1094 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1095 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1096 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1097 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1098 | 1098 | } else return array(); |
| 1099 | 1099 | if ($globalDBdriver == 'mysql') { |
| 1100 | 1100 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | try { |
| 1107 | 1107 | $sth = $this->db->prepare($query); |
| 1108 | 1108 | $sth->execute($query_values); |
| 1109 | - } catch(PDOException $e) { |
|
| 1109 | + } catch (PDOException $e) { |
|
| 1110 | 1110 | echo "error : ".$e->getMessage(); |
| 1111 | 1111 | } |
| 1112 | 1112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | try { |
| 1119 | 1119 | $sth = $this->db->prepare($query); |
| 1120 | 1120 | $sth->execute($query_values); |
| 1121 | - } catch(PDOException $e) { |
|
| 1121 | + } catch (PDOException $e) { |
|
| 1122 | 1122 | return "error : ".$e->getMessage(); |
| 1123 | 1123 | } |
| 1124 | 1124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1126,13 +1126,13 @@ discard block |
||
| 1126 | 1126 | else return array(); |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
|
| 1129 | + public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) { |
|
| 1130 | 1130 | $query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)"; |
| 1131 | - $query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam); |
|
| 1131 | + $query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam); |
|
| 1132 | 1132 | try { |
| 1133 | 1133 | $sth = $this->db->prepare($query); |
| 1134 | 1134 | $sth->execute($query_values); |
| 1135 | - } catch(PDOException $e) { |
|
| 1135 | + } catch (PDOException $e) { |
|
| 1136 | 1136 | return "error : ".$e->getMessage(); |
| 1137 | 1137 | } |
| 1138 | 1138 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | try { |
| 1144 | 1144 | $sth = $this->db->prepare($query); |
| 1145 | 1145 | $sth->execute($query_values); |
| 1146 | - } catch(PDOException $e) { |
|
| 1146 | + } catch (PDOException $e) { |
|
| 1147 | 1147 | return "error : ".$e->getMessage(); |
| 1148 | 1148 | } |
| 1149 | 1149 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | try { |
| 1159 | 1159 | $sth = $this->db->prepare($query); |
| 1160 | 1160 | $sth->execute($query_values); |
| 1161 | - } catch(PDOException $e) { |
|
| 1161 | + } catch (PDOException $e) { |
|
| 1162 | 1162 | return "error : ".$e->getMessage(); |
| 1163 | 1163 | } |
| 1164 | 1164 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | try { |
| 1169 | 1169 | $sth = $this->db->prepare($query); |
| 1170 | 1170 | $sth->execute($query_values); |
| 1171 | - } catch(PDOException $e) { |
|
| 1171 | + } catch (PDOException $e) { |
|
| 1172 | 1172 | return "error : ".$e->getMessage(); |
| 1173 | 1173 | } |
| 1174 | 1174 | } |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | try { |
| 1178 | 1178 | $sth = $this->db->prepare($query); |
| 1179 | 1179 | $sth->execute(); |
| 1180 | - } catch(PDOException $e) { |
|
| 1180 | + } catch (PDOException $e) { |
|
| 1181 | 1181 | return "error : ".$e->getMessage(); |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | try { |
| 1187 | 1187 | $sth = $this->db->prepare($query); |
| 1188 | 1188 | $sth->execute(); |
| 1189 | - } catch(PDOException $e) { |
|
| 1189 | + } catch (PDOException $e) { |
|
| 1190 | 1190 | return "error : ".$e->getMessage(); |
| 1191 | 1191 | } |
| 1192 | 1192 | } |
@@ -1194,14 +1194,14 @@ discard block |
||
| 1194 | 1194 | public function updateNOTAM() { |
| 1195 | 1195 | global $globalNOTAMAirports; |
| 1196 | 1196 | if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) { |
| 1197 | - foreach (array_chunk($globalNOTAMAirports,10) as $airport) { |
|
| 1198 | - $airport_icao = implode(',',$airport); |
|
| 1197 | + foreach (array_chunk($globalNOTAMAirports, 10) as $airport) { |
|
| 1198 | + $airport_icao = implode(',', $airport); |
|
| 1199 | 1199 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1200 | 1200 | if (count($alldata) > 0) { |
| 1201 | 1201 | foreach ($alldata as $initial_data) { |
| 1202 | 1202 | $data = $this->parse($initial_data); |
| 1203 | 1203 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1204 | + if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 1205 | 1205 | } |
| 1206 | 1206 | } |
| 1207 | 1207 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
| 1214 | 1214 | foreach ($alldata as $initial_data) { |
| 1215 | 1215 | $data = $this->parse($initial_data); |
| 1216 | 1216 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1217 | + if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 1218 | 1218 | } |
| 1219 | 1219 | } |
| 1220 | 1220 | } |
@@ -1223,12 +1223,12 @@ discard block |
||
| 1223 | 1223 | global $globalTransaction; |
| 1224 | 1224 | $Spotter = new Spotter($this->db); |
| 1225 | 1225 | $allairports = $Spotter->getAllAirportInfo(); |
| 1226 | - foreach (array_chunk($allairports,20) as $airport) { |
|
| 1226 | + foreach (array_chunk($allairports, 20) as $airport) { |
|
| 1227 | 1227 | $airports_icao = array(); |
| 1228 | - foreach($airport as $icao) { |
|
| 1228 | + foreach ($airport as $icao) { |
|
| 1229 | 1229 | if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
| 1230 | 1230 | } |
| 1231 | - $airport_icao = implode(',',$airports_icao); |
|
| 1231 | + $airport_icao = implode(',', $airports_icao); |
|
| 1232 | 1232 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1233 | 1233 | if ($globalTransaction) $this->db->beginTransaction(); |
| 1234 | 1234 | if (count($alldata) > 0) { |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | if (count($notamref) == 0) { |
| 1242 | 1242 | if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
| 1243 | 1243 | if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
| 1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1244 | + elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | } |
| 1247 | 1247 | } |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | date_default_timezone_set("UTC"); |
| 1256 | 1256 | $Common = new Common(); |
| 1257 | 1257 | //$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
| 1258 | - $url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
| 1258 | + $url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
| 1259 | 1259 | $data = $Common->getData($url); |
| 1260 | 1260 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
| 1261 | 1261 | //print_r($matches); |
@@ -1272,9 +1272,9 @@ discard block |
||
| 1272 | 1272 | $result['permanent'] = ''; |
| 1273 | 1273 | $result['date_begin'] = NULL; |
| 1274 | 1274 | $result['date_end'] = NULL; |
| 1275 | - $data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data); |
|
| 1275 | + $data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data); |
|
| 1276 | 1276 | //echo $data."\n"; |
| 1277 | - $data = preg_split('#\s(?=([A-Z]\)\s))#',$data); |
|
| 1277 | + $data = preg_split('#\s(?=([A-Z]\)\s))#', $data); |
|
| 1278 | 1278 | //print_r($data); |
| 1279 | 1279 | $q = false; |
| 1280 | 1280 | $a = false; |
@@ -1283,9 +1283,9 @@ discard block |
||
| 1283 | 1283 | $e = false; |
| 1284 | 1284 | foreach ($data as $line) { |
| 1285 | 1285 | $line = trim($line); |
| 1286 | - if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) { |
|
| 1287 | - $line = str_replace(' ','',$line); |
|
| 1288 | - if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) { |
|
| 1286 | + if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) { |
|
| 1287 | + $line = str_replace(' ', '', $line); |
|
| 1288 | + if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) { |
|
| 1289 | 1289 | //if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) { |
| 1290 | 1290 | //print_r($matches); |
| 1291 | 1291 | $result['fir'] = $matches[1]; |
@@ -1331,9 +1331,9 @@ discard block |
||
| 1331 | 1331 | elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
| 1332 | 1332 | $result['lower_limit'] = $matches[6]; |
| 1333 | 1333 | $result['upper_limit'] = $matches[7]; |
| 1334 | - $latitude = $Common->convertDec($matches[8],'latitude'); |
|
| 1334 | + $latitude = $Common->convertDec($matches[8], 'latitude'); |
|
| 1335 | 1335 | if ($matches[9] == 'S') $latitude = -$latitude; |
| 1336 | - $longitude = $Common->convertDec($matches[10],'longitude'); |
|
| 1336 | + $longitude = $Common->convertDec($matches[10], 'longitude'); |
|
| 1337 | 1337 | if ($matches[11] == 'W') $longitude = -$longitude; |
| 1338 | 1338 | $result['latitude'] = $latitude; |
| 1339 | 1339 | $result['longitude'] = $longitude; |
@@ -1345,24 +1345,24 @@ discard block |
||
| 1345 | 1345 | echo "Can't parse : ".$line."\n"; |
| 1346 | 1346 | } |
| 1347 | 1347 | } |
| 1348 | - elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
| 1348 | + elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) { |
|
| 1349 | 1349 | $result['icao'] = $matches[2]; |
| 1350 | 1350 | $a = true; |
| 1351 | 1351 | } |
| 1352 | - elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
| 1352 | + elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches) && $b === false) { |
|
| 1353 | 1353 | if ($matches[1] > 50) $year = '19'.$matches[2]; |
| 1354 | 1354 | else $year = '20'.$matches[2]; |
| 1355 | 1355 | $result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1356 | 1356 | $b = true; |
| 1357 | 1357 | } |
| 1358 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
| 1358 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches) && $c === false) { |
|
| 1359 | 1359 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
| 1360 | 1360 | else $year = '20'.$matches[2]; |
| 1361 | 1361 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1362 | 1362 | $result['permanent'] = 0; |
| 1363 | 1363 | $c = true; |
| 1364 | 1364 | } |
| 1365 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1365 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
| 1366 | 1366 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
| 1367 | 1367 | else $year = '20'.$matches[2]; |
| 1368 | 1368 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
@@ -1372,7 +1372,7 @@ discard block |
||
| 1372 | 1372 | else $result['permanent'] = 0; |
| 1373 | 1373 | $c = true; |
| 1374 | 1374 | } |
| 1375 | - elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1375 | + elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
| 1376 | 1376 | $result['date_end'] = '2030/12/20 12:00'; |
| 1377 | 1377 | if ($matches[2] == 'EST') $result['estimated'] = 1; |
| 1378 | 1378 | else $result['estimated'] = 0; |
@@ -1380,20 +1380,20 @@ discard block |
||
| 1380 | 1380 | else $result['permanent'] = 0; |
| 1381 | 1381 | $c = true; |
| 1382 | 1382 | } |
| 1383 | - elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
| 1383 | + elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) { |
|
| 1384 | 1384 | $rtext = array(); |
| 1385 | - $text = explode(' ',$matches[2]); |
|
| 1385 | + $text = explode(' ', $matches[2]); |
|
| 1386 | 1386 | foreach ($text as $word) { |
| 1387 | 1387 | if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
| 1388 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1388 | + elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3); |
|
| 1389 | 1389 | else $rtext[] = $word; |
| 1390 | 1390 | } |
| 1391 | - $result['text'] = implode(' ',$rtext); |
|
| 1391 | + $result['text'] = implode(' ', $rtext); |
|
| 1392 | 1392 | $e = true; |
| 1393 | 1393 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
| 1394 | 1394 | //} elseif (preg_match('#G\) (.*)#',$line,$matches)) { |
| 1395 | - } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
|
| 1396 | - $text = explode(' ',$line); |
|
| 1395 | + } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) { |
|
| 1396 | + $text = explode(' ', $line); |
|
| 1397 | 1397 | $result['ref'] = $text[0]; |
| 1398 | 1398 | if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
| 1399 | 1399 | if ($matches[1] == 'NOTAMC') { |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | * @param String $date get data for a date |
| 29 | 29 | * @return Array Return Accidents data in array |
| 30 | 30 | */ |
| 31 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
| 31 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
| 32 | 32 | global $globalURL, $globalDBdriver; |
| 33 | 33 | $Image = new Image($this->db); |
| 34 | 34 | $Spotter = new Spotter($this->db); |
| 35 | 35 | $Translation = new Translation($this->db); |
| 36 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 36 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 37 | 37 | date_default_timezone_set('UTC'); |
| 38 | 38 | $result = array(); |
| 39 | 39 | $limit_query = ''; |
| 40 | 40 | if ($limit != "") |
| 41 | 41 | { |
| 42 | 42 | $limit_array = explode(",", $limit); |
| 43 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 44 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 43 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 44 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 45 | 45 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 46 | 46 | { |
| 47 | 47 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -50,29 +50,29 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | if ($type != '') { |
| 52 | 52 | if ($date != '') { |
| 53 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 53 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 54 | 54 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 55 | 55 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 56 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 57 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
| 56 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 57 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
| 58 | 58 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 59 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 60 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
| 59 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 60 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
| 61 | 61 | if ($globalDBdriver == 'mysql') { |
| 62 | 62 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 63 | 63 | } else { |
| 64 | 64 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 65 | 65 | } |
| 66 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 66 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 67 | 67 | } else { |
| 68 | 68 | $date = $date.'%'; |
| 69 | 69 | if ($globalDBdriver == 'mysql') { |
| 70 | 70 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 71 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 71 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 72 | 72 | } else { |
| 73 | 73 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 74 | 74 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 75 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 75 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | } else { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | } else { |
| 84 | 84 | if ($date != '') { |
| 85 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 85 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 86 | 86 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 87 | 87 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 88 | 88 | } else { |
@@ -100,17 +100,17 @@ discard block |
||
| 100 | 100 | try { |
| 101 | 101 | $sth = $this->db->prepare($query); |
| 102 | 102 | $sth->execute($query_values); |
| 103 | - } catch(PDOException $e) { |
|
| 103 | + } catch (PDOException $e) { |
|
| 104 | 104 | echo "error : ".$e->getMessage(); |
| 105 | 105 | } |
| 106 | 106 | $i = 0; |
| 107 | 107 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 108 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
| 108 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
| 109 | 109 | $data = array(); |
| 110 | 110 | if ($row['registration'] != '') { |
| 111 | 111 | $image_array = $Image->getSpotterImage($row['registration']); |
| 112 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 113 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 112 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 113 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 114 | 114 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 115 | 115 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 116 | 116 | if (!empty($aircraft_info)) { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
| 119 | 119 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
| 120 | 120 | } else { |
| 121 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
| 121 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
| 122 | 122 | } |
| 123 | 123 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
| 124 | 124 | if (!empty($owner_data)) { |
@@ -126,18 +126,18 @@ discard block |
||
| 126 | 126 | $data['aircraft_base'] = $owner_data['base']; |
| 127 | 127 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 128 | 128 | } |
| 129 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 129 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 130 | 130 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 131 | 131 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 132 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
| 132 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
| 133 | 133 | if (isset($identicao[0])) { |
| 134 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 135 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 136 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 137 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 138 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 134 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 135 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 136 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 137 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 138 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 139 | 139 | } else $icao = $row['ident']; |
| 140 | - $icao = $Translation->checkTranslation($icao,false); |
|
| 140 | + $icao = $Translation->checkTranslation($icao, false); |
|
| 141 | 141 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 142 | 142 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
| 143 | 143 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -146,16 +146,16 @@ discard block |
||
| 146 | 146 | if (!empty($airline_info)) { |
| 147 | 147 | //echo 'data found !'."\n"; |
| 148 | 148 | //print_r($airline_info); |
| 149 | - $data = array_merge($data,$airline_info); |
|
| 149 | + $data = array_merge($data, $airline_info); |
|
| 150 | 150 | } |
| 151 | 151 | //else echo 'No data...'."\n"; |
| 152 | 152 | } |
| 153 | - $data = array_merge($row,$data); |
|
| 153 | + $data = array_merge($row, $data); |
|
| 154 | 154 | if ($data['ident'] == null) $data['ident'] = $icao; |
| 155 | 155 | if ($data['title'] == null) { |
| 156 | 156 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 157 | 157 | } else $data['message'] = strtolower($data['title']); |
| 158 | - $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
|
| 158 | + $ids = $Spotter->getAllIDByRegistration($data['registration'], true); |
|
| 159 | 159 | $date = $data['date']; |
| 160 | 160 | if (isset($ids[$date])) { |
| 161 | 161 | $data['spotted'] = TRUE; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | try { |
| 188 | 188 | $sth = $this->db->prepare($query); |
| 189 | 189 | $sth->execute(); |
| 190 | - } catch(PDOException $e) { |
|
| 190 | + } catch (PDOException $e) { |
|
| 191 | 191 | echo "Error : ".$e->getMessage(); |
| 192 | 192 | } |
| 193 | 193 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | try { |
| 208 | 208 | $sth = $this->db->prepare($query); |
| 209 | 209 | $sth->execute(); |
| 210 | - } catch(PDOException $e) { |
|
| 210 | + } catch (PDOException $e) { |
|
| 211 | 211 | echo "Error : ".$e->getMessage(); |
| 212 | 212 | } |
| 213 | 213 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -222,15 +222,15 @@ discard block |
||
| 222 | 222 | if ($globalDebug) echo 'Import '.$file."\n"; |
| 223 | 223 | $result = array(); |
| 224 | 224 | if (file_exists($file)) { |
| 225 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
| 226 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
| 225 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
| 226 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
| 227 | 227 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
| 228 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
| 228 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | fclose($handle); |
| 232 | 232 | } |
| 233 | - if (!empty($result)) $this->add($result,true); |
|
| 233 | + if (!empty($result)) $this->add($result, true); |
|
| 234 | 234 | elseif ($globalDebug) echo 'Nothing to import'; |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | $all_md5_new = array(); |
| 247 | 247 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 248 | 248 | if ($this->check_accidents_nb() > 0) { |
| 249 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 250 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 249 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 250 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 251 | 251 | if (isset($data[1])) { |
| 252 | 252 | $year = $data[0]; |
| 253 | 253 | $all_md5[$year] = $data[1]; |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 260 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 261 | 261 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 262 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 263 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 262 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 263 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 264 | 264 | if (isset($data[1])) { |
| 265 | 265 | $year = $data[0]; |
| 266 | 266 | $all_md5_new[$year] = $data[1]; |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | fclose($handle); |
| 270 | 270 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
| 271 | 271 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
| 272 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
| 272 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
| 273 | 273 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
| 274 | 274 | foreach ($result as $file => $md5) { |
| 275 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 275 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 276 | 276 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
| 277 | 277 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
| 278 | 278 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * Add data to DB |
| 283 | 283 | * @param Array $crash An array with accidents/incidents data |
| 284 | 284 | */ |
| 285 | - public function add($crash,$new = false) { |
|
| 285 | + public function add($crash, $new = false) { |
|
| 286 | 286 | global $globalTransaction, $globalDebug; |
| 287 | 287 | require_once('class.Connection.php'); |
| 288 | 288 | require_once('class.Image.php'); |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 299 | 299 | } |
| 300 | 300 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 301 | - $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
|
| 301 | + $initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); |
|
| 302 | 302 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 303 | 303 | $sth_check = $Connection->db->prepare($query_check); |
| 304 | 304 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -311,15 +311,15 @@ discard block |
||
| 311 | 311 | $cr = array_map(function($value) { |
| 312 | 312 | return $value === "" ? NULL : $value; |
| 313 | 313 | }, $cr); |
| 314 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
| 315 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 316 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
| 314 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
| 315 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 316 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
| 317 | 317 | $sth_check->execute($query_check_values); |
| 318 | 318 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
| 319 | 319 | if ($result_check['nb'] == 0) { |
| 320 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
| 320 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
| 321 | 321 | $sth->execute($query_values); |
| 322 | - if ($cr['date'] > time()-(30*86400)) { |
|
| 322 | + if ($cr['date'] > time() - (30*86400)) { |
|
| 323 | 323 | if (empty($Image->getSpotterImage($cr['registration']))) { |
| 324 | 324 | if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
| 325 | 325 | $Image->addSpotterImage($cr['registration']); |
@@ -328,16 +328,16 @@ discard block |
||
| 328 | 328 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 329 | 329 | } |
| 330 | 330 | if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
| 331 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
| 331 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | - if ($globalTransaction && $j % 1000 == 0) { |
|
| 334 | + if ($globalTransaction && $j%1000 == 0) { |
|
| 335 | 335 | $Connection->db->commit(); |
| 336 | 336 | $Connection->db->beginTransaction(); |
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | if ($globalTransaction) $Connection->db->commit(); |
| 340 | - } catch(PDOException $e) { |
|
| 340 | + } catch (PDOException $e) { |
|
| 341 | 341 | if ($globalTransaction) $Connection->db->rollBack(); |
| 342 | 342 | echo $e->getMessage(); |
| 343 | 343 | } |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $Connection = new Connection($this->db); |
| 356 | 356 | $sth = $Connection->db->prepare($query); |
| 357 | 357 | $sth->execute(); |
| 358 | - } catch(PDOException $e) { |
|
| 358 | + } catch (PDOException $e) { |
|
| 359 | 359 | return "error : ".$e->getMessage(); |
| 360 | 360 | } |
| 361 | 361 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | $Connection = new Connection($this->db); |
| 374 | 374 | $sth = $Connection->db->prepare($query); |
| 375 | 375 | $sth->execute(); |
| 376 | - } catch(PDOException $e) { |
|
| 376 | + } catch (PDOException $e) { |
|
| 377 | 377 | return "error : ".$e->getMessage(); |
| 378 | 378 | } |
| 379 | 379 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | $Connection = new Connection($this->db); |
| 389 | 389 | $sth = $Connection->db->prepare($query); |
| 390 | 390 | $sth->execute(); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | return "error : ".$e->getMessage(); |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -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 famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 36 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 37 | 37 | } else { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 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,38 +68,38 @@ discard block |
||
| 68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'"; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
| 71 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
| 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 | // tracker_archive |
| 86 | - public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
| 86 | + public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
| 87 | 87 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
| 88 | 88 | if ($over_country == '') { |
| 89 | 89 | $Tracker = new Tracker($this->db); |
| 90 | - $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 90 | + $data_country = $Tracker->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 | // Route is not added in tracker_archive |
| 95 | - $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 95 | + $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 96 | 96 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 97 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
| 97 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
| 98 | 98 | try { |
| 99 | 99 | $sth = $this->db->prepare($query); |
| 100 | 100 | $sth->execute($query_values); |
| 101 | 101 | $sth->closeCursor(); |
| 102 | - } catch(PDOException $e) { |
|
| 102 | + } catch (PDOException $e) { |
|
| 103 | 103 | return "error : ".$e->getMessage(); |
| 104 | 104 | } |
| 105 | 105 | return "success"; |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 121 | 121 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
| 122 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 122 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 123 | 123 | |
| 124 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 124 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident)); |
|
| 125 | 125 | |
| 126 | 126 | return $spotter_array; |
| 127 | 127 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 141 | 141 | //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
| 142 | 142 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
| 143 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 143 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 144 | 144 | |
| 145 | 145 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 146 | 146 | /* |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 155 | 155 | */ |
| 156 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 156 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id)); |
|
| 157 | 157 | |
| 158 | 158 | return $spotter_array; |
| 159 | 159 | } |
@@ -168,14 +168,14 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | date_default_timezone_set('UTC'); |
| 170 | 170 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 171 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 171 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 172 | 172 | |
| 173 | 173 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 174 | 174 | |
| 175 | 175 | try { |
| 176 | 176 | $sth = $this->db->prepare($query); |
| 177 | 177 | $sth->execute(array(':id' => $id)); |
| 178 | - } catch(PDOException $e) { |
|
| 178 | + } catch (PDOException $e) { |
|
| 179 | 179 | echo $e->getMessage(); |
| 180 | 180 | die; |
| 181 | 181 | } |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | { |
| 195 | 195 | date_default_timezone_set('UTC'); |
| 196 | 196 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 197 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 197 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 198 | 198 | |
| 199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 200 | 200 | |
| 201 | 201 | try { |
| 202 | 202 | $sth = $this->db->prepare($query); |
| 203 | 203 | $sth->execute(array(':id' => $id)); |
| 204 | - } catch(PDOException $e) { |
|
| 204 | + } catch (PDOException $e) { |
|
| 205 | 205 | echo $e->getMessage(); |
| 206 | 206 | die; |
| 207 | 207 | } |
@@ -223,12 +223,12 @@ discard block |
||
| 223 | 223 | date_default_timezone_set('UTC'); |
| 224 | 224 | |
| 225 | 225 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 226 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 226 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 227 | 227 | |
| 228 | 228 | try { |
| 229 | 229 | $sth = $this->db->prepare($query); |
| 230 | 230 | $sth->execute(array(':ident' => $ident)); |
| 231 | - } catch(PDOException $e) { |
|
| 231 | + } catch (PDOException $e) { |
|
| 232 | 232 | echo $e->getMessage(); |
| 233 | 233 | die; |
| 234 | 234 | } |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | date_default_timezone_set('UTC'); |
| 250 | 250 | |
| 251 | 251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 253 | 253 | |
| 254 | 254 | try { |
| 255 | 255 | $sth = $this->db->prepare($query); |
| 256 | 256 | $sth->execute(array(':id' => $id)); |
| 257 | - } catch(PDOException $e) { |
|
| 257 | + } catch (PDOException $e) { |
|
| 258 | 258 | echo $e->getMessage(); |
| 259 | 259 | die; |
| 260 | 260 | } |
@@ -275,12 +275,12 @@ discard block |
||
| 275 | 275 | date_default_timezone_set('UTC'); |
| 276 | 276 | |
| 277 | 277 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 279 | 279 | |
| 280 | 280 | try { |
| 281 | 281 | $sth = $this->db->prepare($query); |
| 282 | 282 | $sth->execute(array(':id' => $id)); |
| 283 | - } catch(PDOException $e) { |
|
| 283 | + } catch (PDOException $e) { |
|
| 284 | 284 | echo $e->getMessage(); |
| 285 | 285 | die; |
| 286 | 286 | } |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | date_default_timezone_set('UTC'); |
| 303 | 303 | |
| 304 | 304 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 305 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 305 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 306 | 306 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
| 307 | 307 | |
| 308 | 308 | try { |
| 309 | 309 | $sth = $this->db->prepare($query); |
| 310 | 310 | $sth->execute(array(':ident' => $ident)); |
| 311 | - } catch(PDOException $e) { |
|
| 311 | + } catch (PDOException $e) { |
|
| 312 | 312 | echo $e->getMessage(); |
| 313 | 313 | die; |
| 314 | 314 | } |
@@ -325,13 +325,13 @@ discard block |
||
| 325 | 325 | * @return Array the spotter information |
| 326 | 326 | * |
| 327 | 327 | */ |
| 328 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 328 | + public function getTrackerArchiveData($ident, $famtrackid, $date) |
|
| 329 | 329 | { |
| 330 | 330 | $Tracker = new Tracker($this->db); |
| 331 | 331 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 332 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 332 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 333 | 333 | |
| 334 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 334 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%')); |
|
| 335 | 335 | |
| 336 | 336 | return $spotter_array; |
| 337 | 337 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | try { |
| 345 | 345 | $sth = $this->db->prepare($query); |
| 346 | 346 | $sth->execute(); |
| 347 | - } catch(PDOException $e) { |
|
| 347 | + } catch (PDOException $e) { |
|
| 348 | 348 | echo $e->getMessage(); |
| 349 | 349 | die; |
| 350 | 350 | } |
@@ -356,24 +356,24 @@ discard block |
||
| 356 | 356 | * @return Array the spotter information |
| 357 | 357 | * |
| 358 | 358 | */ |
| 359 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 359 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
| 360 | 360 | { |
| 361 | 361 | global $globalDBdriver, $globalLiveInterval; |
| 362 | 362 | date_default_timezone_set('UTC'); |
| 363 | 363 | |
| 364 | 364 | $filter_query = ''; |
| 365 | 365 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 366 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 366 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 367 | 367 | } |
| 368 | 368 | // Use spotter_output also ? |
| 369 | 369 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 370 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 370 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 371 | 371 | } |
| 372 | 372 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 373 | 373 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 374 | 374 | } |
| 375 | 375 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 376 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 376 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -392,14 +392,14 @@ discard block |
||
| 392 | 392 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
| 393 | 393 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 394 | 394 | */ |
| 395 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 395 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 396 | 396 | FROM tracker_archive |
| 397 | 397 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 398 | 398 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 399 | 399 | '.$filter_query.' ORDER BY famtrackid'; |
| 400 | 400 | } else { |
| 401 | 401 | //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
| 402 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 402 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 403 | 403 | FROM tracker_archive |
| 404 | 404 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 405 | 405 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | try { |
| 410 | 410 | $sth = $this->db->prepare($query); |
| 411 | 411 | $sth->execute(); |
| 412 | - } catch(PDOException $e) { |
|
| 412 | + } catch (PDOException $e) { |
|
| 413 | 413 | echo $e->getMessage(); |
| 414 | 414 | die; |
| 415 | 415 | } |
@@ -424,24 +424,24 @@ discard block |
||
| 424 | 424 | * @return Array the spotter information |
| 425 | 425 | * |
| 426 | 426 | */ |
| 427 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 427 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
| 428 | 428 | { |
| 429 | 429 | global $globalDBdriver, $globalLiveInterval; |
| 430 | 430 | date_default_timezone_set('UTC'); |
| 431 | 431 | |
| 432 | 432 | $filter_query = ''; |
| 433 | 433 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 434 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 434 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 435 | 435 | } |
| 436 | 436 | // Should use spotter_output also ? |
| 437 | 437 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 438 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 438 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 439 | 439 | } |
| 440 | 440 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 441 | 441 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 442 | 442 | } |
| 443 | 443 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 444 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 444 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | FROM tracker_archive |
| 452 | 452 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 453 | 453 | */ |
| 454 | - $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 454 | + $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 455 | 455 | FROM tracker_archive_output |
| 456 | 456 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
| 457 | 457 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 467 | 467 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 468 | 468 | */ |
| 469 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 469 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 470 | 470 | FROM tracker_archive_output |
| 471 | 471 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 472 | 472 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | try { |
| 479 | 479 | $sth = $this->db->prepare($query); |
| 480 | 480 | $sth->execute(); |
| 481 | - } catch(PDOException $e) { |
|
| 481 | + } catch (PDOException $e) { |
|
| 482 | 482 | echo $e->getMessage(); |
| 483 | 483 | die; |
| 484 | 484 | } |
@@ -493,23 +493,23 @@ discard block |
||
| 493 | 493 | * @return Array the spotter information |
| 494 | 494 | * |
| 495 | 495 | */ |
| 496 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 496 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
| 497 | 497 | { |
| 498 | 498 | global $globalDBdriver, $globalLiveInterval; |
| 499 | 499 | date_default_timezone_set('UTC'); |
| 500 | 500 | |
| 501 | 501 | $filter_query = ''; |
| 502 | 502 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 503 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 503 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 504 | 504 | } |
| 505 | 505 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 506 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 506 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 507 | 507 | } |
| 508 | 508 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 509 | 509 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 510 | 510 | } |
| 511 | 511 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 512 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 512 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | try { |
| 525 | 525 | $sth = $this->db->prepare($query); |
| 526 | 526 | $sth->execute(); |
| 527 | - } catch(PDOException $e) { |
|
| 527 | + } catch (PDOException $e) { |
|
| 528 | 528 | echo $e->getMessage(); |
| 529 | 529 | die; |
| 530 | 530 | } |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | * @return Array the spotter information |
| 545 | 545 | * |
| 546 | 546 | */ |
| 547 | - public function searchTrackerData($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()) |
|
| 547 | + public function searchTrackerData($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()) |
|
| 548 | 548 | { |
| 549 | 549 | global $globalTimezone, $globalDBdriver; |
| 550 | 550 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | |
| 567 | 567 | $q_array = explode(" ", $q); |
| 568 | 568 | |
| 569 | - foreach ($q_array as $q_item){ |
|
| 569 | + foreach ($q_array as $q_item) { |
|
| 570 | 570 | $additional_query .= " AND ("; |
| 571 | 571 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 572 | 572 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | if ($registration != "") |
| 600 | 600 | { |
| 601 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 601 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 602 | 602 | if (!is_string($registration)) |
| 603 | 603 | { |
| 604 | 604 | return false; |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | |
| 610 | 610 | if ($aircraft_icao != "") |
| 611 | 611 | { |
| 612 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 612 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 613 | 613 | if (!is_string($aircraft_icao)) |
| 614 | 614 | { |
| 615 | 615 | return false; |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | |
| 621 | 621 | if ($aircraft_manufacturer != "") |
| 622 | 622 | { |
| 623 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 623 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 624 | 624 | if (!is_string($aircraft_manufacturer)) |
| 625 | 625 | { |
| 626 | 626 | return false; |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | if ($airline_icao != "") |
| 643 | 643 | { |
| 644 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 644 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 645 | 645 | if (!is_string($airline_icao)) |
| 646 | 646 | { |
| 647 | 647 | return false; |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | if ($airline_country != "") |
| 654 | 654 | { |
| 655 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 655 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 656 | 656 | if (!is_string($airline_country)) |
| 657 | 657 | { |
| 658 | 658 | return false; |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | |
| 664 | 664 | if ($airline_type != "") |
| 665 | 665 | { |
| 666 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 666 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 667 | 667 | if (!is_string($airline_type)) |
| 668 | 668 | { |
| 669 | 669 | return false; |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | |
| 686 | 686 | if ($airport != "") |
| 687 | 687 | { |
| 688 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 688 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 689 | 689 | if (!is_string($airport)) |
| 690 | 690 | { |
| 691 | 691 | return false; |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | if ($airport_country != "") |
| 698 | 698 | { |
| 699 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 699 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 700 | 700 | if (!is_string($airport_country)) |
| 701 | 701 | { |
| 702 | 702 | return false; |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | |
| 708 | 708 | if ($callsign != "") |
| 709 | 709 | { |
| 710 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 710 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 711 | 711 | if (!is_string($callsign)) |
| 712 | 712 | { |
| 713 | 713 | return false; |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | $translate = $Translation->ident2icao($callsign); |
| 716 | 716 | if ($translate != $callsign) { |
| 717 | 717 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
| 718 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 718 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 719 | 719 | } else { |
| 720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
| 721 | 721 | } |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | if ($owner != "") |
| 726 | 726 | { |
| 727 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 727 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 728 | 728 | if (!is_string($owner)) |
| 729 | 729 | { |
| 730 | 730 | return false; |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | if ($pilot_name != "") |
| 737 | 737 | { |
| 738 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 738 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 739 | 739 | if (!is_string($pilot_name)) |
| 740 | 740 | { |
| 741 | 741 | return false; |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | if ($pilot_id != "") |
| 748 | 748 | { |
| 749 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 749 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 750 | 750 | if (!is_string($pilot_id)) |
| 751 | 751 | { |
| 752 | 752 | return false; |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | if ($departure_airport_route != "") |
| 759 | 759 | { |
| 760 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 760 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 761 | 761 | if (!is_string($departure_airport_route)) |
| 762 | 762 | { |
| 763 | 763 | return false; |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | if ($arrival_airport_route != "") |
| 770 | 770 | { |
| 771 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 771 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 772 | 772 | if (!is_string($arrival_airport_route)) |
| 773 | 773 | { |
| 774 | 774 | return false; |
@@ -781,8 +781,8 @@ discard block |
||
| 781 | 781 | { |
| 782 | 782 | $altitude_array = explode(",", $altitude); |
| 783 | 783 | |
| 784 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 785 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 784 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 785 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 786 | 786 | |
| 787 | 787 | |
| 788 | 788 | if ($altitude_array[1] != "") |
@@ -800,8 +800,8 @@ discard block |
||
| 800 | 800 | { |
| 801 | 801 | $date_array = explode(",", $date_posted); |
| 802 | 802 | |
| 803 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 804 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 803 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 804 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 805 | 805 | |
| 806 | 806 | if ($globalTimezone != '') { |
| 807 | 807 | date_default_timezone_set($globalTimezone); |
@@ -833,8 +833,8 @@ discard block |
||
| 833 | 833 | { |
| 834 | 834 | $limit_array = explode(",", $limit); |
| 835 | 835 | |
| 836 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 837 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 836 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 837 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 838 | 838 | |
| 839 | 839 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 840 | 840 | { |
@@ -845,8 +845,8 @@ discard block |
||
| 845 | 845 | |
| 846 | 846 | |
| 847 | 847 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 848 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 849 | - $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 848 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 849 | + $query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 850 | 850 | FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 851 | 851 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 852 | 852 | } else { |
@@ -863,12 +863,12 @@ discard block |
||
| 863 | 863 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 866 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 867 | 867 | WHERE tracker_archive_output.ident <> '' |
| 868 | 868 | ".$additional_query." |
| 869 | 869 | ".$filter_query.$orderby_query; |
| 870 | 870 | } |
| 871 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
| 871 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 872 | 872 | |
| 873 | 873 | return $spotter_array; |
| 874 | 874 | } |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | try { |
| 886 | 886 | $sth = $this->db->prepare($query); |
| 887 | 887 | $sth->execute(); |
| 888 | - } catch(PDOException $e) { |
|
| 888 | + } catch (PDOException $e) { |
|
| 889 | 889 | return "error"; |
| 890 | 890 | } |
| 891 | 891 | } |
@@ -922,8 +922,8 @@ discard block |
||
| 922 | 922 | { |
| 923 | 923 | $limit_array = explode(",", $limit); |
| 924 | 924 | |
| 925 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 926 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 925 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 926 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 927 | 927 | |
| 928 | 928 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 929 | 929 | { |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | $query_values = array(); |
| 965 | 965 | $limit_query = ''; |
| 966 | 966 | $additional_query = ''; |
| 967 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 967 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 968 | 968 | |
| 969 | 969 | if ($owner != "") |
| 970 | 970 | { |
@@ -981,8 +981,8 @@ discard block |
||
| 981 | 981 | { |
| 982 | 982 | $limit_array = explode(",", $limit); |
| 983 | 983 | |
| 984 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 985 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 984 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 985 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 986 | 986 | |
| 987 | 987 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 988 | 988 | { |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | $query_values = array(); |
| 1023 | 1023 | $limit_query = ''; |
| 1024 | 1024 | $additional_query = ''; |
| 1025 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1025 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1026 | 1026 | |
| 1027 | 1027 | if ($pilot != "") |
| 1028 | 1028 | { |
@@ -1034,8 +1034,8 @@ discard block |
||
| 1034 | 1034 | { |
| 1035 | 1035 | $limit_array = explode(",", $limit); |
| 1036 | 1036 | |
| 1037 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1038 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1037 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1038 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1039 | 1039 | |
| 1040 | 1040 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1041 | 1041 | { |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | * @return Array the airline country list |
| 1066 | 1066 | * |
| 1067 | 1067 | */ |
| 1068 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1068 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1069 | 1069 | { |
| 1070 | 1070 | global $globalDBdriver; |
| 1071 | 1071 | /* |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | $flight_array = array(); |
| 1095 | 1095 | $temp_array = array(); |
| 1096 | 1096 | |
| 1097 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1097 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1098 | 1098 | { |
| 1099 | 1099 | $temp_array['flight_count'] = $row['nb']; |
| 1100 | 1100 | $temp_array['flight_country'] = $row['name']; |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | * @return Array the airline country list |
| 1112 | 1112 | * |
| 1113 | 1113 | */ |
| 1114 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1114 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1115 | 1115 | { |
| 1116 | 1116 | global $globalDBdriver; |
| 1117 | 1117 | /* |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | $flight_array = array(); |
| 1141 | 1141 | $temp_array = array(); |
| 1142 | 1142 | |
| 1143 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1143 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1144 | 1144 | { |
| 1145 | 1145 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1146 | 1146 | $temp_array['flight_count'] = $row['nb']; |
@@ -1158,14 +1158,14 @@ discard block |
||
| 1158 | 1158 | * @return Array the spotter information |
| 1159 | 1159 | * |
| 1160 | 1160 | */ |
| 1161 | - public function getDateArchiveTrackerDataById($id,$date) |
|
| 1161 | + public function getDateArchiveTrackerDataById($id, $date) |
|
| 1162 | 1162 | { |
| 1163 | 1163 | $Tracker = new Tracker($this->db); |
| 1164 | 1164 | date_default_timezone_set('UTC'); |
| 1165 | 1165 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1166 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1167 | - $date = date('c',$date); |
|
| 1168 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1166 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1167 | + $date = date('c', $date); |
|
| 1168 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1169 | 1169 | return $spotter_array; |
| 1170 | 1170 | } |
| 1171 | 1171 | |
@@ -1175,14 +1175,14 @@ discard block |
||
| 1175 | 1175 | * @return Array the spotter information |
| 1176 | 1176 | * |
| 1177 | 1177 | */ |
| 1178 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1178 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
| 1179 | 1179 | { |
| 1180 | 1180 | $Tracker = new Tracker($this->db); |
| 1181 | 1181 | date_default_timezone_set('UTC'); |
| 1182 | 1182 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1183 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1184 | - $date = date('c',$date); |
|
| 1185 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1183 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1184 | + $date = date('c', $date); |
|
| 1185 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1186 | 1186 | return $spotter_array; |
| 1187 | 1187 | } |
| 1188 | 1188 | |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | * @return Array the spotter information |
| 1193 | 1193 | * |
| 1194 | 1194 | */ |
| 1195 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1195 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1196 | 1196 | { |
| 1197 | 1197 | global $global_query; |
| 1198 | 1198 | $Tracker = new Tracker($this->db); |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | $query_values = array(); |
| 1201 | 1201 | $limit_query = ''; |
| 1202 | 1202 | $additional_query = ''; |
| 1203 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1203 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1204 | 1204 | |
| 1205 | 1205 | if ($airport != "") |
| 1206 | 1206 | { |
@@ -1217,8 +1217,8 @@ discard block |
||
| 1217 | 1217 | { |
| 1218 | 1218 | $limit_array = explode(",", $limit); |
| 1219 | 1219 | |
| 1220 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1221 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1220 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1221 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1222 | 1222 | |
| 1223 | 1223 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1224 | 1224 | { |
@@ -19,14 +19,14 @@ discard block |
||
| 19 | 19 | if ($this->db === null) die('Error: No DB connection.'); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function addLastStatsUpdate($type,$stats_date) { |
|
| 22 | + public function addLastStatsUpdate($type, $stats_date) { |
|
| 23 | 23 | $query = "DELETE FROM config WHERE name = :type; |
| 24 | 24 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
| 25 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
| 25 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
| 26 | 26 | try { |
| 27 | 27 | $sth = $this->db->prepare($query); |
| 28 | 28 | $sth->execute($query_values); |
| 29 | - } catch(PDOException $e) { |
|
| 29 | + } catch (PDOException $e) { |
|
| 30 | 30 | return "error : ".$e->getMessage(); |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | try { |
| 37 | 37 | $sth = $this->db->prepare($query); |
| 38 | 38 | $sth->execute(array(':type' => $type)); |
| 39 | - } catch(PDOException $e) { |
|
| 39 | + } catch (PDOException $e) { |
|
| 40 | 40 | echo "error : ".$e->getMessage(); |
| 41 | 41 | } |
| 42 | 42 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | try { |
| 58 | 58 | $sth = $this->db->prepare($query); |
| 59 | 59 | $sth->execute(array(':filter_name' => $filter_name)); |
| 60 | - } catch(PDOException $e) { |
|
| 60 | + } catch (PDOException $e) { |
|
| 61 | 61 | return "error : ".$e->getMessage(); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | try { |
| 71 | 71 | $sth = $this->db->prepare($query); |
| 72 | 72 | $sth->execute(); |
| 73 | - } catch(PDOException $e) { |
|
| 73 | + } catch (PDOException $e) { |
|
| 74 | 74 | return "error : ".$e->getMessage(); |
| 75 | 75 | } |
| 76 | 76 | $query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;"; |
| 77 | 77 | try { |
| 78 | 78 | $sth = $this->db->prepare($query); |
| 79 | 79 | $sth->execute(array(':filter_name' => $filter_name)); |
| 80 | - } catch(PDOException $e) { |
|
| 80 | + } catch (PDOException $e) { |
|
| 81 | 81 | return "error : ".$e->getMessage(); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -89,77 +89,77 @@ discard block |
||
| 89 | 89 | try { |
| 90 | 90 | $sth = $this->db->prepare($query); |
| 91 | 91 | $sth->execute(array(':filter_name' => $filter_name)); |
| 92 | - } catch(PDOException $e) { |
|
| 92 | + } catch (PDOException $e) { |
|
| 93 | 93 | echo "error : ".$e->getMessage(); |
| 94 | 94 | } |
| 95 | 95 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 96 | 96 | if (empty($all)) { |
| 97 | 97 | $filters = array(); |
| 98 | 98 | if ($filter_name != '') { |
| 99 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 99 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 100 | 100 | } |
| 101 | 101 | $Spotter = new Spotter($this->db); |
| 102 | - $all = $Spotter->getAllAirlineNames('',NULL,$filters); |
|
| 102 | + $all = $Spotter->getAllAirlineNames('', NULL, $filters); |
|
| 103 | 103 | } |
| 104 | 104 | return $all; |
| 105 | 105 | } |
| 106 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
| 106 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
| 107 | 107 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 108 | 108 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 109 | 109 | try { |
| 110 | 110 | $sth = $this->db->prepare($query); |
| 111 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 112 | - } catch(PDOException $e) { |
|
| 111 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 112 | + } catch (PDOException $e) { |
|
| 113 | 113 | echo "error : ".$e->getMessage(); |
| 114 | 114 | } |
| 115 | 115 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 116 | 116 | return $all; |
| 117 | 117 | } |
| 118 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
| 118 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
| 119 | 119 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 120 | 120 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
| 121 | 121 | try { |
| 122 | 122 | $sth = $this->db->prepare($query); |
| 123 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 124 | - } catch(PDOException $e) { |
|
| 123 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 124 | + } catch (PDOException $e) { |
|
| 125 | 125 | echo "error : ".$e->getMessage(); |
| 126 | 126 | } |
| 127 | 127 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 128 | 128 | return $all; |
| 129 | 129 | } |
| 130 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
| 130 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
| 131 | 131 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 132 | 132 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
| 133 | 133 | try { |
| 134 | 134 | $sth = $this->db->prepare($query); |
| 135 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 136 | - } catch(PDOException $e) { |
|
| 135 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 136 | + } catch (PDOException $e) { |
|
| 137 | 137 | echo "error : ".$e->getMessage(); |
| 138 | 138 | } |
| 139 | 139 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 140 | 140 | return $all; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
|
| 143 | + public function getAllOwnerNames($stats_airline = '', $filter_name = '') { |
|
| 144 | 144 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 145 | 145 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 146 | 146 | try { |
| 147 | 147 | $sth = $this->db->prepare($query); |
| 148 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 149 | - } catch(PDOException $e) { |
|
| 148 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 149 | + } catch (PDOException $e) { |
|
| 150 | 150 | echo "error : ".$e->getMessage(); |
| 151 | 151 | } |
| 152 | 152 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 153 | 153 | return $all; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
|
| 156 | + public function getAllPilotNames($stats_airline = '', $filter_name = '') { |
|
| 157 | 157 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 158 | 158 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 159 | 159 | try { |
| 160 | 160 | $sth = $this->db->prepare($query); |
| 161 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 162 | - } catch(PDOException $e) { |
|
| 161 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 162 | + } catch (PDOException $e) { |
|
| 163 | 163 | echo "error : ".$e->getMessage(); |
| 164 | 164 | } |
| 165 | 165 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -167,23 +167,23 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | |
| 170 | - public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 170 | + public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 171 | 171 | global $globalStatsFilters; |
| 172 | 172 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 173 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 173 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 174 | 174 | $Spotter = new Spotter($this->db); |
| 175 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 175 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 176 | 176 | $alliance_airlines = array(); |
| 177 | 177 | foreach ($airlines as $airline) { |
| 178 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 178 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 179 | 179 | } |
| 180 | 180 | if ($year == '' && $month == '') { |
| 181 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 182 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 181 | + if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 182 | + else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 183 | 183 | try { |
| 184 | 184 | $sth = $this->db->prepare($query); |
| 185 | 185 | $sth->execute(array(':filter_name' => $filter_name)); |
| 186 | - } catch(PDOException $e) { |
|
| 186 | + } catch (PDOException $e) { |
|
| 187 | 187 | echo "error : ".$e->getMessage(); |
| 188 | 188 | } |
| 189 | 189 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -194,29 +194,29 @@ discard block |
||
| 194 | 194 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
| 195 | 195 | try { |
| 196 | 196 | $sth = $this->db->prepare($query); |
| 197 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 198 | - } catch(PDOException $e) { |
|
| 197 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 198 | + } catch (PDOException $e) { |
|
| 199 | 199 | echo "error : ".$e->getMessage(); |
| 200 | 200 | } |
| 201 | 201 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 202 | 202 | } else $all = array(); |
| 203 | 203 | } |
| 204 | 204 | if (empty($all)) { |
| 205 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 206 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 205 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 206 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 207 | 207 | } else { |
| 208 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 208 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 209 | 209 | } |
| 210 | 210 | if ($filter_name != '') { |
| 211 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 211 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 212 | 212 | } |
| 213 | 213 | $Spotter = new Spotter($this->db); |
| 214 | 214 | //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
| 215 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
| 215 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
| 216 | 216 | } |
| 217 | 217 | return $all; |
| 218 | 218 | } |
| 219 | - public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 219 | + public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 220 | 220 | global $globalStatsFilters; |
| 221 | 221 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 222 | 222 | if ($year == '' && $month == '') { |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | try { |
| 226 | 226 | $sth = $this->db->prepare($query); |
| 227 | 227 | $sth->execute(array(':filter_name' => $filter_name)); |
| 228 | - } catch(PDOException $e) { |
|
| 228 | + } catch (PDOException $e) { |
|
| 229 | 229 | echo "error : ".$e->getMessage(); |
| 230 | 230 | } |
| 231 | 231 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -233,32 +233,32 @@ discard block |
||
| 233 | 233 | if (empty($all)) { |
| 234 | 234 | $Spotter = new Spotter($this->db); |
| 235 | 235 | $filters = array(); |
| 236 | - $filters = array('year' => $year,'month' => $month); |
|
| 236 | + $filters = array('year' => $year, 'month' => $month); |
|
| 237 | 237 | if ($filter_name != '') { |
| 238 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 238 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 239 | 239 | } |
| 240 | 240 | //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
| 241 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
| 241 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
| 242 | 242 | } |
| 243 | 243 | return $all; |
| 244 | 244 | } |
| 245 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 245 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 246 | 246 | global $globalStatsFilters; |
| 247 | 247 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 248 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 248 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 249 | 249 | $Spotter = new Spotter($this->db); |
| 250 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 250 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 251 | 251 | $alliance_airlines = array(); |
| 252 | 252 | foreach ($airlines as $airline) { |
| 253 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 253 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 254 | 254 | } |
| 255 | 255 | if ($year == '' && $month == '') { |
| 256 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 257 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 256 | + if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 257 | + else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 258 | 258 | try { |
| 259 | 259 | $sth = $this->db->prepare($query); |
| 260 | 260 | $sth->execute(array(':filter_name' => $filter_name)); |
| 261 | - } catch(PDOException $e) { |
|
| 261 | + } catch (PDOException $e) { |
|
| 262 | 262 | echo "error : ".$e->getMessage(); |
| 263 | 263 | } |
| 264 | 264 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -269,21 +269,21 @@ discard block |
||
| 269 | 269 | else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
| 270 | 270 | try { |
| 271 | 271 | $sth = $this->db->prepare($query); |
| 272 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 273 | - } catch(PDOException $e) { |
|
| 272 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 273 | + } catch (PDOException $e) { |
|
| 274 | 274 | echo "error : ".$e->getMessage(); |
| 275 | 275 | } |
| 276 | 276 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 277 | 277 | } else $all = array(); |
| 278 | 278 | } |
| 279 | 279 | if (empty($all)) { |
| 280 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 281 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 280 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 281 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 282 | 282 | } else { |
| 283 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 283 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 284 | 284 | } |
| 285 | 285 | if ($filter_name != '') { |
| 286 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 286 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 287 | 287 | } |
| 288 | 288 | $Spotter = new Spotter($this->db); |
| 289 | 289 | //$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month); |
@@ -292,23 +292,23 @@ discard block |
||
| 292 | 292 | return $all; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
| 295 | + public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 296 | 296 | global $globalStatsFilters; |
| 297 | 297 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 298 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 298 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 299 | 299 | $Spotter = new Spotter($this->db); |
| 300 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 300 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 301 | 301 | $alliance_airlines = array(); |
| 302 | 302 | foreach ($airlines as $airline) { |
| 303 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 303 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 304 | 304 | } |
| 305 | 305 | if ($year == '' && $month == '') { |
| 306 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 307 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 306 | + if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 307 | + else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 308 | 308 | try { |
| 309 | 309 | $sth = $this->db->prepare($query); |
| 310 | 310 | $sth->execute(array(':filter_name' => $filter_name)); |
| 311 | - } catch(PDOException $e) { |
|
| 311 | + } catch (PDOException $e) { |
|
| 312 | 312 | echo "error : ".$e->getMessage(); |
| 313 | 313 | } |
| 314 | 314 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -319,61 +319,61 @@ discard block |
||
| 319 | 319 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
| 320 | 320 | try { |
| 321 | 321 | $sth = $this->db->prepare($query); |
| 322 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 323 | - } catch(PDOException $e) { |
|
| 322 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 323 | + } catch (PDOException $e) { |
|
| 324 | 324 | echo "error : ".$e->getMessage(); |
| 325 | 325 | } |
| 326 | 326 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 327 | 327 | } else $all = array(); |
| 328 | 328 | } |
| 329 | 329 | if (empty($all)) { |
| 330 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 331 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 330 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 331 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 332 | 332 | } else { |
| 333 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 333 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 334 | 334 | } |
| 335 | 335 | if ($filter_name != '') { |
| 336 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 336 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 337 | 337 | } |
| 338 | 338 | $Spotter = new Spotter($this->db); |
| 339 | 339 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
| 340 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
| 340 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
| 341 | 341 | } |
| 342 | 342 | return $all; |
| 343 | 343 | } |
| 344 | 344 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 345 | 345 | global $globalStatsFilters; |
| 346 | 346 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 347 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 347 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 348 | 348 | $Spotter = new Spotter($this->db); |
| 349 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 349 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 350 | 350 | $alliance_airlines = array(); |
| 351 | 351 | foreach ($airlines as $airline) { |
| 352 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 352 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 353 | 353 | } |
| 354 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 355 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 354 | + if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 355 | + else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 356 | 356 | $query_values = array(':filter_name' => $filter_name); |
| 357 | 357 | } else { |
| 358 | 358 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
| 359 | 359 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
| 360 | - $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 360 | + $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 361 | 361 | } |
| 362 | 362 | try { |
| 363 | 363 | $sth = $this->db->prepare($query); |
| 364 | 364 | $sth->execute($query_values); |
| 365 | - } catch(PDOException $e) { |
|
| 365 | + } catch (PDOException $e) { |
|
| 366 | 366 | echo "error : ".$e->getMessage(); |
| 367 | 367 | } |
| 368 | 368 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 369 | 369 | if (empty($all)) { |
| 370 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 371 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 370 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 371 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 372 | 372 | } else { |
| 373 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 373 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 374 | 374 | } |
| 375 | 375 | if ($filter_name != '') { |
| 376 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 376 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 377 | 377 | } |
| 378 | 378 | $Spotter = new Spotter($this->db); |
| 379 | 379 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | return $all; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
|
| 385 | + public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') { |
|
| 386 | 386 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 387 | 387 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 388 | 388 | if ($year == '' && $month == '') { |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | if (isset($forsource)) { |
| 392 | 392 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
| 393 | 393 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
| 394 | - $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
|
| 394 | + $query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource); |
|
| 395 | 395 | } else { |
| 396 | 396 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
| 397 | 397 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | try { |
| 401 | 401 | $sth = $this->db->prepare($query); |
| 402 | 402 | $sth->execute($query_values); |
| 403 | - } catch(PDOException $e) { |
|
| 403 | + } catch (PDOException $e) { |
|
| 404 | 404 | echo "error : ".$e->getMessage(); |
| 405 | 405 | } |
| 406 | 406 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -408,32 +408,32 @@ discard block |
||
| 408 | 408 | if (empty($all)) { |
| 409 | 409 | $Spotter = new Spotter($this->db); |
| 410 | 410 | $filters = array(); |
| 411 | - $filters = array('year' => $year,'month' => $month); |
|
| 411 | + $filters = array('year' => $year, 'month' => $month); |
|
| 412 | 412 | if ($filter_name != '') { |
| 413 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 413 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 414 | 414 | } |
| 415 | 415 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
| 416 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
| 416 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
| 417 | 417 | } |
| 418 | 418 | return $all; |
| 419 | 419 | } |
| 420 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 420 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 421 | 421 | global $globalStatsFilters; |
| 422 | 422 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 423 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 423 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 424 | 424 | $Spotter = new Spotter($this->db); |
| 425 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 425 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 426 | 426 | $alliance_airlines = array(); |
| 427 | 427 | foreach ($airlines as $airline) { |
| 428 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 428 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 429 | 429 | } |
| 430 | 430 | if ($year == '' && $month == '') { |
| 431 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 432 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 431 | + if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 432 | + else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 433 | 433 | try { |
| 434 | 434 | $sth = $this->db->prepare($query); |
| 435 | 435 | $sth->execute(array(':filter_name' => $filter_name)); |
| 436 | - } catch(PDOException $e) { |
|
| 436 | + } catch (PDOException $e) { |
|
| 437 | 437 | echo "error : ".$e->getMessage(); |
| 438 | 438 | } |
| 439 | 439 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -444,45 +444,45 @@ discard block |
||
| 444 | 444 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
| 445 | 445 | try { |
| 446 | 446 | $sth = $this->db->prepare($query); |
| 447 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 448 | - } catch(PDOException $e) { |
|
| 447 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 448 | + } catch (PDOException $e) { |
|
| 449 | 449 | echo "error : ".$e->getMessage(); |
| 450 | 450 | } |
| 451 | 451 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 452 | 452 | } else $all = array(); |
| 453 | 453 | } |
| 454 | 454 | if (empty($all)) { |
| 455 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 456 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 455 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 456 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 457 | 457 | } else { |
| 458 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 458 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 459 | 459 | } |
| 460 | 460 | if ($filter_name != '') { |
| 461 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 461 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 462 | 462 | } |
| 463 | 463 | $Spotter = new Spotter($this->db); |
| 464 | 464 | //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
| 465 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
| 465 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
| 466 | 466 | } |
| 467 | 467 | return $all; |
| 468 | 468 | } |
| 469 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 469 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 470 | 470 | global $globalStatsFilters; |
| 471 | 471 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 472 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 472 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 473 | 473 | $Spotter = new Spotter($this->db); |
| 474 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 474 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 475 | 475 | $alliance_airlines = array(); |
| 476 | 476 | foreach ($airlines as $airline) { |
| 477 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 477 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 478 | 478 | } |
| 479 | 479 | if ($year == '' && $month == '') { |
| 480 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 481 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 480 | + if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 481 | + else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 482 | 482 | try { |
| 483 | 483 | $sth = $this->db->prepare($query); |
| 484 | 484 | $sth->execute(array(':filter_name' => $filter_name)); |
| 485 | - } catch(PDOException $e) { |
|
| 485 | + } catch (PDOException $e) { |
|
| 486 | 486 | echo "error : ".$e->getMessage(); |
| 487 | 487 | } |
| 488 | 488 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -493,46 +493,46 @@ discard block |
||
| 493 | 493 | else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
| 494 | 494 | try { |
| 495 | 495 | $sth = $this->db->prepare($query); |
| 496 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 497 | - } catch(PDOException $e) { |
|
| 496 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 497 | + } catch (PDOException $e) { |
|
| 498 | 498 | echo "error : ".$e->getMessage(); |
| 499 | 499 | } |
| 500 | 500 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 501 | 501 | } else $all = array(); |
| 502 | 502 | } |
| 503 | 503 | if (empty($all)) { |
| 504 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 505 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 504 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 505 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 506 | 506 | } else { |
| 507 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 507 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 508 | 508 | } |
| 509 | 509 | if ($filter_name != '') { |
| 510 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 510 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 511 | 511 | } |
| 512 | 512 | $Spotter = new Spotter($this->db); |
| 513 | 513 | //$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month); |
| 514 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
| 514 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
| 515 | 515 | } |
| 516 | 516 | return $all; |
| 517 | 517 | } |
| 518 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 518 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 519 | 519 | $Connection = new Connection($this->db); |
| 520 | 520 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 521 | 521 | if ($Connection->tableExists('countries')) { |
| 522 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 522 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 523 | 523 | $Spotter = new Spotter($this->db); |
| 524 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 524 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 525 | 525 | if ($year == '' && $month == '') { |
| 526 | 526 | $alliance_airlines = array(); |
| 527 | 527 | foreach ($airlines as $airline) { |
| 528 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 528 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 529 | 529 | } |
| 530 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 531 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 530 | + if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 531 | + else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 532 | 532 | try { |
| 533 | 533 | $sth = $this->db->prepare($query); |
| 534 | 534 | $sth->execute(array(':filter_name' => $filter_name)); |
| 535 | - } catch(PDOException $e) { |
|
| 535 | + } catch (PDOException $e) { |
|
| 536 | 536 | echo "error : ".$e->getMessage(); |
| 537 | 537 | } |
| 538 | 538 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -544,8 +544,8 @@ discard block |
||
| 544 | 544 | else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
| 545 | 545 | try { |
| 546 | 546 | $sth = $this->db->prepare($query); |
| 547 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 548 | - } catch(PDOException $e) { |
|
| 547 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 548 | + } catch (PDOException $e) { |
|
| 549 | 549 | echo "error : ".$e->getMessage(); |
| 550 | 550 | } |
| 551 | 551 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | return array(); |
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
|
| 565 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 566 | 566 | global $globalStatsFilters; |
| 567 | 567 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 568 | 568 | if ($year == '' && $month == '') { |
@@ -570,41 +570,41 @@ discard block |
||
| 570 | 570 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
| 571 | 571 | try { |
| 572 | 572 | $sth = $this->db->prepare($query); |
| 573 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 574 | - } catch(PDOException $e) { |
|
| 573 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 574 | + } catch (PDOException $e) { |
|
| 575 | 575 | echo "error : ".$e->getMessage(); |
| 576 | 576 | } |
| 577 | 577 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 578 | 578 | } else $all = array(); |
| 579 | 579 | if (empty($all)) { |
| 580 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 580 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 581 | 581 | if ($filter_name != '') { |
| 582 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 582 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 583 | 583 | } |
| 584 | 584 | $Spotter = new Spotter($this->db); |
| 585 | 585 | //$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month); |
| 586 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
| 586 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
| 587 | 587 | } |
| 588 | 588 | return $all; |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 591 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 592 | 592 | global $globalStatsFilters; |
| 593 | 593 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 594 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 594 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 595 | 595 | $Spotter = new Spotter($this->db); |
| 596 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 596 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 597 | 597 | if ($year == '' && $month == '') { |
| 598 | 598 | $alliance_airlines = array(); |
| 599 | 599 | foreach ($airlines as $airline) { |
| 600 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 600 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 601 | 601 | } |
| 602 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 603 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 602 | + if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 603 | + else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 604 | 604 | try { |
| 605 | 605 | $sth = $this->db->prepare($query); |
| 606 | 606 | $sth->execute(array(':filter_name' => $filter_name)); |
| 607 | - } catch(PDOException $e) { |
|
| 607 | + } catch (PDOException $e) { |
|
| 608 | 608 | echo "error : ".$e->getMessage(); |
| 609 | 609 | } |
| 610 | 610 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -615,45 +615,45 @@ discard block |
||
| 615 | 615 | else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
| 616 | 616 | try { |
| 617 | 617 | $sth = $this->db->prepare($query); |
| 618 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 619 | - } catch(PDOException $e) { |
|
| 618 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 619 | + } catch (PDOException $e) { |
|
| 620 | 620 | echo "error : ".$e->getMessage(); |
| 621 | 621 | } |
| 622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 623 | 623 | } else $all = array(); |
| 624 | 624 | } |
| 625 | 625 | if (empty($all)) { |
| 626 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 627 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 626 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 627 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 628 | 628 | } else { |
| 629 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 629 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 630 | 630 | } |
| 631 | 631 | if ($filter_name != '') { |
| 632 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 632 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 633 | 633 | } |
| 634 | 634 | $Spotter = new Spotter($this->db); |
| 635 | 635 | //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
| 636 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
| 636 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
| 637 | 637 | } |
| 638 | 638 | return $all; |
| 639 | 639 | } |
| 640 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 640 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 641 | 641 | global $globalStatsFilters; |
| 642 | 642 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 643 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 643 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 644 | 644 | $Spotter = new Spotter($this->db); |
| 645 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 645 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 646 | 646 | if ($year == '' && $month == '') { |
| 647 | 647 | $alliance_airlines = array(); |
| 648 | 648 | foreach ($airlines as $airline) { |
| 649 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 649 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 650 | 650 | } |
| 651 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 652 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 651 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 652 | + else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 653 | 653 | try { |
| 654 | 654 | $sth = $this->db->prepare($query); |
| 655 | 655 | $sth->execute(array(':filter_name' => $filter_name)); |
| 656 | - } catch(PDOException $e) { |
|
| 656 | + } catch (PDOException $e) { |
|
| 657 | 657 | echo "error : ".$e->getMessage(); |
| 658 | 658 | } |
| 659 | 659 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -664,27 +664,27 @@ discard block |
||
| 664 | 664 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
| 665 | 665 | try { |
| 666 | 666 | $sth = $this->db->prepare($query); |
| 667 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 668 | - } catch(PDOException $e) { |
|
| 667 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 668 | + } catch (PDOException $e) { |
|
| 669 | 669 | echo "error : ".$e->getMessage(); |
| 670 | 670 | } |
| 671 | 671 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 672 | 672 | } else $all = array(); |
| 673 | 673 | } |
| 674 | 674 | if (empty($all)) { |
| 675 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 676 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 675 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 676 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 677 | 677 | } else { |
| 678 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 678 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 679 | 679 | } |
| 680 | 680 | if ($filter_name != '') { |
| 681 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 681 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 682 | 682 | } |
| 683 | 683 | $Spotter = new Spotter($this->db); |
| 684 | 684 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
| 685 | 685 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
| 686 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
| 687 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
| 686 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
| 687 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
| 688 | 688 | $all = array(); |
| 689 | 689 | foreach ($pall as $value) { |
| 690 | 690 | $icao = $value['airport_departure_icao']; |
@@ -700,27 +700,27 @@ discard block |
||
| 700 | 700 | foreach ($all as $key => $row) { |
| 701 | 701 | $count[$key] = $row['airport_departure_icao_count']; |
| 702 | 702 | } |
| 703 | - array_multisort($count,SORT_DESC,$all); |
|
| 703 | + array_multisort($count, SORT_DESC, $all); |
|
| 704 | 704 | } |
| 705 | 705 | return $all; |
| 706 | 706 | } |
| 707 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 707 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 708 | 708 | global $globalStatsFilters; |
| 709 | 709 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 710 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 710 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 711 | 711 | $Spotter = new Spotter($this->db); |
| 712 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 712 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 713 | 713 | if ($year == '' && $month == '') { |
| 714 | 714 | $alliance_airlines = array(); |
| 715 | 715 | foreach ($airlines as $airline) { |
| 716 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 716 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 717 | 717 | } |
| 718 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 719 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 718 | + if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 719 | + else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 720 | 720 | try { |
| 721 | 721 | $sth = $this->db->prepare($query); |
| 722 | 722 | $sth->execute(array(':filter_name' => $filter_name)); |
| 723 | - } catch(PDOException $e) { |
|
| 723 | + } catch (PDOException $e) { |
|
| 724 | 724 | echo "error : ".$e->getMessage(); |
| 725 | 725 | } |
| 726 | 726 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -731,27 +731,27 @@ discard block |
||
| 731 | 731 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
| 732 | 732 | try { |
| 733 | 733 | $sth = $this->db->prepare($query); |
| 734 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
| 735 | - } catch(PDOException $e) { |
|
| 734 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
| 735 | + } catch (PDOException $e) { |
|
| 736 | 736 | echo "error : ".$e->getMessage(); |
| 737 | 737 | } |
| 738 | 738 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 739 | 739 | } else $all = array(); |
| 740 | 740 | } |
| 741 | 741 | if (empty($all)) { |
| 742 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 743 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 742 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 743 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 744 | 744 | } else { |
| 745 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 745 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 746 | 746 | } |
| 747 | 747 | if ($filter_name != '') { |
| 748 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 748 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 749 | 749 | } |
| 750 | 750 | $Spotter = new Spotter($this->db); |
| 751 | 751 | // $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
| 752 | 752 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
| 753 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
| 754 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
| 753 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
| 754 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
| 755 | 755 | $all = array(); |
| 756 | 756 | foreach ($pall as $value) { |
| 757 | 757 | $icao = $value['airport_arrival_icao']; |
@@ -767,26 +767,26 @@ discard block |
||
| 767 | 767 | foreach ($all as $key => $row) { |
| 768 | 768 | $count[$key] = $row['airport_arrival_icao_count']; |
| 769 | 769 | } |
| 770 | - array_multisort($count,SORT_DESC,$all); |
|
| 770 | + array_multisort($count, SORT_DESC, $all); |
|
| 771 | 771 | } |
| 772 | 772 | return $all; |
| 773 | 773 | } |
| 774 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
| 774 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
| 775 | 775 | global $globalDBdriver, $globalStatsFilters; |
| 776 | 776 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 777 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 777 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 778 | 778 | $Spotter = new Spotter($this->db); |
| 779 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 779 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 780 | 780 | $alliance_airlines = array(); |
| 781 | 781 | foreach ($airlines as $airline) { |
| 782 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 782 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 783 | 783 | } |
| 784 | 784 | if ($globalDBdriver == 'mysql') { |
| 785 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 786 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 785 | + if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 786 | + else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 787 | 787 | } else { |
| 788 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 789 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 788 | + if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 789 | + else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 790 | 790 | } |
| 791 | 791 | $query_data = array(':filter_name' => $filter_name); |
| 792 | 792 | } else { |
@@ -797,23 +797,23 @@ discard block |
||
| 797 | 797 | if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 798 | 798 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 799 | 799 | } |
| 800 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 800 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 801 | 801 | } |
| 802 | 802 | try { |
| 803 | 803 | $sth = $this->db->prepare($query); |
| 804 | 804 | $sth->execute($query_data); |
| 805 | - } catch(PDOException $e) { |
|
| 805 | + } catch (PDOException $e) { |
|
| 806 | 806 | echo "error : ".$e->getMessage(); |
| 807 | 807 | } |
| 808 | 808 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 809 | 809 | if (empty($all)) { |
| 810 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 811 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 810 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 811 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 812 | 812 | } else { |
| 813 | 813 | $filters = array('airlines' => array($stats_airline)); |
| 814 | 814 | } |
| 815 | 815 | if ($filter_name != '') { |
| 816 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 816 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 817 | 817 | } |
| 818 | 818 | $Spotter = new Spotter($this->db); |
| 819 | 819 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -821,57 +821,57 @@ discard block |
||
| 821 | 821 | return $all; |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
| 824 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
| 825 | 825 | global $globalStatsFilters; |
| 826 | 826 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 827 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 827 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 828 | 828 | $Spotter = new Spotter($this->db); |
| 829 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 829 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 830 | 830 | $alliance_airlines = array(); |
| 831 | 831 | foreach ($airlines as $airline) { |
| 832 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 832 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 833 | 833 | } |
| 834 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 834 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 835 | 835 | $query_data = array(':filter_name' => $filter_name); |
| 836 | 836 | } else { |
| 837 | 837 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 838 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 838 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 839 | 839 | } |
| 840 | 840 | try { |
| 841 | 841 | $sth = $this->db->prepare($query); |
| 842 | 842 | $sth->execute($query_data); |
| 843 | - } catch(PDOException $e) { |
|
| 843 | + } catch (PDOException $e) { |
|
| 844 | 844 | echo "error : ".$e->getMessage(); |
| 845 | 845 | } |
| 846 | 846 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 847 | 847 | if (empty($all)) { |
| 848 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 849 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 848 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 849 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 850 | 850 | } else { |
| 851 | 851 | $filters = array('airlines' => array($stats_airline)); |
| 852 | 852 | } |
| 853 | 853 | if ($filter_name != '') { |
| 854 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 854 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 855 | 855 | } |
| 856 | 856 | $Spotter = new Spotter($this->db); |
| 857 | 857 | $all = $Spotter->countAllDatesLastMonth($filters); |
| 858 | 858 | } |
| 859 | 859 | return $all; |
| 860 | 860 | } |
| 861 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
| 861 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
| 862 | 862 | global $globalDBdriver, $globalStatsFilters; |
| 863 | 863 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 864 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 864 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 865 | 865 | $Spotter = new Spotter($this->db); |
| 866 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 866 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 867 | 867 | $alliance_airlines = array(); |
| 868 | 868 | foreach ($airlines as $airline) { |
| 869 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 869 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 870 | 870 | } |
| 871 | 871 | if ($globalDBdriver == 'mysql') { |
| 872 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 872 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 873 | 873 | } else { |
| 874 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 874 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 875 | 875 | } |
| 876 | 876 | $query_data = array(':filter_name' => $filter_name); |
| 877 | 877 | } else { |
@@ -880,60 +880,60 @@ discard block |
||
| 880 | 880 | } else { |
| 881 | 881 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 882 | 882 | } |
| 883 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 883 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 884 | 884 | } |
| 885 | 885 | try { |
| 886 | 886 | $sth = $this->db->prepare($query); |
| 887 | 887 | $sth->execute($query_data); |
| 888 | - } catch(PDOException $e) { |
|
| 888 | + } catch (PDOException $e) { |
|
| 889 | 889 | echo "error : ".$e->getMessage(); |
| 890 | 890 | } |
| 891 | 891 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 892 | 892 | if (empty($all)) { |
| 893 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 894 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 893 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 894 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 895 | 895 | } else { |
| 896 | 896 | $filters = array('airlines' => array($stats_airline)); |
| 897 | 897 | } |
| 898 | 898 | if ($filter_name != '') { |
| 899 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 899 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 900 | 900 | } |
| 901 | 901 | $Spotter = new Spotter($this->db); |
| 902 | 902 | $all = $Spotter->countAllDatesLast7Days($filters); |
| 903 | 903 | } |
| 904 | 904 | return $all; |
| 905 | 905 | } |
| 906 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
| 906 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
| 907 | 907 | global $globalStatsFilters; |
| 908 | 908 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 909 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 909 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 910 | 910 | $Spotter = new Spotter($this->db); |
| 911 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 911 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 912 | 912 | $alliance_airlines = array(); |
| 913 | 913 | foreach ($airlines as $airline) { |
| 914 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 914 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 915 | 915 | } |
| 916 | - $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
| 916 | + $query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC"; |
|
| 917 | 917 | $query_data = array(':filter_name' => $filter_name); |
| 918 | 918 | } else { |
| 919 | 919 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC"; |
| 920 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 920 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 921 | 921 | } |
| 922 | 922 | try { |
| 923 | 923 | $sth = $this->db->prepare($query); |
| 924 | 924 | $sth->execute($query_data); |
| 925 | - } catch(PDOException $e) { |
|
| 925 | + } catch (PDOException $e) { |
|
| 926 | 926 | echo "error : ".$e->getMessage(); |
| 927 | 927 | } |
| 928 | 928 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 929 | 929 | if (empty($all)) { |
| 930 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 931 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 930 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 931 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 932 | 932 | } else { |
| 933 | 933 | $filters = array('airlines' => array($stats_airline)); |
| 934 | 934 | } |
| 935 | 935 | if ($filter_name != '') { |
| 936 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 936 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 937 | 937 | } |
| 938 | 938 | $Spotter = new Spotter($this->db); |
| 939 | 939 | $all = $Spotter->countAllDates($filters); |
@@ -948,34 +948,34 @@ discard block |
||
| 948 | 948 | try { |
| 949 | 949 | $sth = $this->db->prepare($query); |
| 950 | 950 | $sth->execute($query_data); |
| 951 | - } catch(PDOException $e) { |
|
| 951 | + } catch (PDOException $e) { |
|
| 952 | 952 | echo "error : ".$e->getMessage(); |
| 953 | 953 | } |
| 954 | 954 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 955 | 955 | if (empty($all)) { |
| 956 | 956 | $filters = array(); |
| 957 | 957 | if ($filter_name != '') { |
| 958 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 958 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 959 | 959 | } |
| 960 | 960 | $Spotter = new Spotter($this->db); |
| 961 | 961 | $all = $Spotter->countAllDatesByAirlines($filters); |
| 962 | 962 | } |
| 963 | 963 | return $all; |
| 964 | 964 | } |
| 965 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
| 965 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
| 966 | 966 | global $globalStatsFilters, $globalDBdriver; |
| 967 | 967 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 968 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 968 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 969 | 969 | $Spotter = new Spotter($this->db); |
| 970 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 970 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 971 | 971 | $alliance_airlines = array(); |
| 972 | 972 | foreach ($airlines as $airline) { |
| 973 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 973 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 974 | 974 | } |
| 975 | 975 | if ($globalDBdriver == 'mysql') { |
| 976 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 976 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 977 | 977 | } else { |
| 978 | - $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 978 | + $query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC"; |
|
| 979 | 979 | } |
| 980 | 980 | $query_data = array(':filter_name' => $filter_name); |
| 981 | 981 | } else { |
@@ -989,18 +989,18 @@ discard block |
||
| 989 | 989 | try { |
| 990 | 990 | $sth = $this->db->prepare($query); |
| 991 | 991 | $sth->execute($query_data); |
| 992 | - } catch(PDOException $e) { |
|
| 992 | + } catch (PDOException $e) { |
|
| 993 | 993 | echo "error : ".$e->getMessage(); |
| 994 | 994 | } |
| 995 | 995 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 996 | 996 | if (empty($all)) { |
| 997 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 998 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 997 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 998 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 999 | 999 | } else { |
| 1000 | 1000 | $filters = array('airlines' => array($stats_airline)); |
| 1001 | 1001 | } |
| 1002 | 1002 | if ($filter_name != '') { |
| 1003 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1003 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | $Spotter = new Spotter($this->db); |
| 1006 | 1006 | $all = $Spotter->countAllMonths($filters); |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | try { |
| 1018 | 1018 | $sth = $this->db->prepare($query); |
| 1019 | 1019 | $sth->execute(); |
| 1020 | - } catch(PDOException $e) { |
|
| 1020 | + } catch (PDOException $e) { |
|
| 1021 | 1021 | echo "error : ".$e->getMessage(); |
| 1022 | 1022 | } |
| 1023 | 1023 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | try { |
| 1038 | 1038 | $sth = $this->db->prepare($query); |
| 1039 | 1039 | $sth->execute(); |
| 1040 | - } catch(PDOException $e) { |
|
| 1040 | + } catch (PDOException $e) { |
|
| 1041 | 1041 | echo "error : ".$e->getMessage(); |
| 1042 | 1042 | } |
| 1043 | 1043 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1054,32 +1054,32 @@ discard block |
||
| 1054 | 1054 | try { |
| 1055 | 1055 | $sth = $this->db->prepare($query); |
| 1056 | 1056 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1057 | - } catch(PDOException $e) { |
|
| 1057 | + } catch (PDOException $e) { |
|
| 1058 | 1058 | echo "error : ".$e->getMessage(); |
| 1059 | 1059 | } |
| 1060 | 1060 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1061 | 1061 | if (empty($all)) { |
| 1062 | 1062 | $filters = array(); |
| 1063 | 1063 | if ($filter_name != '') { |
| 1064 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1064 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | $Spotter = new Spotter($this->db); |
| 1067 | 1067 | $all = $Spotter->countAllMilitaryMonths($filters); |
| 1068 | 1068 | } |
| 1069 | 1069 | return $all; |
| 1070 | 1070 | } |
| 1071 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
| 1071 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
| 1072 | 1072 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1073 | 1073 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1074 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1074 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1075 | 1075 | $Spotter = new Spotter($this->db); |
| 1076 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1076 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1077 | 1077 | $alliance_airlines = array(); |
| 1078 | 1078 | foreach ($airlines as $airline) { |
| 1079 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1079 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1080 | 1080 | } |
| 1081 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1082 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1081 | + if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1082 | + else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1083 | 1083 | $query_data = array(':filter_name' => $filter_name); |
| 1084 | 1084 | } else { |
| 1085 | 1085 | if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1097,37 +1097,37 @@ discard block |
||
| 1097 | 1097 | try { |
| 1098 | 1098 | $sth = $this->db->prepare($query); |
| 1099 | 1099 | $sth->execute($query_data); |
| 1100 | - } catch(PDOException $e) { |
|
| 1100 | + } catch (PDOException $e) { |
|
| 1101 | 1101 | echo "error : ".$e->getMessage(); |
| 1102 | 1102 | } |
| 1103 | 1103 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1104 | 1104 | if (empty($all)) { |
| 1105 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1106 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1105 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1106 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1107 | 1107 | } else { |
| 1108 | 1108 | $filters = array('airlines' => array($stats_airline)); |
| 1109 | 1109 | } |
| 1110 | 1110 | if ($filter_name != '') { |
| 1111 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1111 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | $Spotter = new Spotter($this->db); |
| 1114 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
| 1114 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | return $all; |
| 1117 | 1117 | } |
| 1118 | - public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
| 1118 | + public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1119 | 1119 | global $globalStatsFilters; |
| 1120 | 1120 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1121 | 1121 | if ($year == '') $year = date('Y'); |
| 1122 | - $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1122 | + $all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1123 | 1123 | if (empty($all)) { |
| 1124 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1125 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1124 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1125 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1126 | 1126 | } else { |
| 1127 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1127 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1128 | 1128 | } |
| 1129 | 1129 | if ($filter_name != '') { |
| 1130 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1130 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1131 | 1131 | } |
| 1132 | 1132 | $Spotter = new Spotter($this->db); |
| 1133 | 1133 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -1135,16 +1135,16 @@ discard block |
||
| 1135 | 1135 | } |
| 1136 | 1136 | return $all; |
| 1137 | 1137 | } |
| 1138 | - public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
|
| 1138 | + public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') { |
|
| 1139 | 1139 | global $globalStatsFilters; |
| 1140 | 1140 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1141 | 1141 | if ($year == '') $year = date('Y'); |
| 1142 | - $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
|
| 1142 | + $all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month); |
|
| 1143 | 1143 | if (empty($all)) { |
| 1144 | 1144 | $filters = array(); |
| 1145 | - $filters = array('year' => $year,'month' => $month); |
|
| 1145 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1146 | 1146 | if ($filter_name != '') { |
| 1147 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1147 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1148 | 1148 | } |
| 1149 | 1149 | $Spotter = new Spotter($this->db); |
| 1150 | 1150 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -1152,19 +1152,19 @@ discard block |
||
| 1152 | 1152 | } |
| 1153 | 1153 | return $all; |
| 1154 | 1154 | } |
| 1155 | - public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
|
| 1155 | + public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1156 | 1156 | global $globalStatsFilters; |
| 1157 | 1157 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1158 | 1158 | if ($year == '') $year = date('Y'); |
| 1159 | - $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1159 | + $all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1160 | 1160 | if (empty($all)) { |
| 1161 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1162 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1161 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1162 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1163 | 1163 | } else { |
| 1164 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1164 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | if ($filter_name != '') { |
| 1167 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1167 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1168 | 1168 | } |
| 1169 | 1169 | $Spotter = new Spotter($this->db); |
| 1170 | 1170 | //$all = $Spotter->countOverallArrival($filters,$year,$month); |
@@ -1172,48 +1172,48 @@ discard block |
||
| 1172 | 1172 | } |
| 1173 | 1173 | return $all; |
| 1174 | 1174 | } |
| 1175 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 1175 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1176 | 1176 | global $globalStatsFilters; |
| 1177 | 1177 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1178 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1178 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1179 | 1179 | $Spotter = new Spotter($this->db); |
| 1180 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1180 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1181 | 1181 | if ($year == '' && $month == '') { |
| 1182 | 1182 | $alliance_airlines = array(); |
| 1183 | 1183 | foreach ($airlines as $airline) { |
| 1184 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1184 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1185 | 1185 | } |
| 1186 | - $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1186 | + $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1187 | 1187 | try { |
| 1188 | 1188 | $sth = $this->db->prepare($query); |
| 1189 | 1189 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1190 | - } catch(PDOException $e) { |
|
| 1190 | + } catch (PDOException $e) { |
|
| 1191 | 1191 | echo "error : ".$e->getMessage(); |
| 1192 | 1192 | } |
| 1193 | 1193 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1194 | 1194 | $all = $result[0]['nb']; |
| 1195 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1195 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1196 | 1196 | } else { |
| 1197 | 1197 | if ($year == '' && $month == '') { |
| 1198 | 1198 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1199 | 1199 | try { |
| 1200 | 1200 | $sth = $this->db->prepare($query); |
| 1201 | - $sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline)); |
|
| 1202 | - } catch(PDOException $e) { |
|
| 1201 | + $sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline)); |
|
| 1202 | + } catch (PDOException $e) { |
|
| 1203 | 1203 | echo "error : ".$e->getMessage(); |
| 1204 | 1204 | } |
| 1205 | 1205 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1206 | 1206 | $all = $result[0]['nb']; |
| 1207 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1207 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1208 | 1208 | } |
| 1209 | 1209 | if (empty($all)) { |
| 1210 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1211 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1210 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1211 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1212 | 1212 | } else { |
| 1213 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1213 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1214 | 1214 | } |
| 1215 | 1215 | if ($filter_name != '') { |
| 1216 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1216 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | $Spotter = new Spotter($this->db); |
| 1219 | 1219 | //$all = $Spotter->countOverallAircrafts($filters,$year,$month); |
@@ -1221,7 +1221,7 @@ discard block |
||
| 1221 | 1221 | } |
| 1222 | 1222 | return $all; |
| 1223 | 1223 | } |
| 1224 | - public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
|
| 1224 | + public function countOverallAirlines($filter_name = '', $year = '', $month = '') { |
|
| 1225 | 1225 | global $globalStatsFilters; |
| 1226 | 1226 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1227 | 1227 | if ($year == '' && $month == '') { |
@@ -1229,17 +1229,17 @@ discard block |
||
| 1229 | 1229 | try { |
| 1230 | 1230 | $sth = $this->db->prepare($query); |
| 1231 | 1231 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1232 | - } catch(PDOException $e) { |
|
| 1232 | + } catch (PDOException $e) { |
|
| 1233 | 1233 | echo "error : ".$e->getMessage(); |
| 1234 | 1234 | } |
| 1235 | 1235 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1236 | 1236 | $all = $result[0]['nb_airline']; |
| 1237 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1237 | + } else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month); |
|
| 1238 | 1238 | if (empty($all)) { |
| 1239 | 1239 | $filters = array(); |
| 1240 | - $filters = array('year' => $year,'month' => $month); |
|
| 1240 | + $filters = array('year' => $year, 'month' => $month); |
|
| 1241 | 1241 | if ($filter_name != '') { |
| 1242 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1242 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | $Spotter = new Spotter($this->db); |
| 1245 | 1245 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -1247,29 +1247,29 @@ discard block |
||
| 1247 | 1247 | } |
| 1248 | 1248 | return $all; |
| 1249 | 1249 | } |
| 1250 | - public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
| 1250 | + public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1251 | 1251 | global $globalStatsFilters; |
| 1252 | 1252 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1253 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1253 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1254 | 1254 | $Spotter = new Spotter($this->db); |
| 1255 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1255 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1256 | 1256 | if ($year == '' && $month == '') { |
| 1257 | 1257 | $alliance_airlines = array(); |
| 1258 | 1258 | foreach ($airlines as $airline) { |
| 1259 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1259 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1260 | 1260 | } |
| 1261 | - $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1261 | + $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1262 | 1262 | $query_values = array(':filter_name' => $filter_name); |
| 1263 | 1263 | try { |
| 1264 | 1264 | $sth = $this->db->prepare($query); |
| 1265 | 1265 | $sth->execute($query_values); |
| 1266 | - } catch(PDOException $e) { |
|
| 1266 | + } catch (PDOException $e) { |
|
| 1267 | 1267 | echo "error : ".$e->getMessage(); |
| 1268 | 1268 | } |
| 1269 | 1269 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1270 | 1270 | $all = $result[0]['nb']; |
| 1271 | 1271 | } else { |
| 1272 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1272 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1273 | 1273 | } |
| 1274 | 1274 | } else { |
| 1275 | 1275 | if ($year == '' && $month == '') { |
@@ -1278,23 +1278,23 @@ discard block |
||
| 1278 | 1278 | try { |
| 1279 | 1279 | $sth = $this->db->prepare($query); |
| 1280 | 1280 | $sth->execute($query_values); |
| 1281 | - } catch(PDOException $e) { |
|
| 1281 | + } catch (PDOException $e) { |
|
| 1282 | 1282 | echo "error : ".$e->getMessage(); |
| 1283 | 1283 | } |
| 1284 | 1284 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1285 | 1285 | $all = $result[0]['nb']; |
| 1286 | 1286 | } else { |
| 1287 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1287 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | } |
| 1290 | 1290 | if (empty($all)) { |
| 1291 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1292 | - $filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month); |
|
| 1291 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1292 | + $filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month); |
|
| 1293 | 1293 | } else { |
| 1294 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1294 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | if ($filter_name != '') { |
| 1297 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1297 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1298 | 1298 | } |
| 1299 | 1299 | $Spotter = new Spotter($this->db); |
| 1300 | 1300 | //$all = $Spotter->countOverallOwners($filters,$year,$month); |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | } |
| 1303 | 1303 | return $all; |
| 1304 | 1304 | } |
| 1305 | - public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
| 1305 | + public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
| 1306 | 1306 | global $globalStatsFilters; |
| 1307 | 1307 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1308 | 1308 | //if ($year == '') $year = date('Y'); |
@@ -1312,18 +1312,18 @@ discard block |
||
| 1312 | 1312 | try { |
| 1313 | 1313 | $sth = $this->db->prepare($query); |
| 1314 | 1314 | $sth->execute($query_values); |
| 1315 | - } catch(PDOException $e) { |
|
| 1315 | + } catch (PDOException $e) { |
|
| 1316 | 1316 | echo "error : ".$e->getMessage(); |
| 1317 | 1317 | } |
| 1318 | 1318 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1319 | 1319 | $all = $result[0]['nb']; |
| 1320 | 1320 | } else { |
| 1321 | - $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1321 | + $all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month); |
|
| 1322 | 1322 | } |
| 1323 | 1323 | if (empty($all)) { |
| 1324 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
| 1324 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
| 1325 | 1325 | if ($filter_name != '') { |
| 1326 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
| 1326 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | $Spotter = new Spotter($this->db); |
| 1329 | 1329 | //$all = $Spotter->countOverallPilots($filters,$year,$month); |
@@ -1332,104 +1332,104 @@ discard block |
||
| 1332 | 1332 | return $all; |
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
| 1335 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
| 1336 | 1336 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1337 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1337 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1338 | 1338 | $Spotter = new Spotter($this->db); |
| 1339 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1339 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1340 | 1340 | $alliance_airlines = array(); |
| 1341 | 1341 | foreach ($airlines as $airline) { |
| 1342 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1342 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1343 | 1343 | } |
| 1344 | - $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
| 1345 | - $query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name); |
|
| 1344 | + $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date"; |
|
| 1345 | + $query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name); |
|
| 1346 | 1346 | } else { |
| 1347 | 1347 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
| 1348 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1348 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | try { |
| 1351 | 1351 | $sth = $this->db->prepare($query); |
| 1352 | 1352 | $sth->execute($query_values); |
| 1353 | - } catch(PDOException $e) { |
|
| 1353 | + } catch (PDOException $e) { |
|
| 1354 | 1354 | echo "error : ".$e->getMessage(); |
| 1355 | 1355 | } |
| 1356 | 1356 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1357 | 1357 | return $all; |
| 1358 | 1358 | } |
| 1359 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
| 1359 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
| 1360 | 1360 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1361 | 1361 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 1362 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1362 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1363 | 1363 | try { |
| 1364 | 1364 | $sth = $this->db->prepare($query); |
| 1365 | 1365 | $sth->execute($query_values); |
| 1366 | - } catch(PDOException $e) { |
|
| 1366 | + } catch (PDOException $e) { |
|
| 1367 | 1367 | echo "error : ".$e->getMessage(); |
| 1368 | 1368 | } |
| 1369 | 1369 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1370 | 1370 | return $all; |
| 1371 | 1371 | } |
| 1372 | - public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
|
| 1372 | + public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') { |
|
| 1373 | 1373 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1374 | 1374 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1375 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1375 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1376 | 1376 | try { |
| 1377 | 1377 | $sth = $this->db->prepare($query); |
| 1378 | 1378 | $sth->execute($query_values); |
| 1379 | - } catch(PDOException $e) { |
|
| 1379 | + } catch (PDOException $e) { |
|
| 1380 | 1380 | echo "error : ".$e->getMessage(); |
| 1381 | 1381 | } |
| 1382 | 1382 | } |
| 1383 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
|
| 1383 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') { |
|
| 1384 | 1384 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1385 | 1385 | global $globalArchiveMonths, $globalDBdriver; |
| 1386 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1386 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1387 | 1387 | $Spotter = new Spotter($this->db); |
| 1388 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1388 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1389 | 1389 | $alliance_airlines = array(); |
| 1390 | 1390 | foreach ($airlines as $airline) { |
| 1391 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1391 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1392 | 1392 | } |
| 1393 | 1393 | if ($globalDBdriver == 'mysql') { |
| 1394 | 1394 | if ($month == '') { |
| 1395 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1395 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1396 | 1396 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
| 1397 | 1397 | } else { |
| 1398 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1399 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
| 1398 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1399 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1400 | 1400 | } |
| 1401 | 1401 | } else { |
| 1402 | 1402 | if ($month == '') { |
| 1403 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1403 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1404 | 1404 | $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name); |
| 1405 | 1405 | } else { |
| 1406 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1407 | - $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month); |
|
| 1406 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1407 | + $query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1408 | 1408 | } |
| 1409 | 1409 | } |
| 1410 | 1410 | } else { |
| 1411 | 1411 | if ($globalDBdriver == 'mysql') { |
| 1412 | 1412 | if ($month == '') { |
| 1413 | 1413 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1414 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1414 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1415 | 1415 | } else { |
| 1416 | 1416 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1417 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 1417 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1418 | 1418 | } |
| 1419 | 1419 | } else { |
| 1420 | 1420 | if ($month == '') { |
| 1421 | 1421 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1422 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1422 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1423 | 1423 | } else { |
| 1424 | 1424 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1425 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
| 1425 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | 1428 | } |
| 1429 | 1429 | try { |
| 1430 | 1430 | $sth = $this->db->prepare($query); |
| 1431 | 1431 | $sth->execute($query_values); |
| 1432 | - } catch(PDOException $e) { |
|
| 1432 | + } catch (PDOException $e) { |
|
| 1433 | 1433 | echo "error : ".$e->getMessage(); |
| 1434 | 1434 | } |
| 1435 | 1435 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1438,17 +1438,17 @@ discard block |
||
| 1438 | 1438 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 1439 | 1439 | global $globalArchiveMonths, $globalDBdriver; |
| 1440 | 1440 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1441 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1441 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1442 | 1442 | $Spotter = new Spotter($this->db); |
| 1443 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1443 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1444 | 1444 | $alliance_airlines = array(); |
| 1445 | 1445 | foreach ($airlines as $airline) { |
| 1446 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1446 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | if ($globalDBdriver == 'mysql') { |
| 1449 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1449 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1450 | 1450 | } else { |
| 1451 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1451 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1452 | 1452 | } |
| 1453 | 1453 | $query_values = array(':type' => $type, ':filter_name' => $filter_name); |
| 1454 | 1454 | } else { |
@@ -1462,7 +1462,7 @@ discard block |
||
| 1462 | 1462 | try { |
| 1463 | 1463 | $sth = $this->db->prepare($query); |
| 1464 | 1464 | $sth->execute($query_values); |
| 1465 | - } catch(PDOException $e) { |
|
| 1465 | + } catch (PDOException $e) { |
|
| 1466 | 1466 | echo "error : ".$e->getMessage(); |
| 1467 | 1467 | } |
| 1468 | 1468 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1471,17 +1471,17 @@ discard block |
||
| 1471 | 1471 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 1472 | 1472 | global $globalArchiveMonths, $globalDBdriver; |
| 1473 | 1473 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1474 | - if (strpos($stats_airline,'alliance_') !== FALSE) { |
|
| 1474 | + if (strpos($stats_airline, 'alliance_') !== FALSE) { |
|
| 1475 | 1475 | $Spotter = new Spotter($this->db); |
| 1476 | - $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
|
| 1476 | + $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline))); |
|
| 1477 | 1477 | $alliance_airlines = array(); |
| 1478 | 1478 | foreach ($airlines as $airline) { |
| 1479 | - $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
|
| 1479 | + $alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao'])); |
|
| 1480 | 1480 | } |
| 1481 | 1481 | if ($globalDBdriver == 'mysql') { |
| 1482 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1482 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1483 | 1483 | } else { |
| 1484 | - $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1484 | + $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name"; |
|
| 1485 | 1485 | } |
| 1486 | 1486 | } else { |
| 1487 | 1487 | if ($globalDBdriver == 'mysql') { |
@@ -1493,7 +1493,7 @@ discard block |
||
| 1493 | 1493 | try { |
| 1494 | 1494 | $sth = $this->db->prepare($query); |
| 1495 | 1495 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
| 1496 | - } catch(PDOException $e) { |
|
| 1496 | + } catch (PDOException $e) { |
|
| 1497 | 1497 | echo "error : ".$e->getMessage(); |
| 1498 | 1498 | } |
| 1499 | 1499 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | try { |
| 1511 | 1511 | $sth = $this->db->prepare($query); |
| 1512 | 1512 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1513 | - } catch(PDOException $e) { |
|
| 1513 | + } catch (PDOException $e) { |
|
| 1514 | 1514 | echo "error : ".$e->getMessage(); |
| 1515 | 1515 | } |
| 1516 | 1516 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1527,20 +1527,20 @@ discard block |
||
| 1527 | 1527 | try { |
| 1528 | 1528 | $sth = $this->db->prepare($query); |
| 1529 | 1529 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1530 | - } catch(PDOException $e) { |
|
| 1530 | + } catch (PDOException $e) { |
|
| 1531 | 1531 | echo "error : ".$e->getMessage(); |
| 1532 | 1532 | } |
| 1533 | 1533 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1534 | 1534 | return $all[0]['total']; |
| 1535 | 1535 | } |
| 1536 | - public function getStatsOwner($owner_name,$filter_name = '') { |
|
| 1536 | + public function getStatsOwner($owner_name, $filter_name = '') { |
|
| 1537 | 1537 | global $globalArchiveMonths, $globalDBdriver; |
| 1538 | 1538 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1539 | 1539 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1540 | 1540 | try { |
| 1541 | 1541 | $sth = $this->db->prepare($query); |
| 1542 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
| 1543 | - } catch(PDOException $e) { |
|
| 1542 | + $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name)); |
|
| 1543 | + } catch (PDOException $e) { |
|
| 1544 | 1544 | echo "error : ".$e->getMessage(); |
| 1545 | 1545 | } |
| 1546 | 1546 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1558,20 +1558,20 @@ discard block |
||
| 1558 | 1558 | try { |
| 1559 | 1559 | $sth = $this->db->prepare($query); |
| 1560 | 1560 | $sth->execute(array(':filter_name' => $filter_name)); |
| 1561 | - } catch(PDOException $e) { |
|
| 1561 | + } catch (PDOException $e) { |
|
| 1562 | 1562 | echo "error : ".$e->getMessage(); |
| 1563 | 1563 | } |
| 1564 | 1564 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1565 | 1565 | return $all[0]['total']; |
| 1566 | 1566 | } |
| 1567 | - public function getStatsPilot($pilot,$filter_name = '') { |
|
| 1567 | + public function getStatsPilot($pilot, $filter_name = '') { |
|
| 1568 | 1568 | global $globalArchiveMonths, $globalDBdriver; |
| 1569 | 1569 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1570 | 1570 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1571 | 1571 | try { |
| 1572 | 1572 | $sth = $this->db->prepare($query); |
| 1573 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
| 1574 | - } catch(PDOException $e) { |
|
| 1573 | + $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot)); |
|
| 1574 | + } catch (PDOException $e) { |
|
| 1575 | 1575 | echo "error : ".$e->getMessage(); |
| 1576 | 1576 | } |
| 1577 | 1577 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | else return 0; |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 1582 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 1583 | 1583 | global $globalDBdriver; |
| 1584 | 1584 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1585 | 1585 | if ($globalDBdriver == 'mysql') { |
@@ -1587,15 +1587,15 @@ discard block |
||
| 1587 | 1587 | } else { |
| 1588 | 1588 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1589 | 1589 | } |
| 1590 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1590 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1591 | 1591 | try { |
| 1592 | 1592 | $sth = $this->db->prepare($query); |
| 1593 | 1593 | $sth->execute($query_values); |
| 1594 | - } catch(PDOException $e) { |
|
| 1594 | + } catch (PDOException $e) { |
|
| 1595 | 1595 | return "error : ".$e->getMessage(); |
| 1596 | 1596 | } |
| 1597 | 1597 | } |
| 1598 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
| 1598 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
| 1599 | 1599 | global $globalDBdriver; |
| 1600 | 1600 | if ($filter_name == '') $filter_name = $this->filter_name; |
| 1601 | 1601 | if ($globalDBdriver == 'mysql') { |
@@ -1604,11 +1604,11 @@ discard block |
||
| 1604 | 1604 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 1605 | 1605 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1606 | 1606 | } |
| 1607 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1607 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1608 | 1608 | try { |
| 1609 | 1609 | $sth = $this->db->prepare($query); |
| 1610 | 1610 | $sth->execute($query_values); |
| 1611 | - } catch(PDOException $e) { |
|
| 1611 | + } catch (PDOException $e) { |
|
| 1612 | 1612 | return "error : ".$e->getMessage(); |
| 1613 | 1613 | } |
| 1614 | 1614 | } |
@@ -1632,75 +1632,75 @@ discard block |
||
| 1632 | 1632 | } |
| 1633 | 1633 | */ |
| 1634 | 1634 | |
| 1635 | - public function getStatsSource($stats_type,$year = '',$month = '',$day = '') { |
|
| 1635 | + public function getStatsSource($stats_type, $year = '', $month = '', $day = '') { |
|
| 1636 | 1636 | global $globalDBdriver; |
| 1637 | 1637 | $query = "SELECT * FROM stats_source WHERE stats_type = :stats_type"; |
| 1638 | 1638 | $query_values = array(); |
| 1639 | 1639 | if ($globalDBdriver == 'mysql') { |
| 1640 | 1640 | if ($year != '') { |
| 1641 | 1641 | $query .= ' AND YEAR(stats_date) = :year'; |
| 1642 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1642 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1643 | 1643 | } |
| 1644 | 1644 | if ($month != '') { |
| 1645 | 1645 | $query .= ' AND MONTH(stats_date) = :month'; |
| 1646 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1646 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1647 | 1647 | } |
| 1648 | 1648 | if ($day != '') { |
| 1649 | 1649 | $query .= ' AND DAY(stats_date) = :day'; |
| 1650 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1650 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1651 | 1651 | } |
| 1652 | 1652 | } else { |
| 1653 | 1653 | if ($year != '') { |
| 1654 | 1654 | $query .= ' AND EXTRACT(YEAR FROM stats_date) = :year'; |
| 1655 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1655 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1656 | 1656 | } |
| 1657 | 1657 | if ($month != '') { |
| 1658 | 1658 | $query .= ' AND EXTRACT(MONTH FROM stats_date) = :month'; |
| 1659 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1659 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1660 | 1660 | } |
| 1661 | 1661 | if ($day != '') { |
| 1662 | 1662 | $query .= ' AND EXTRACT(DAY FROM stats_date) = :day'; |
| 1663 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1663 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1664 | 1664 | } |
| 1665 | 1665 | } |
| 1666 | 1666 | $query .= " ORDER BY source_name"; |
| 1667 | - $query_values = array_merge($query_values,array(':stats_type' => $stats_type)); |
|
| 1667 | + $query_values = array_merge($query_values, array(':stats_type' => $stats_type)); |
|
| 1668 | 1668 | try { |
| 1669 | 1669 | $sth = $this->db->prepare($query); |
| 1670 | 1670 | $sth->execute($query_values); |
| 1671 | - } catch(PDOException $e) { |
|
| 1671 | + } catch (PDOException $e) { |
|
| 1672 | 1672 | echo "error : ".$e->getMessage(); |
| 1673 | 1673 | } |
| 1674 | 1674 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1675 | 1675 | return $all; |
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
| 1678 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
| 1679 | 1679 | global $globalDBdriver; |
| 1680 | 1680 | if ($globalDBdriver == 'mysql') { |
| 1681 | 1681 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
| 1682 | 1682 | } else { |
| 1683 | 1683 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
| 1684 | 1684 | } |
| 1685 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
| 1685 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
| 1686 | 1686 | try { |
| 1687 | 1687 | $sth = $this->db->prepare($query); |
| 1688 | 1688 | $sth->execute($query_values); |
| 1689 | - } catch(PDOException $e) { |
|
| 1689 | + } catch (PDOException $e) { |
|
| 1690 | 1690 | return "error : ".$e->getMessage(); |
| 1691 | 1691 | } |
| 1692 | 1692 | } |
| 1693 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
| 1693 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
| 1694 | 1694 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
| 1695 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1695 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1696 | 1696 | try { |
| 1697 | 1697 | $sth = $this->db->prepare($query); |
| 1698 | 1698 | $sth->execute($query_values); |
| 1699 | - } catch(PDOException $e) { |
|
| 1699 | + } catch (PDOException $e) { |
|
| 1700 | 1700 | return "error : ".$e->getMessage(); |
| 1701 | 1701 | } |
| 1702 | 1702 | } |
| 1703 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1703 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1704 | 1704 | global $globalDBdriver; |
| 1705 | 1705 | if ($globalDBdriver == 'mysql') { |
| 1706 | 1706 | if ($reset) { |
@@ -1715,15 +1715,15 @@ discard block |
||
| 1715 | 1715 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1716 | 1716 | } |
| 1717 | 1717 | } |
| 1718 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1718 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1719 | 1719 | try { |
| 1720 | 1720 | $sth = $this->db->prepare($query); |
| 1721 | 1721 | $sth->execute($query_values); |
| 1722 | - } catch(PDOException $e) { |
|
| 1722 | + } catch (PDOException $e) { |
|
| 1723 | 1723 | return "error : ".$e->getMessage(); |
| 1724 | 1724 | } |
| 1725 | 1725 | } |
| 1726 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1726 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1727 | 1727 | global $globalDBdriver; |
| 1728 | 1728 | if ($globalDBdriver == 'mysql') { |
| 1729 | 1729 | if ($reset) { |
@@ -1738,15 +1738,15 @@ discard block |
||
| 1738 | 1738 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
| 1739 | 1739 | } |
| 1740 | 1740 | } |
| 1741 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1741 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1742 | 1742 | try { |
| 1743 | 1743 | $sth = $this->db->prepare($query); |
| 1744 | 1744 | $sth->execute($query_values); |
| 1745 | - } catch(PDOException $e) { |
|
| 1745 | + } catch (PDOException $e) { |
|
| 1746 | 1746 | return "error : ".$e->getMessage(); |
| 1747 | 1747 | } |
| 1748 | 1748 | } |
| 1749 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1749 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1750 | 1750 | global $globalDBdriver; |
| 1751 | 1751 | if ($globalDBdriver == 'mysql') { |
| 1752 | 1752 | if ($reset) { |
@@ -1761,15 +1761,15 @@ discard block |
||
| 1761 | 1761 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
| 1762 | 1762 | } |
| 1763 | 1763 | } |
| 1764 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
| 1764 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao); |
|
| 1765 | 1765 | try { |
| 1766 | 1766 | $sth = $this->db->prepare($query); |
| 1767 | 1767 | $sth->execute($query_values); |
| 1768 | - } catch(PDOException $e) { |
|
| 1768 | + } catch (PDOException $e) { |
|
| 1769 | 1769 | return "error : ".$e->getMessage(); |
| 1770 | 1770 | } |
| 1771 | 1771 | } |
| 1772 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1772 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1773 | 1773 | global $globalDBdriver; |
| 1774 | 1774 | if ($globalDBdriver == 'mysql') { |
| 1775 | 1775 | if ($reset) { |
@@ -1784,15 +1784,15 @@ discard block |
||
| 1784 | 1784 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1785 | 1785 | } |
| 1786 | 1786 | } |
| 1787 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1787 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1788 | 1788 | try { |
| 1789 | 1789 | $sth = $this->db->prepare($query); |
| 1790 | 1790 | $sth->execute($query_values); |
| 1791 | - } catch(PDOException $e) { |
|
| 1791 | + } catch (PDOException $e) { |
|
| 1792 | 1792 | return "error : ".$e->getMessage(); |
| 1793 | 1793 | } |
| 1794 | 1794 | } |
| 1795 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
|
| 1795 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) { |
|
| 1796 | 1796 | global $globalDBdriver; |
| 1797 | 1797 | if ($globalDBdriver == 'mysql') { |
| 1798 | 1798 | if ($reset) { |
@@ -1807,15 +1807,15 @@ discard block |
||
| 1807 | 1807 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
| 1808 | 1808 | } |
| 1809 | 1809 | } |
| 1810 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
| 1810 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
| 1811 | 1811 | try { |
| 1812 | 1812 | $sth = $this->db->prepare($query); |
| 1813 | 1813 | $sth->execute($query_values); |
| 1814 | - } catch(PDOException $e) { |
|
| 1814 | + } catch (PDOException $e) { |
|
| 1815 | 1815 | return "error : ".$e->getMessage(); |
| 1816 | 1816 | } |
| 1817 | 1817 | } |
| 1818 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
|
| 1818 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) { |
|
| 1819 | 1819 | global $globalDBdriver; |
| 1820 | 1820 | if ($globalDBdriver == 'mysql') { |
| 1821 | 1821 | if ($reset) { |
@@ -1830,15 +1830,15 @@ discard block |
||
| 1830 | 1830 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1831 | 1831 | } |
| 1832 | 1832 | } |
| 1833 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
| 1833 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
| 1834 | 1834 | try { |
| 1835 | 1835 | $sth = $this->db->prepare($query); |
| 1836 | 1836 | $sth->execute($query_values); |
| 1837 | - } catch(PDOException $e) { |
|
| 1837 | + } catch (PDOException $e) { |
|
| 1838 | 1838 | return "error : ".$e->getMessage(); |
| 1839 | 1839 | } |
| 1840 | 1840 | } |
| 1841 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
|
| 1841 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) { |
|
| 1842 | 1842 | global $globalDBdriver; |
| 1843 | 1843 | if ($globalDBdriver == 'mysql') { |
| 1844 | 1844 | if ($reset) { |
@@ -1853,15 +1853,15 @@ discard block |
||
| 1853 | 1853 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
| 1854 | 1854 | } |
| 1855 | 1855 | } |
| 1856 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
| 1856 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source); |
|
| 1857 | 1857 | try { |
| 1858 | 1858 | $sth = $this->db->prepare($query); |
| 1859 | 1859 | $sth->execute($query_values); |
| 1860 | - } catch(PDOException $e) { |
|
| 1860 | + } catch (PDOException $e) { |
|
| 1861 | 1861 | return "error : ".$e->getMessage(); |
| 1862 | 1862 | } |
| 1863 | 1863 | } |
| 1864 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1864 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1865 | 1865 | global $globalDBdriver; |
| 1866 | 1866 | if ($airport_icao != '') { |
| 1867 | 1867 | if ($globalDBdriver == 'mysql') { |
@@ -1877,16 +1877,16 @@ discard block |
||
| 1877 | 1877 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
| 1878 | 1878 | } |
| 1879 | 1879 | } |
| 1880 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 1880 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1881 | 1881 | try { |
| 1882 | 1882 | $sth = $this->db->prepare($query); |
| 1883 | 1883 | $sth->execute($query_values); |
| 1884 | - } catch(PDOException $e) { |
|
| 1884 | + } catch (PDOException $e) { |
|
| 1885 | 1885 | return "error : ".$e->getMessage(); |
| 1886 | 1886 | } |
| 1887 | 1887 | } |
| 1888 | 1888 | } |
| 1889 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
| 1889 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
| 1890 | 1890 | global $globalDBdriver; |
| 1891 | 1891 | if ($airport_icao != '') { |
| 1892 | 1892 | if ($globalDBdriver == 'mysql') { |
@@ -1894,16 +1894,16 @@ discard block |
||
| 1894 | 1894 | } else { |
| 1895 | 1895 | $query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1896 | 1896 | } |
| 1897 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 1897 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1898 | 1898 | try { |
| 1899 | 1899 | $sth = $this->db->prepare($query); |
| 1900 | 1900 | $sth->execute($query_values); |
| 1901 | - } catch(PDOException $e) { |
|
| 1901 | + } catch (PDOException $e) { |
|
| 1902 | 1902 | return "error : ".$e->getMessage(); |
| 1903 | 1903 | } |
| 1904 | 1904 | } |
| 1905 | 1905 | } |
| 1906 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
|
| 1906 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) { |
|
| 1907 | 1907 | global $globalDBdriver; |
| 1908 | 1908 | if ($airport_icao != '') { |
| 1909 | 1909 | if ($globalDBdriver == 'mysql') { |
@@ -1919,16 +1919,16 @@ discard block |
||
| 1919 | 1919 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
| 1920 | 1920 | } |
| 1921 | 1921 | } |
| 1922 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 1922 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1923 | 1923 | try { |
| 1924 | 1924 | $sth = $this->db->prepare($query); |
| 1925 | 1925 | $sth->execute($query_values); |
| 1926 | - } catch(PDOException $e) { |
|
| 1926 | + } catch (PDOException $e) { |
|
| 1927 | 1927 | return "error : ".$e->getMessage(); |
| 1928 | 1928 | } |
| 1929 | 1929 | } |
| 1930 | 1930 | } |
| 1931 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
| 1931 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
| 1932 | 1932 | global $globalDBdriver; |
| 1933 | 1933 | if ($airport_icao != '') { |
| 1934 | 1934 | if ($globalDBdriver == 'mysql') { |
@@ -1936,11 +1936,11 @@ discard block |
||
| 1936 | 1936 | } else { |
| 1937 | 1937 | $query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
| 1938 | 1938 | } |
| 1939 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
| 1939 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
| 1940 | 1940 | try { |
| 1941 | 1941 | $sth = $this->db->prepare($query); |
| 1942 | 1942 | $sth->execute($query_values); |
| 1943 | - } catch(PDOException $e) { |
|
| 1943 | + } catch (PDOException $e) { |
|
| 1944 | 1944 | return "error : ".$e->getMessage(); |
| 1945 | 1945 | } |
| 1946 | 1946 | } |
@@ -1952,7 +1952,7 @@ discard block |
||
| 1952 | 1952 | try { |
| 1953 | 1953 | $sth = $this->db->prepare($query); |
| 1954 | 1954 | $sth->execute($query_values); |
| 1955 | - } catch(PDOException $e) { |
|
| 1955 | + } catch (PDOException $e) { |
|
| 1956 | 1956 | return "error : ".$e->getMessage(); |
| 1957 | 1957 | } |
| 1958 | 1958 | } |
@@ -1962,7 +1962,7 @@ discard block |
||
| 1962 | 1962 | try { |
| 1963 | 1963 | $sth = $this->db->prepare($query); |
| 1964 | 1964 | $sth->execute($query_values); |
| 1965 | - } catch(PDOException $e) { |
|
| 1965 | + } catch (PDOException $e) { |
|
| 1966 | 1966 | return "error : ".$e->getMessage(); |
| 1967 | 1967 | } |
| 1968 | 1968 | } |
@@ -1972,13 +1972,13 @@ discard block |
||
| 1972 | 1972 | try { |
| 1973 | 1973 | $sth = $this->db->prepare($query); |
| 1974 | 1974 | $sth->execute($query_values); |
| 1975 | - } catch(PDOException $e) { |
|
| 1975 | + } catch (PDOException $e) { |
|
| 1976 | 1976 | return "error : ".$e->getMessage(); |
| 1977 | 1977 | } |
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | 1980 | public function addOldStats() { |
| 1981 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
| 1981 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents; |
|
| 1982 | 1982 | $Common = new Common(); |
| 1983 | 1983 | $Connection = new Connection($this->db); |
| 1984 | 1984 | date_default_timezone_set('UTC'); |
@@ -1996,41 +1996,41 @@ discard block |
||
| 1996 | 1996 | $Spotter = new Spotter($this->db); |
| 1997 | 1997 | |
| 1998 | 1998 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
| 1999 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
| 1999 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
| 2000 | 2000 | foreach ($alldata as $number) { |
| 2001 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
|
| 2001 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset); |
|
| 2002 | 2002 | } |
| 2003 | 2003 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
| 2004 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
| 2004 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
| 2005 | 2005 | foreach ($alldata as $number) { |
| 2006 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
|
| 2006 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset); |
|
| 2007 | 2007 | } |
| 2008 | 2008 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
| 2009 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
| 2009 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
| 2010 | 2010 | foreach ($alldata as $number) { |
| 2011 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
|
| 2011 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset); |
|
| 2012 | 2012 | } |
| 2013 | 2013 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
| 2014 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
| 2014 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
| 2015 | 2015 | foreach ($alldata as $number) { |
| 2016 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2016 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2017 | 2017 | } |
| 2018 | 2018 | if ($globalDebug) echo 'Count all owners...'."\n"; |
| 2019 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
| 2019 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
| 2020 | 2020 | foreach ($alldata as $number) { |
| 2021 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
|
| 2021 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset); |
|
| 2022 | 2022 | } |
| 2023 | 2023 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
| 2024 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
| 2024 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
| 2025 | 2025 | foreach ($alldata as $number) { |
| 2026 | 2026 | if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
| 2027 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
|
| 2027 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset); |
|
| 2028 | 2028 | } |
| 2029 | 2029 | |
| 2030 | 2030 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
| 2031 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
| 2031 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
| 2032 | 2032 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
| 2033 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
| 2033 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
| 2034 | 2034 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
| 2035 | 2035 | $alldata = array(); |
| 2036 | 2036 | foreach ($pall as $value) { |
@@ -2047,14 +2047,14 @@ discard block |
||
| 2047 | 2047 | foreach ($alldata as $key => $row) { |
| 2048 | 2048 | $count[$key] = $row['airport_departure_icao_count']; |
| 2049 | 2049 | } |
| 2050 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2050 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2051 | 2051 | foreach ($alldata as $number) { |
| 2052 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
|
| 2052 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset); |
|
| 2053 | 2053 | } |
| 2054 | 2054 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
| 2055 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
| 2055 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
| 2056 | 2056 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
| 2057 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
| 2057 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
| 2058 | 2058 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
| 2059 | 2059 | $alldata = array(); |
| 2060 | 2060 | foreach ($pall as $value) { |
@@ -2071,18 +2071,18 @@ discard block |
||
| 2071 | 2071 | foreach ($alldata as $key => $row) { |
| 2072 | 2072 | $count[$key] = $row['airport_arrival_icao_count']; |
| 2073 | 2073 | } |
| 2074 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2074 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2075 | 2075 | foreach ($alldata as $number) { |
| 2076 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
|
| 2076 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset); |
|
| 2077 | 2077 | } |
| 2078 | 2078 | if ($Connection->tableExists('countries')) { |
| 2079 | 2079 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
| 2080 | 2080 | //$SpotterArchive = new SpotterArchive(); |
| 2081 | 2081 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 2082 | 2082 | $Spotter = new Spotter($this->db); |
| 2083 | - $alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day); |
|
| 2083 | + $alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day); |
|
| 2084 | 2084 | foreach ($alldata as $number) { |
| 2085 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset); |
|
| 2085 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset); |
|
| 2086 | 2086 | } |
| 2087 | 2087 | } |
| 2088 | 2088 | |
@@ -2092,12 +2092,12 @@ discard block |
||
| 2092 | 2092 | $this->deleteStatsByType('fatalities_byyear'); |
| 2093 | 2093 | $alldata = $Accident->countFatalitiesByYear(); |
| 2094 | 2094 | foreach ($alldata as $number) { |
| 2095 | - $this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year']))); |
|
| 2095 | + $this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year']))); |
|
| 2096 | 2096 | } |
| 2097 | 2097 | $this->deleteStatsByType('fatalities_bymonth'); |
| 2098 | 2098 | $alldata = $Accident->countFatalitiesLast12Months(); |
| 2099 | 2099 | foreach ($alldata as $number) { |
| 2100 | - $this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year']))); |
|
| 2100 | + $this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year']))); |
|
| 2101 | 2101 | } |
| 2102 | 2102 | } |
| 2103 | 2103 | |
@@ -2111,37 +2111,37 @@ discard block |
||
| 2111 | 2111 | $lastyear = false; |
| 2112 | 2112 | foreach ($alldata as $number) { |
| 2113 | 2113 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2114 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2114 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2115 | 2115 | } |
| 2116 | 2116 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
| 2117 | 2117 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
| 2118 | 2118 | foreach ($alldata as $number) { |
| 2119 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2119 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2120 | 2120 | } |
| 2121 | 2121 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
| 2122 | 2122 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
| 2123 | 2123 | foreach ($alldata as $number) { |
| 2124 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2124 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2125 | 2125 | } |
| 2126 | 2126 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
| 2127 | 2127 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
| 2128 | 2128 | foreach ($alldata as $number) { |
| 2129 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2129 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2130 | 2130 | } |
| 2131 | 2131 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
| 2132 | 2132 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
| 2133 | 2133 | foreach ($alldata as $number) { |
| 2134 | - $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2134 | + $this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2135 | 2135 | } |
| 2136 | 2136 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
| 2137 | 2137 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
| 2138 | 2138 | foreach ($alldata as $number) { |
| 2139 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2139 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2140 | 2140 | } |
| 2141 | 2141 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
| 2142 | 2142 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
| 2143 | 2143 | foreach ($alldata as $number) { |
| 2144 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
| 2144 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
| 2145 | 2145 | } |
| 2146 | 2146 | if ($globalDebug) echo 'Airports data...'."\n"; |
| 2147 | 2147 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -2186,7 +2186,7 @@ discard block |
||
| 2186 | 2186 | } |
| 2187 | 2187 | $alldata = $pall; |
| 2188 | 2188 | foreach ($alldata as $number) { |
| 2189 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
| 2189 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
| 2190 | 2190 | } |
| 2191 | 2191 | echo '...Arrival'."\n"; |
| 2192 | 2192 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -2227,7 +2227,7 @@ discard block |
||
| 2227 | 2227 | } |
| 2228 | 2228 | $alldata = $pall; |
| 2229 | 2229 | foreach ($alldata as $number) { |
| 2230 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
| 2230 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | echo 'Flights data...'."\n"; |
@@ -2235,28 +2235,28 @@ discard block |
||
| 2235 | 2235 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2236 | 2236 | $alldata = $Spotter->countAllDatesLastMonth($filter_last_month); |
| 2237 | 2237 | foreach ($alldata as $number) { |
| 2238 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
| 2238 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
| 2239 | 2239 | } |
| 2240 | 2240 | echo '-> countAllDates...'."\n"; |
| 2241 | 2241 | $previousdata = $this->countAllDates(); |
| 2242 | 2242 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
| 2243 | 2243 | $this->deleteStatFlight('date'); |
| 2244 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month)); |
|
| 2244 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month)); |
|
| 2245 | 2245 | $values = array(); |
| 2246 | 2246 | foreach ($alldata as $cnt) { |
| 2247 | 2247 | $values[] = $cnt['date_count']; |
| 2248 | 2248 | } |
| 2249 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2250 | - array_splice($alldata,11); |
|
| 2249 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2250 | + array_splice($alldata, 11); |
|
| 2251 | 2251 | foreach ($alldata as $number) { |
| 2252 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
| 2252 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
| 2253 | 2253 | } |
| 2254 | 2254 | |
| 2255 | 2255 | $this->deleteStatFlight('hour'); |
| 2256 | 2256 | echo '-> countAllHours...'."\n"; |
| 2257 | - $alldata = $Spotter->countAllHours('hour',$filter_last_month); |
|
| 2257 | + $alldata = $Spotter->countAllHours('hour', $filter_last_month); |
|
| 2258 | 2258 | foreach ($alldata as $number) { |
| 2259 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
| 2259 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
| 2260 | 2260 | } |
| 2261 | 2261 | |
| 2262 | 2262 | // Count by airlines |
@@ -2265,42 +2265,42 @@ discard block |
||
| 2265 | 2265 | if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
| 2266 | 2266 | $SpotterArchive = new SpotterArchive($this->db); |
| 2267 | 2267 | //$Spotter = new Spotter($this->db); |
| 2268 | - $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
|
| 2268 | + $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day); |
|
| 2269 | 2269 | //$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
| 2270 | 2270 | foreach ($alldata as $number) { |
| 2271 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
|
| 2271 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset); |
|
| 2272 | 2272 | } |
| 2273 | 2273 | } |
| 2274 | 2274 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
| 2275 | 2275 | $Spotter = new Spotter($this->db); |
| 2276 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
| 2276 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
| 2277 | 2277 | foreach ($alldata as $number) { |
| 2278 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
|
| 2278 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset); |
|
| 2279 | 2279 | } |
| 2280 | 2280 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
| 2281 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
| 2281 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
| 2282 | 2282 | foreach ($alldata as $number) { |
| 2283 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
|
| 2283 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset); |
|
| 2284 | 2284 | } |
| 2285 | 2285 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
| 2286 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
| 2286 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
| 2287 | 2287 | foreach ($alldata as $number) { |
| 2288 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2288 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2289 | 2289 | } |
| 2290 | 2290 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
| 2291 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
| 2291 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
| 2292 | 2292 | foreach ($alldata as $number) { |
| 2293 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
|
| 2293 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset); |
|
| 2294 | 2294 | } |
| 2295 | 2295 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
| 2296 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
| 2296 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
| 2297 | 2297 | foreach ($alldata as $number) { |
| 2298 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
|
| 2298 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset); |
|
| 2299 | 2299 | } |
| 2300 | 2300 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
| 2301 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 2301 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 2302 | 2302 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
| 2303 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
| 2303 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
| 2304 | 2304 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
| 2305 | 2305 | //$alldata = array(); |
| 2306 | 2306 | foreach ($dall as $value) { |
@@ -2320,12 +2320,12 @@ discard block |
||
| 2320 | 2320 | } |
| 2321 | 2321 | $alldata = $pall; |
| 2322 | 2322 | foreach ($alldata as $number) { |
| 2323 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2323 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2324 | 2324 | } |
| 2325 | 2325 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
| 2326 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 2326 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 2327 | 2327 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
| 2328 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
| 2328 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
| 2329 | 2329 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
| 2330 | 2330 | //$alldata = array(); |
| 2331 | 2331 | foreach ($dall as $value) { |
@@ -2345,7 +2345,7 @@ discard block |
||
| 2345 | 2345 | } |
| 2346 | 2346 | $alldata = $pall; |
| 2347 | 2347 | foreach ($alldata as $number) { |
| 2348 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2348 | + if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset); |
|
| 2349 | 2349 | } |
| 2350 | 2350 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
| 2351 | 2351 | $Spotter = new Spotter($this->db); |
@@ -2353,27 +2353,27 @@ discard block |
||
| 2353 | 2353 | $lastyear = false; |
| 2354 | 2354 | foreach ($alldata as $number) { |
| 2355 | 2355 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2356 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 2356 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2357 | 2357 | } |
| 2358 | 2358 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
| 2359 | 2359 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
| 2360 | 2360 | foreach ($alldata as $number) { |
| 2361 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 2361 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2362 | 2362 | } |
| 2363 | 2363 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
| 2364 | 2364 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
| 2365 | 2365 | foreach ($alldata as $number) { |
| 2366 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 2366 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2367 | 2367 | } |
| 2368 | 2368 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
| 2369 | 2369 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
| 2370 | 2370 | foreach ($alldata as $number) { |
| 2371 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 2371 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2372 | 2372 | } |
| 2373 | 2373 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
| 2374 | 2374 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
| 2375 | 2375 | foreach ($alldata as $number) { |
| 2376 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
| 2376 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
| 2377 | 2377 | } |
| 2378 | 2378 | if ($globalDebug) echo '...Departure'."\n"; |
| 2379 | 2379 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -2396,7 +2396,7 @@ discard block |
||
| 2396 | 2396 | } |
| 2397 | 2397 | $alldata = $pall; |
| 2398 | 2398 | foreach ($alldata as $number) { |
| 2399 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
|
| 2399 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']); |
|
| 2400 | 2400 | } |
| 2401 | 2401 | if ($globalDebug) echo '...Arrival'."\n"; |
| 2402 | 2402 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -2419,32 +2419,32 @@ discard block |
||
| 2419 | 2419 | } |
| 2420 | 2420 | $alldata = $pall; |
| 2421 | 2421 | foreach ($alldata as $number) { |
| 2422 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
|
| 2422 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']); |
|
| 2423 | 2423 | } |
| 2424 | 2424 | |
| 2425 | 2425 | if ($globalDebug) echo 'Flights data...'."\n"; |
| 2426 | 2426 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
| 2427 | 2427 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
| 2428 | 2428 | foreach ($alldata as $number) { |
| 2429 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
| 2429 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 2430 | 2430 | } |
| 2431 | 2431 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
| 2432 | 2432 | //$previousdata = $this->countAllDatesByAirlines(); |
| 2433 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
|
| 2433 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month)); |
|
| 2434 | 2434 | $values = array(); |
| 2435 | 2435 | foreach ($alldata as $cnt) { |
| 2436 | 2436 | $values[] = $cnt['date_count']; |
| 2437 | 2437 | } |
| 2438 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2439 | - array_splice($alldata,11); |
|
| 2438 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2439 | + array_splice($alldata, 11); |
|
| 2440 | 2440 | foreach ($alldata as $number) { |
| 2441 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
| 2441 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
| 2442 | 2442 | } |
| 2443 | 2443 | |
| 2444 | 2444 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
| 2445 | - $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
|
| 2445 | + $alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month); |
|
| 2446 | 2446 | foreach ($alldata as $number) { |
| 2447 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
| 2447 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
| 2448 | 2448 | } |
| 2449 | 2449 | |
| 2450 | 2450 | // Stats by filters |
@@ -2467,7 +2467,7 @@ discard block |
||
| 2467 | 2467 | $last_update_day = date('Y').'-01-01 00:00:00'; |
| 2468 | 2468 | } |
| 2469 | 2469 | } |
| 2470 | - if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) { |
|
| 2470 | + if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) { |
|
| 2471 | 2471 | $last_update_day = date('Y').'-01-01 00:00:00'; |
| 2472 | 2472 | $reset = true; |
| 2473 | 2473 | } |
@@ -2476,32 +2476,32 @@ discard block |
||
| 2476 | 2476 | // Count by filter |
| 2477 | 2477 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
| 2478 | 2478 | $Spotter = new Spotter($this->db); |
| 2479 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
| 2479 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
| 2480 | 2480 | foreach ($alldata as $number) { |
| 2481 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
|
| 2481 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset); |
|
| 2482 | 2482 | } |
| 2483 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
| 2483 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
| 2484 | 2484 | foreach ($alldata as $number) { |
| 2485 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
|
| 2485 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset); |
|
| 2486 | 2486 | } |
| 2487 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
| 2487 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
| 2488 | 2488 | foreach ($alldata as $number) { |
| 2489 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
|
| 2489 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset); |
|
| 2490 | 2490 | } |
| 2491 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
| 2491 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
| 2492 | 2492 | foreach ($alldata as $number) { |
| 2493 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
|
| 2493 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset); |
|
| 2494 | 2494 | } |
| 2495 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
| 2495 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
| 2496 | 2496 | foreach ($alldata as $number) { |
| 2497 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
|
| 2497 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset); |
|
| 2498 | 2498 | } |
| 2499 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
| 2499 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
| 2500 | 2500 | foreach ($alldata as $number) { |
| 2501 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
|
| 2501 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset); |
|
| 2502 | 2502 | } |
| 2503 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
| 2504 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
| 2503 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 2504 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
| 2505 | 2505 | $alldata = array(); |
| 2506 | 2506 | foreach ($pall as $value) { |
| 2507 | 2507 | $icao = $value['airport_departure_icao']; |
@@ -2517,12 +2517,12 @@ discard block |
||
| 2517 | 2517 | foreach ($alldata as $key => $row) { |
| 2518 | 2518 | $count[$key] = $row['airport_departure_icao_count']; |
| 2519 | 2519 | } |
| 2520 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2520 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2521 | 2521 | foreach ($alldata as $number) { |
| 2522 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
| 2522 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset); |
|
| 2523 | 2523 | } |
| 2524 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 2525 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
| 2524 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 2525 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
| 2526 | 2526 | $alldata = array(); |
| 2527 | 2527 | foreach ($pall as $value) { |
| 2528 | 2528 | $icao = $value['airport_arrival_icao']; |
@@ -2538,40 +2538,40 @@ discard block |
||
| 2538 | 2538 | foreach ($alldata as $key => $row) { |
| 2539 | 2539 | $count[$key] = $row['airport_arrival_icao_count']; |
| 2540 | 2540 | } |
| 2541 | - array_multisort($count,SORT_DESC,$alldata); |
|
| 2541 | + array_multisort($count, SORT_DESC, $alldata); |
|
| 2542 | 2542 | foreach ($alldata as $number) { |
| 2543 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
|
| 2543 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset); |
|
| 2544 | 2544 | } |
| 2545 | 2545 | $Spotter = new Spotter($this->db); |
| 2546 | 2546 | $alldata = $Spotter->countAllMonths($filter); |
| 2547 | 2547 | $lastyear = false; |
| 2548 | 2548 | foreach ($alldata as $number) { |
| 2549 | 2549 | if ($number['year_name'] != date('Y')) $lastyear = true; |
| 2550 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 2550 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2551 | 2551 | } |
| 2552 | 2552 | $alldata = $Spotter->countAllMonthsOwners($filter); |
| 2553 | 2553 | foreach ($alldata as $number) { |
| 2554 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 2554 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2555 | 2555 | } |
| 2556 | 2556 | $alldata = $Spotter->countAllMonthsPilots($filter); |
| 2557 | 2557 | foreach ($alldata as $number) { |
| 2558 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 2558 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2559 | 2559 | } |
| 2560 | 2560 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
| 2561 | 2561 | foreach ($alldata as $number) { |
| 2562 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 2562 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2563 | 2563 | } |
| 2564 | 2564 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 2565 | 2565 | foreach ($alldata as $number) { |
| 2566 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 2566 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2567 | 2567 | } |
| 2568 | 2568 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
| 2569 | 2569 | foreach ($alldata as $number) { |
| 2570 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
| 2570 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
| 2571 | 2571 | } |
| 2572 | 2572 | echo '...Departure'."\n"; |
| 2573 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
| 2574 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
| 2573 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
| 2574 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
| 2575 | 2575 | foreach ($dall as $value) { |
| 2576 | 2576 | $icao = $value['departure_airport_icao']; |
| 2577 | 2577 | $ddate = $value['date']; |
@@ -2589,11 +2589,11 @@ discard block |
||
| 2589 | 2589 | } |
| 2590 | 2590 | $alldata = $pall; |
| 2591 | 2591 | foreach ($alldata as $number) { |
| 2592 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
| 2592 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
| 2593 | 2593 | } |
| 2594 | 2594 | echo '...Arrival'."\n"; |
| 2595 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
| 2596 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
| 2595 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
| 2596 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
| 2597 | 2597 | foreach ($dall as $value) { |
| 2598 | 2598 | $icao = $value['arrival_airport_icao']; |
| 2599 | 2599 | $ddate = $value['date']; |
@@ -2611,39 +2611,39 @@ discard block |
||
| 2611 | 2611 | } |
| 2612 | 2612 | $alldata = $pall; |
| 2613 | 2613 | foreach ($alldata as $number) { |
| 2614 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
| 2614 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
| 2615 | 2615 | } |
| 2616 | 2616 | echo 'Flights data...'."\n"; |
| 2617 | 2617 | echo '-> countAllDatesLastMonth...'."\n"; |
| 2618 | 2618 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
| 2619 | 2619 | foreach ($alldata as $number) { |
| 2620 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
| 2620 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 2621 | 2621 | } |
| 2622 | 2622 | echo '-> countAllDates...'."\n"; |
| 2623 | - $previousdata = $this->countAllDates('',$filter_name); |
|
| 2624 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
| 2623 | + $previousdata = $this->countAllDates('', $filter_name); |
|
| 2624 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
| 2625 | 2625 | $values = array(); |
| 2626 | 2626 | foreach ($alldata as $cnt) { |
| 2627 | 2627 | $values[] = $cnt['date_count']; |
| 2628 | 2628 | } |
| 2629 | - array_multisort($values,SORT_DESC,$alldata); |
|
| 2630 | - array_splice($alldata,11); |
|
| 2629 | + array_multisort($values, SORT_DESC, $alldata); |
|
| 2630 | + array_splice($alldata, 11); |
|
| 2631 | 2631 | foreach ($alldata as $number) { |
| 2632 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
| 2632 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
| 2633 | 2633 | } |
| 2634 | 2634 | |
| 2635 | 2635 | echo '-> countAllHours...'."\n"; |
| 2636 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
| 2636 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
| 2637 | 2637 | foreach ($alldata as $number) { |
| 2638 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
| 2638 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
| 2639 | 2639 | } |
| 2640 | 2640 | echo 'Insert last stats update date...'."\n"; |
| 2641 | 2641 | date_default_timezone_set('UTC'); |
| 2642 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
| 2642 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
| 2643 | 2643 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
| 2644 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
| 2644 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
| 2645 | 2645 | $this->deleteOldStats($filter_name); |
| 2646 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
| 2646 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
| 2647 | 2647 | } |
| 2648 | 2648 | } |
| 2649 | 2649 | } |
@@ -2654,16 +2654,16 @@ discard block |
||
| 2654 | 2654 | // SUM all previous month to put as year |
| 2655 | 2655 | $previous_year = date('Y'); |
| 2656 | 2656 | $previous_year--; |
| 2657 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2658 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2659 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2660 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
| 2657 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2658 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2659 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2660 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
| 2661 | 2661 | $allairlines = $this->getAllAirlineNames(); |
| 2662 | 2662 | foreach ($allairlines as $data) { |
| 2663 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2664 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2665 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2666 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
| 2663 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2664 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2665 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2666 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
| 2667 | 2667 | } |
| 2668 | 2668 | |
| 2669 | 2669 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -2672,7 +2672,7 @@ discard block |
||
| 2672 | 2672 | try { |
| 2673 | 2673 | $sth = $this->db->prepare($query); |
| 2674 | 2674 | $sth->execute(); |
| 2675 | - } catch(PDOException $e) { |
|
| 2675 | + } catch (PDOException $e) { |
|
| 2676 | 2676 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 2677 | 2677 | } |
| 2678 | 2678 | } |
@@ -2681,15 +2681,15 @@ discard block |
||
| 2681 | 2681 | try { |
| 2682 | 2682 | $sth = $this->db->prepare($query); |
| 2683 | 2683 | $sth->execute(); |
| 2684 | - } catch(PDOException $e) { |
|
| 2684 | + } catch (PDOException $e) { |
|
| 2685 | 2685 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
| 2686 | 2686 | } |
| 2687 | 2687 | } |
| 2688 | 2688 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
| 2689 | 2689 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 2690 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 2690 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
| 2691 | 2691 | $this->deleteOldStats(); |
| 2692 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
| 2692 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
| 2693 | 2693 | $lastyearupdate = true; |
| 2694 | 2694 | } |
| 2695 | 2695 | } |
@@ -2711,7 +2711,7 @@ discard block |
||
| 2711 | 2711 | try { |
| 2712 | 2712 | $sth = $this->db->prepare($query); |
| 2713 | 2713 | $sth->execute(); |
| 2714 | - } catch(PDOException $e) { |
|
| 2714 | + } catch (PDOException $e) { |
|
| 2715 | 2715 | return "error : ".$e->getMessage(); |
| 2716 | 2716 | } |
| 2717 | 2717 | } |
@@ -2725,14 +2725,14 @@ discard block |
||
| 2725 | 2725 | try { |
| 2726 | 2726 | $sth = $this->db->prepare($query); |
| 2727 | 2727 | $sth->execute(); |
| 2728 | - } catch(PDOException $e) { |
|
| 2728 | + } catch (PDOException $e) { |
|
| 2729 | 2729 | return "error : ".$e->getMessage(); |
| 2730 | 2730 | } |
| 2731 | 2731 | } |
| 2732 | 2732 | if (!isset($lastyearupdate)) { |
| 2733 | 2733 | echo 'Insert last stats update date...'."\n"; |
| 2734 | 2734 | date_default_timezone_set('UTC'); |
| 2735 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
| 2735 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
| 2736 | 2736 | } |
| 2737 | 2737 | if ($globalStatsResetYear) { |
| 2738 | 2738 | require_once(dirname(__FILE__).'/../install/class.settings.php'); |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 5 | 5 | $global_query = "SELECT tracker_output.* FROM tracker_output"; |
| 6 | 6 | |
| 7 | -class Tracker{ |
|
| 7 | +class Tracker { |
|
| 8 | 8 | public $db; |
| 9 | 9 | |
| 10 | 10 | public function __construct($dbc = null) { |
@@ -19,33 +19,33 @@ discard block |
||
| 19 | 19 | * @return Array the SQL part |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 22 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 23 | 23 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 24 | 24 | $filters = array(); |
| 25 | 25 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 26 | 26 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 27 | 27 | $filters = $globalStatsFilters[$globalFilterName]; |
| 28 | 28 | } else { |
| 29 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 29 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | if (isset($filter[0]['source'])) { |
| 33 | - $filters = array_merge($filters,$filter); |
|
| 33 | + $filters = array_merge($filters, $filter); |
|
| 34 | 34 | } |
| 35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 36 | 36 | $filter_query_join = ''; |
| 37 | 37 | $filter_query_where = ''; |
| 38 | - foreach($filters as $flt) { |
|
| 38 | + foreach ($filters as $flt) { |
|
| 39 | 39 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 40 | 40 | if (isset($flt['source'])) { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
| 42 | 42 | } else { |
| 43 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
| 43 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 48 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 48 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 49 | 49 | } |
| 50 | 50 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 51 | 51 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 75 | 75 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 76 | 76 | if ($filter_query_where != '') { |
| 77 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 77 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 78 | 78 | } |
| 79 | 79 | $filter_query = $filter_query_join.$filter_query_where; |
| 80 | 80 | return $filter_query; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @return Array the spotter information |
| 90 | 90 | * |
| 91 | 91 | */ |
| 92 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 92 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 93 | 93 | { |
| 94 | 94 | date_default_timezone_set('UTC'); |
| 95 | 95 | if (!is_string($query)) |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | $sth = $this->db->prepare($query.$limitQuery); |
| 110 | 110 | $sth->execute($params); |
| 111 | 111 | } catch (PDOException $e) { |
| 112 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 112 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 113 | 113 | exit(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $num_rows = 0; |
| 117 | 117 | $spotter_array = array(); |
| 118 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 118 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 119 | 119 | { |
| 120 | 120 | $num_rows++; |
| 121 | 121 | $temp_array = array(); |
@@ -171,17 +171,17 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 173 | 173 | } else { |
| 174 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 174 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 175 | 175 | } |
| 176 | 176 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 177 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 178 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 177 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 178 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 179 | 179 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 180 | 180 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 181 | 181 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 182 | 182 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 183 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 184 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 183 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 184 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 185 | 185 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | { |
| 219 | 219 | $limit_array = explode(",", $limit); |
| 220 | 220 | |
| 221 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 222 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 221 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 222 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 223 | 223 | |
| 224 | 224 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 225 | 225 | { |
@@ -236,9 +236,9 @@ discard block |
||
| 236 | 236 | $orderby_query = " ORDER BY tracker_output.date DESC"; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 239 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 240 | 240 | |
| 241 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 241 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 242 | 242 | |
| 243 | 243 | return $spotter_array; |
| 244 | 244 | } |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | if ($id == '') return array(); |
| 258 | 258 | $additional_query = "tracker_output.famtrackid = :id"; |
| 259 | 259 | $query_values = array(':id' => $id); |
| 260 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 261 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 260 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 261 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 262 | 262 | return $spotter_array; |
| 263 | 263 | } |
| 264 | 264 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | $query_values = array(); |
| 278 | 278 | $limit_query = ''; |
| 279 | 279 | $additional_query = ''; |
| 280 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 280 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 281 | 281 | if ($ident != "") |
| 282 | 282 | { |
| 283 | 283 | if (!is_string($ident)) |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | { |
| 294 | 294 | $limit_array = explode(",", $limit); |
| 295 | 295 | |
| 296 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 297 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 296 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 297 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 298 | 298 | |
| 299 | 299 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 300 | 300 | { |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | return $spotter_array; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 321 | + public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 322 | 322 | { |
| 323 | 323 | global $global_query, $globalTimezone, $globalDBdriver; |
| 324 | 324 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $limit_query = ''; |
| 327 | 327 | $additional_query = ''; |
| 328 | 328 | |
| 329 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 329 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 330 | 330 | |
| 331 | 331 | if ($date != "") |
| 332 | 332 | { |
@@ -352,8 +352,8 @@ discard block |
||
| 352 | 352 | { |
| 353 | 353 | $limit_array = explode(",", $limit); |
| 354 | 354 | |
| 355 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 356 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 355 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 356 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 357 | 357 | |
| 358 | 358 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 359 | 359 | { |
@@ -384,11 +384,11 @@ discard block |
||
| 384 | 384 | * @return Array list of source name |
| 385 | 385 | * |
| 386 | 386 | */ |
| 387 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 387 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 388 | 388 | { |
| 389 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 389 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 390 | 390 | $query_values = array(); |
| 391 | - $query = "SELECT DISTINCT tracker_output.source_name |
|
| 391 | + $query = "SELECT DISTINCT tracker_output.source_name |
|
| 392 | 392 | FROM tracker_output".$filter_query." tracker_output.source_name <> ''"; |
| 393 | 393 | if ($type != '') { |
| 394 | 394 | $query_values = array(':type' => $type); |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | $source_array = array(); |
| 404 | 404 | $temp_array = array(); |
| 405 | 405 | |
| 406 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 406 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 407 | 407 | { |
| 408 | 408 | $temp_array['source_name'] = $row['source_name']; |
| 409 | 409 | $source_array[] = $temp_array; |
@@ -420,8 +420,8 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | public function getAllIdents($filters = array()) |
| 422 | 422 | { |
| 423 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 424 | - $query = "SELECT DISTINCT tracker_output.ident |
|
| 423 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 424 | + $query = "SELECT DISTINCT tracker_output.ident |
|
| 425 | 425 | FROM tracker_output".$filter_query." tracker_output.ident <> '' |
| 426 | 426 | ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0"; |
| 427 | 427 | |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | $ident_array = array(); |
| 432 | 432 | $temp_array = array(); |
| 433 | 433 | |
| 434 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 434 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 435 | 435 | { |
| 436 | 436 | $temp_array['ident'] = $row['ident']; |
| 437 | 437 | $ident_array[] = $temp_array; |
@@ -456,12 +456,12 @@ discard block |
||
| 456 | 456 | } else $offset = '+00:00'; |
| 457 | 457 | |
| 458 | 458 | if ($globalDBdriver == 'mysql') { |
| 459 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
| 459 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
| 460 | 460 | FROM tracker_output |
| 461 | 461 | WHERE tracker_output.date <> '' |
| 462 | 462 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
| 463 | 463 | } else { |
| 464 | - $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 464 | + $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 465 | 465 | FROM tracker_output |
| 466 | 466 | WHERE tracker_output.date <> '' |
| 467 | 467 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | $date_array = array(); |
| 474 | 474 | $temp_array = array(); |
| 475 | 475 | |
| 476 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 476 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 477 | 477 | { |
| 478 | 478 | $temp_array['date'] = $row['date']; |
| 479 | 479 | |
@@ -492,11 +492,11 @@ discard block |
||
| 492 | 492 | * @return String success or false |
| 493 | 493 | * |
| 494 | 494 | */ |
| 495 | - public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
|
| 495 | + public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL) |
|
| 496 | 496 | { |
| 497 | 497 | |
| 498 | 498 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
| 499 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
| 499 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident); |
|
| 500 | 500 | |
| 501 | 501 | try { |
| 502 | 502 | $sth = $this->db->prepare($query); |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
| 521 | 521 | { |
| 522 | 522 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
| 523 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 523 | + $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 524 | 524 | |
| 525 | 525 | try { |
| 526 | 526 | $sth = $this->db->prepare($query); |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | * @param String $verticalrate vertival rate of flight |
| 561 | 561 | * @return String success or false |
| 562 | 562 | */ |
| 563 | - public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
|
| 563 | + public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '') |
|
| 564 | 564 | { |
| 565 | 565 | global $globalURL; |
| 566 | 566 | |
@@ -628,21 +628,21 @@ discard block |
||
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | |
| 631 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 631 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 632 | 632 | { |
| 633 | 633 | $date = date("Y-m-d H:i:s", time()); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
| 637 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 638 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 639 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 640 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 641 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 642 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 643 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 644 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
| 645 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 636 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
| 637 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 638 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 639 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 640 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 641 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 642 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 643 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 644 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
| 645 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 646 | 646 | |
| 647 | 647 | if ($latitude == '' && $longitude == '') { |
| 648 | 648 | $latitude = 0; |
@@ -650,10 +650,10 @@ discard block |
||
| 650 | 650 | } |
| 651 | 651 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 652 | 652 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 653 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
| 653 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
| 654 | 654 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
| 655 | 655 | |
| 656 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
| 656 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type); |
|
| 657 | 657 | |
| 658 | 658 | try { |
| 659 | 659 | |
@@ -679,13 +679,13 @@ discard block |
||
| 679 | 679 | { |
| 680 | 680 | global $globalDBdriver, $globalTimezone; |
| 681 | 681 | if ($globalDBdriver == 'mysql') { |
| 682 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
| 682 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
| 683 | 683 | WHERE tracker_output.ident = :ident |
| 684 | 684 | AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 685 | 685 | AND tracker_output.date < UTC_TIMESTAMP()"; |
| 686 | 686 | $query_data = array(':ident' => $ident); |
| 687 | 687 | } else { |
| 688 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
| 688 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
| 689 | 689 | WHERE tracker_output.ident = :ident |
| 690 | 690 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 691 | 691 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -694,8 +694,8 @@ discard block |
||
| 694 | 694 | |
| 695 | 695 | $sth = $this->db->prepare($query); |
| 696 | 696 | $sth->execute($query_data); |
| 697 | - $ident_result=''; |
|
| 698 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 697 | + $ident_result = ''; |
|
| 698 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 699 | 699 | { |
| 700 | 700 | $ident_result = $row['ident']; |
| 701 | 701 | } |
@@ -721,8 +721,8 @@ discard block |
||
| 721 | 721 | return false; |
| 722 | 722 | } else { |
| 723 | 723 | $q_array = explode(" ", $q); |
| 724 | - foreach ($q_array as $q_item){ |
|
| 725 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 724 | + foreach ($q_array as $q_item) { |
|
| 725 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 726 | 726 | $additional_query .= " AND ("; |
| 727 | 727 | $additional_query .= "(tracker_output.ident like '%".$q_item."%')"; |
| 728 | 728 | $additional_query .= ")"; |
@@ -730,11 +730,11 @@ discard block |
||
| 730 | 730 | } |
| 731 | 731 | } |
| 732 | 732 | if ($globalDBdriver == 'mysql') { |
| 733 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
| 733 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
| 734 | 734 | WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 735 | 735 | AND tracker_output.date < UTC_TIMESTAMP()"; |
| 736 | 736 | } else { |
| 737 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
| 737 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
| 738 | 738 | WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 739 | 739 | AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 740 | 740 | } |
@@ -753,16 +753,16 @@ discard block |
||
| 753 | 753 | * |
| 754 | 754 | */ |
| 755 | 755 | |
| 756 | - public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 756 | + public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 757 | 757 | { |
| 758 | 758 | global $globalDBdriver, $globalArchive; |
| 759 | 759 | //$filter_query = $this->getFilter($filters,true,true); |
| 760 | - $Connection= new Connection($this->db); |
|
| 760 | + $Connection = new Connection($this->db); |
|
| 761 | 761 | if (!$Connection->tableExists('countries')) return array(); |
| 762 | 762 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 763 | 763 | require_once('class.TrackerLive.php'); |
| 764 | 764 | $TrackerLive = new TrackerLive($this->db); |
| 765 | - $filter_query = $TrackerLive->getFilter($filters,true,true); |
|
| 765 | + $filter_query = $TrackerLive->getFilter($filters, true, true); |
|
| 766 | 766 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 767 | 767 | if ($olderthanmonths > 0) { |
| 768 | 768 | if ($globalDBdriver == 'mysql') { |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | } else { |
| 783 | 783 | require_once('class.TrackerArchive.php'); |
| 784 | 784 | $TrackerArchive = new TrackerArchive($this->db); |
| 785 | - $filter_query = $TrackerArchive->getFilter($filters,true,true); |
|
| 785 | + $filter_query = $TrackerArchive->getFilter($filters, true, true); |
|
| 786 | 786 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 787 | 787 | if ($olderthanmonths > 0) { |
| 788 | 788 | if ($globalDBdriver == 'mysql') { |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | $flight_array = array(); |
| 811 | 811 | $temp_array = array(); |
| 812 | 812 | |
| 813 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 813 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 814 | 814 | { |
| 815 | 815 | $temp_array['flight_count'] = $row['nb']; |
| 816 | 816 | $temp_array['flight_country'] = $row['name']; |
@@ -827,11 +827,11 @@ discard block |
||
| 827 | 827 | * @return Array the callsign list |
| 828 | 828 | * |
| 829 | 829 | */ |
| 830 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 830 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 831 | 831 | { |
| 832 | 832 | global $globalDBdriver; |
| 833 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 834 | - $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
| 833 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 834 | + $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
| 835 | 835 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
| 836 | 836 | if ($olderthanmonths > 0) { |
| 837 | 837 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -845,28 +845,28 @@ discard block |
||
| 845 | 845 | if ($year != '') { |
| 846 | 846 | if ($globalDBdriver == 'mysql') { |
| 847 | 847 | $query .= " AND YEAR(tracker_output.date) = :year"; |
| 848 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 848 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 849 | 849 | } else { |
| 850 | 850 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
| 851 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 851 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 852 | 852 | } |
| 853 | 853 | } |
| 854 | 854 | if ($month != '') { |
| 855 | 855 | if ($globalDBdriver == 'mysql') { |
| 856 | 856 | $query .= " AND MONTH(tracker_output.date) = :month"; |
| 857 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 857 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 858 | 858 | } else { |
| 859 | 859 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
| 860 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 860 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | 863 | if ($day != '') { |
| 864 | 864 | if ($globalDBdriver == 'mysql') { |
| 865 | 865 | $query .= " AND DAY(tracker_output.date) = :day"; |
| 866 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 866 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 867 | 867 | } else { |
| 868 | 868 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
| 869 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 869 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | $callsign_array = array(); |
| 879 | 879 | $temp_array = array(); |
| 880 | 880 | |
| 881 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 881 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 882 | 882 | { |
| 883 | 883 | $temp_array['callsign_icao'] = $row['ident']; |
| 884 | 884 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | $date_array = array(); |
| 931 | 931 | $temp_array = array(); |
| 932 | 932 | |
| 933 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 933 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 934 | 934 | { |
| 935 | 935 | $temp_array['date_name'] = $row['date_name']; |
| 936 | 936 | $temp_array['date_count'] = $row['date_count']; |
@@ -956,7 +956,7 @@ discard block |
||
| 956 | 956 | $datetime = new DateTime(); |
| 957 | 957 | $offset = $datetime->format('P'); |
| 958 | 958 | } else $offset = '+00:00'; |
| 959 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 959 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 960 | 960 | if ($globalDBdriver == 'mysql') { |
| 961 | 961 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 962 | 962 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | $date_array = array(); |
| 978 | 978 | $temp_array = array(); |
| 979 | 979 | |
| 980 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 980 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 981 | 981 | { |
| 982 | 982 | $temp_array['date_name'] = $row['date_name']; |
| 983 | 983 | $temp_array['date_count'] = $row['date_count']; |
@@ -1002,7 +1002,7 @@ discard block |
||
| 1002 | 1002 | $datetime = new DateTime(); |
| 1003 | 1003 | $offset = $datetime->format('P'); |
| 1004 | 1004 | } else $offset = '+00:00'; |
| 1005 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1005 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1006 | 1006 | if ($globalDBdriver == 'mysql') { |
| 1007 | 1007 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1008 | 1008 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | $date_array = array(); |
| 1024 | 1024 | $temp_array = array(); |
| 1025 | 1025 | |
| 1026 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1026 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1027 | 1027 | { |
| 1028 | 1028 | $temp_array['date_name'] = $row['date_name']; |
| 1029 | 1029 | $temp_array['date_count'] = $row['date_count']; |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | $date_array = array(); |
| 1071 | 1071 | $temp_array = array(); |
| 1072 | 1072 | |
| 1073 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1073 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1074 | 1074 | { |
| 1075 | 1075 | $temp_array['month_name'] = $row['month_name']; |
| 1076 | 1076 | $temp_array['year_name'] = $row['year_name']; |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | $datetime = new DateTime(); |
| 1100 | 1100 | $offset = $datetime->format('P'); |
| 1101 | 1101 | } else $offset = '+00:00'; |
| 1102 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1102 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1103 | 1103 | if ($globalDBdriver == 'mysql') { |
| 1104 | 1104 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 1105 | 1105 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1120,7 +1120,7 @@ discard block |
||
| 1120 | 1120 | $date_array = array(); |
| 1121 | 1121 | $temp_array = array(); |
| 1122 | 1122 | |
| 1123 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1123 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1124 | 1124 | { |
| 1125 | 1125 | $temp_array['year_name'] = $row['year_name']; |
| 1126 | 1126 | $temp_array['month_name'] = $row['month_name']; |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | * @return Array the hour list |
| 1141 | 1141 | * |
| 1142 | 1142 | */ |
| 1143 | - public function countAllHours($orderby,$filters = array()) |
|
| 1143 | + public function countAllHours($orderby, $filters = array()) |
|
| 1144 | 1144 | { |
| 1145 | 1145 | global $globalTimezone, $globalDBdriver; |
| 1146 | 1146 | if ($globalTimezone != '') { |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | $hour_array = array(); |
| 1189 | 1189 | $temp_array = array(); |
| 1190 | 1190 | |
| 1191 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1191 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1192 | 1192 | { |
| 1193 | 1193 | $temp_array['hour_name'] = $row['hour_name']; |
| 1194 | 1194 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1210,8 +1210,8 @@ discard block |
||
| 1210 | 1210 | public function countAllHoursByDate($date, $filters = array()) |
| 1211 | 1211 | { |
| 1212 | 1212 | global $globalTimezone, $globalDBdriver; |
| 1213 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1214 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1213 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1214 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1215 | 1215 | if ($globalTimezone != '') { |
| 1216 | 1216 | date_default_timezone_set($globalTimezone); |
| 1217 | 1217 | $datetime = new DateTime($date); |
@@ -1219,12 +1219,12 @@ discard block |
||
| 1219 | 1219 | } else $offset = '+00:00'; |
| 1220 | 1220 | |
| 1221 | 1221 | if ($globalDBdriver == 'mysql') { |
| 1222 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1222 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1223 | 1223 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date |
| 1224 | 1224 | GROUP BY hour_name |
| 1225 | 1225 | ORDER BY hour_name ASC"; |
| 1226 | 1226 | } else { |
| 1227 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1227 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1228 | 1228 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1229 | 1229 | GROUP BY hour_name |
| 1230 | 1230 | ORDER BY hour_name ASC"; |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | $hour_array = array(); |
| 1237 | 1237 | $temp_array = array(); |
| 1238 | 1238 | |
| 1239 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1239 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1240 | 1240 | { |
| 1241 | 1241 | $temp_array['hour_name'] = $row['hour_name']; |
| 1242 | 1242 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1258,8 +1258,8 @@ discard block |
||
| 1258 | 1258 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1259 | 1259 | { |
| 1260 | 1260 | global $globalTimezone, $globalDBdriver; |
| 1261 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1262 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1261 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1262 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1263 | 1263 | if ($globalTimezone != '') { |
| 1264 | 1264 | date_default_timezone_set($globalTimezone); |
| 1265 | 1265 | $datetime = new DateTime(); |
@@ -1267,12 +1267,12 @@ discard block |
||
| 1267 | 1267 | } else $offset = '+00:00'; |
| 1268 | 1268 | |
| 1269 | 1269 | if ($globalDBdriver == 'mysql') { |
| 1270 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1270 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1271 | 1271 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
| 1272 | 1272 | GROUP BY hour_name |
| 1273 | 1273 | ORDER BY hour_name ASC"; |
| 1274 | 1274 | } else { |
| 1275 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1275 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1276 | 1276 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
| 1277 | 1277 | GROUP BY hour_name |
| 1278 | 1278 | ORDER BY hour_name ASC"; |
@@ -1280,12 +1280,12 @@ discard block |
||
| 1280 | 1280 | |
| 1281 | 1281 | |
| 1282 | 1282 | $sth = $this->db->prepare($query); |
| 1283 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1283 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1284 | 1284 | |
| 1285 | 1285 | $hour_array = array(); |
| 1286 | 1286 | $temp_array = array(); |
| 1287 | 1287 | |
| 1288 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1288 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1289 | 1289 | { |
| 1290 | 1290 | $temp_array['hour_name'] = $row['hour_name']; |
| 1291 | 1291 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1304,33 +1304,33 @@ discard block |
||
| 1304 | 1304 | * @return Integer the number of trackers |
| 1305 | 1305 | * |
| 1306 | 1306 | */ |
| 1307 | - public function countOverallTracker($filters = array(),$year = '',$month = '') |
|
| 1307 | + public function countOverallTracker($filters = array(), $year = '', $month = '') |
|
| 1308 | 1308 | { |
| 1309 | 1309 | global $globalDBdriver; |
| 1310 | 1310 | //$queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output"; |
| 1311 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
| 1311 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
| 1312 | 1312 | $query_values = array(); |
| 1313 | 1313 | $query = ''; |
| 1314 | 1314 | if ($year != '') { |
| 1315 | 1315 | if ($globalDBdriver == 'mysql') { |
| 1316 | 1316 | $query .= " AND YEAR(tracker_output.date) = :year"; |
| 1317 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1317 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1318 | 1318 | } else { |
| 1319 | 1319 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
| 1320 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1320 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1321 | 1321 | } |
| 1322 | 1322 | } |
| 1323 | 1323 | if ($month != '') { |
| 1324 | 1324 | if ($globalDBdriver == 'mysql') { |
| 1325 | 1325 | $query .= " AND MONTH(tracker_output.date) = :month"; |
| 1326 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1326 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1327 | 1327 | } else { |
| 1328 | 1328 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
| 1329 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1329 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1330 | 1330 | } |
| 1331 | 1331 | } |
| 1332 | 1332 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1333 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1333 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1334 | 1334 | |
| 1335 | 1335 | $sth = $this->db->prepare($queryi); |
| 1336 | 1336 | $sth->execute($query_values); |
@@ -1343,32 +1343,32 @@ discard block |
||
| 1343 | 1343 | * @return Integer the number of flights |
| 1344 | 1344 | * |
| 1345 | 1345 | */ |
| 1346 | - public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
|
| 1346 | + public function countOverallTrackerTypes($filters = array(), $year = '', $month = '') |
|
| 1347 | 1347 | { |
| 1348 | 1348 | global $globalDBdriver; |
| 1349 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
| 1349 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
| 1350 | 1350 | $query_values = array(); |
| 1351 | 1351 | $query = ''; |
| 1352 | 1352 | if ($year != '') { |
| 1353 | 1353 | if ($globalDBdriver == 'mysql') { |
| 1354 | 1354 | $query .= " AND YEAR(tracker_output.date) = :year"; |
| 1355 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1355 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1356 | 1356 | } else { |
| 1357 | 1357 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
| 1358 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1358 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1359 | 1359 | } |
| 1360 | 1360 | } |
| 1361 | 1361 | if ($month != '') { |
| 1362 | 1362 | if ($globalDBdriver == 'mysql') { |
| 1363 | 1363 | $query .= " AND MONTH(tracker_output.date) = :month"; |
| 1364 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1364 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1365 | 1365 | } else { |
| 1366 | 1366 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
| 1367 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1367 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1368 | 1368 | } |
| 1369 | 1369 | } |
| 1370 | 1370 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1371 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1371 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1372 | 1372 | |
| 1373 | 1373 | $sth = $this->db->prepare($queryi); |
| 1374 | 1374 | $sth->execute($query_values); |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | public function countAllHoursFromToday($filters = array()) |
| 1386 | 1386 | { |
| 1387 | 1387 | global $globalTimezone, $globalDBdriver; |
| 1388 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1388 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1389 | 1389 | if ($globalTimezone != '') { |
| 1390 | 1390 | date_default_timezone_set($globalTimezone); |
| 1391 | 1391 | $datetime = new DateTime(); |
@@ -1393,12 +1393,12 @@ discard block |
||
| 1393 | 1393 | } else $offset = '+00:00'; |
| 1394 | 1394 | |
| 1395 | 1395 | if ($globalDBdriver == 'mysql') { |
| 1396 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1396 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1397 | 1397 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE() |
| 1398 | 1398 | GROUP BY hour_name |
| 1399 | 1399 | ORDER BY hour_name ASC"; |
| 1400 | 1400 | } else { |
| 1401 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1401 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1402 | 1402 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1403 | 1403 | GROUP BY hour_name |
| 1404 | 1404 | ORDER BY hour_name ASC"; |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | $hour_array = array(); |
| 1411 | 1411 | $temp_array = array(); |
| 1412 | 1412 | |
| 1413 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1413 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1414 | 1414 | { |
| 1415 | 1415 | $temp_array['hour_name'] = $row['hour_name']; |
| 1416 | 1416 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1429,9 +1429,9 @@ discard block |
||
| 1429 | 1429 | */ |
| 1430 | 1430 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
| 1431 | 1431 | { |
| 1432 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
| 1432 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
| 1433 | 1433 | |
| 1434 | - $query = "SELECT tracker_output.tracker_id |
|
| 1434 | + $query = "SELECT tracker_output.tracker_id |
|
| 1435 | 1435 | FROM tracker_output |
| 1436 | 1436 | WHERE tracker_output.famtrackid = '".$famtrackid."'"; |
| 1437 | 1437 | |
@@ -1439,7 +1439,7 @@ discard block |
||
| 1439 | 1439 | $sth = $this->db->prepare($query); |
| 1440 | 1440 | $sth->execute(); |
| 1441 | 1441 | |
| 1442 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1442 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1443 | 1443 | { |
| 1444 | 1444 | return $row['tracker_id']; |
| 1445 | 1445 | } |
@@ -1464,23 +1464,23 @@ discard block |
||
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | 1466 | $current_date = date("Y-m-d H:i:s"); |
| 1467 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1467 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1468 | 1468 | |
| 1469 | 1469 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1470 | 1470 | |
| 1471 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1471 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1472 | 1472 | $years = $time_array['years']; |
| 1473 | 1473 | |
| 1474 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1474 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1475 | 1475 | $months = $time_array['months']; |
| 1476 | 1476 | |
| 1477 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1477 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1478 | 1478 | $days = $time_array['days']; |
| 1479 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1479 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1480 | 1480 | $hours = $time_array['hours']; |
| 1481 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1481 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1482 | 1482 | $minutes = $time_array['minutes']; |
| 1483 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1483 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1484 | 1484 | |
| 1485 | 1485 | return $time_array; |
| 1486 | 1486 | } |
@@ -1503,63 +1503,63 @@ discard block |
||
| 1503 | 1503 | $temp_array['direction_degree'] = $direction; |
| 1504 | 1504 | $temp_array['direction_shortname'] = "N"; |
| 1505 | 1505 | $temp_array['direction_fullname'] = "North"; |
| 1506 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1506 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1507 | 1507 | $temp_array['direction_degree'] = $direction; |
| 1508 | 1508 | $temp_array['direction_shortname'] = "NNE"; |
| 1509 | 1509 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1510 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1510 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1511 | 1511 | $temp_array['direction_degree'] = $direction; |
| 1512 | 1512 | $temp_array['direction_shortname'] = "NE"; |
| 1513 | 1513 | $temp_array['direction_fullname'] = "Northeast"; |
| 1514 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1514 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1515 | 1515 | $temp_array['direction_degree'] = $direction; |
| 1516 | 1516 | $temp_array['direction_shortname'] = "ENE"; |
| 1517 | 1517 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1518 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1518 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1519 | 1519 | $temp_array['direction_degree'] = $direction; |
| 1520 | 1520 | $temp_array['direction_shortname'] = "E"; |
| 1521 | 1521 | $temp_array['direction_fullname'] = "East"; |
| 1522 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1522 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1523 | 1523 | $temp_array['direction_degree'] = $direction; |
| 1524 | 1524 | $temp_array['direction_shortname'] = "ESE"; |
| 1525 | 1525 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1526 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1526 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1527 | 1527 | $temp_array['direction_degree'] = $direction; |
| 1528 | 1528 | $temp_array['direction_shortname'] = "SE"; |
| 1529 | 1529 | $temp_array['direction_fullname'] = "Southeast"; |
| 1530 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1530 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1531 | 1531 | $temp_array['direction_degree'] = $direction; |
| 1532 | 1532 | $temp_array['direction_shortname'] = "SSE"; |
| 1533 | 1533 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1534 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1534 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1535 | 1535 | $temp_array['direction_degree'] = $direction; |
| 1536 | 1536 | $temp_array['direction_shortname'] = "S"; |
| 1537 | 1537 | $temp_array['direction_fullname'] = "South"; |
| 1538 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1538 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1539 | 1539 | $temp_array['direction_degree'] = $direction; |
| 1540 | 1540 | $temp_array['direction_shortname'] = "SSW"; |
| 1541 | 1541 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1542 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1542 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1543 | 1543 | $temp_array['direction_degree'] = $direction; |
| 1544 | 1544 | $temp_array['direction_shortname'] = "SW"; |
| 1545 | 1545 | $temp_array['direction_fullname'] = "Southwest"; |
| 1546 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1546 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1547 | 1547 | $temp_array['direction_degree'] = $direction; |
| 1548 | 1548 | $temp_array['direction_shortname'] = "WSW"; |
| 1549 | 1549 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1550 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1550 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1551 | 1551 | $temp_array['direction_degree'] = $direction; |
| 1552 | 1552 | $temp_array['direction_shortname'] = "W"; |
| 1553 | 1553 | $temp_array['direction_fullname'] = "West"; |
| 1554 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1554 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1555 | 1555 | $temp_array['direction_degree'] = $direction; |
| 1556 | 1556 | $temp_array['direction_shortname'] = "WNW"; |
| 1557 | 1557 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1558 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1558 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1559 | 1559 | $temp_array['direction_degree'] = $direction; |
| 1560 | 1560 | $temp_array['direction_shortname'] = "NW"; |
| 1561 | 1561 | $temp_array['direction_fullname'] = "Northwest"; |
| 1562 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1562 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1563 | 1563 | $temp_array['direction_degree'] = $direction; |
| 1564 | 1564 | $temp_array['direction_shortname'] = "NNW"; |
| 1565 | 1565 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1576,11 +1576,11 @@ discard block |
||
| 1576 | 1576 | * @param Float $longitude longitute of the flight |
| 1577 | 1577 | * @return String the countrie |
| 1578 | 1578 | */ |
| 1579 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1579 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1580 | 1580 | { |
| 1581 | 1581 | global $globalDBdriver, $globalDebug; |
| 1582 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1583 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1582 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1583 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1584 | 1584 | |
| 1585 | 1585 | $Connection = new Connection($this->db); |
| 1586 | 1586 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1620,7 +1620,7 @@ discard block |
||
| 1620 | 1620 | public function getCountryFromISO2($iso2) |
| 1621 | 1621 | { |
| 1622 | 1622 | global $globalDBdriver, $globalDebug; |
| 1623 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1623 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1624 | 1624 | |
| 1625 | 1625 | $Connection = new Connection($this->db); |
| 1626 | 1626 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1649,11 +1649,11 @@ discard block |
||
| 1649 | 1649 | * @return Array the vessel type list |
| 1650 | 1650 | * |
| 1651 | 1651 | */ |
| 1652 | - public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 1652 | + public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1653 | 1653 | { |
| 1654 | 1654 | global $globalDBdriver; |
| 1655 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1656 | - $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
| 1655 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1656 | + $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
| 1657 | 1657 | FROM tracker_output ".$filter_query." tracker_output.type <> ''"; |
| 1658 | 1658 | if ($olderthanmonths > 0) { |
| 1659 | 1659 | if ($globalDBdriver == 'mysql') { |
@@ -1673,28 +1673,28 @@ discard block |
||
| 1673 | 1673 | if ($year != '') { |
| 1674 | 1674 | if ($globalDBdriver == 'mysql') { |
| 1675 | 1675 | $query .= " AND YEAR(tracker_output.date) = :year"; |
| 1676 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1676 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1677 | 1677 | } else { |
| 1678 | 1678 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
| 1679 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1679 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1680 | 1680 | } |
| 1681 | 1681 | } |
| 1682 | 1682 | if ($month != '') { |
| 1683 | 1683 | if ($globalDBdriver == 'mysql') { |
| 1684 | 1684 | $query .= " AND MONTH(tracker_output.date) = :month"; |
| 1685 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1685 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1686 | 1686 | } else { |
| 1687 | 1687 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
| 1688 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1688 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1689 | 1689 | } |
| 1690 | 1690 | } |
| 1691 | 1691 | if ($day != '') { |
| 1692 | 1692 | if ($globalDBdriver == 'mysql') { |
| 1693 | 1693 | $query .= " AND DAY(tracker_output.date) = :day"; |
| 1694 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1694 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1695 | 1695 | } else { |
| 1696 | 1696 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
| 1697 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1697 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1698 | 1698 | } |
| 1699 | 1699 | } |
| 1700 | 1700 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
@@ -1703,7 +1703,7 @@ discard block |
||
| 1703 | 1703 | $sth->execute($query_values); |
| 1704 | 1704 | $tracker_array = array(); |
| 1705 | 1705 | $temp_array = array(); |
| 1706 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1706 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1707 | 1707 | { |
| 1708 | 1708 | $temp_array['tracker_type'] = $row['tracker_type']; |
| 1709 | 1709 | $temp_array['tracker_type_count'] = $row['tracker_type_count']; |
@@ -1738,7 +1738,7 @@ discard block |
||
| 1738 | 1738 | |
| 1739 | 1739 | $bitly_data = json_decode($bitly_data); |
| 1740 | 1740 | $bitly_url = ''; |
| 1741 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1741 | + if ($bitly_data->status_txt = "OK") { |
|
| 1742 | 1742 | $bitly_url = $bitly_data->data->url; |
| 1743 | 1743 | } |
| 1744 | 1744 | |
@@ -1748,7 +1748,7 @@ discard block |
||
| 1748 | 1748 | |
| 1749 | 1749 | public function getOrderBy() |
| 1750 | 1750 | { |
| 1751 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 1751 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 1752 | 1752 | |
| 1753 | 1753 | return $orderby; |
| 1754 | 1754 | |