@@ -10,100 +10,100 @@ |
||
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Get SQL query part for filter used |
|
| 15 | - * @param Array $filter the filter |
|
| 16 | - * @return Array the SQL part |
|
| 17 | - */ |
|
| 18 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 13 | + /** |
|
| 14 | + * Get SQL query part for filter used |
|
| 15 | + * @param Array $filter the filter |
|
| 16 | + * @return Array the SQL part |
|
| 17 | + */ |
|
| 18 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | 19 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 21 | - if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
| 21 | + if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
| 22 | 22 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
| 23 | 23 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
| 24 | 24 | } |
| 25 | - } else { |
|
| 25 | + } else { |
|
| 26 | 26 | $filter = $globalStatsFilters[$globalFilterName]; |
| 27 | - } |
|
| 27 | + } |
|
| 28 | 28 | } |
| 29 | 29 | if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
| 30 | 30 | $filter_query_join = ''; |
| 31 | 31 | $filter_query_where = ''; |
| 32 | 32 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 33 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 33 | + $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 34 | 34 | } |
| 35 | 35 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 36 | 36 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 37 | 37 | $filter_query = $filter_query_join.$filter_query_where; |
| 38 | 38 | return $filter_query; |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function getAll() { |
|
| 42 | - $filter_query = $this->getFilter(array()); |
|
| 43 | - $query = "SELECT * FROM atc".$filter_query; |
|
| 44 | - $query_values = array(); |
|
| 45 | - try { |
|
| 46 | - $sth = $this->db->prepare($query); |
|
| 47 | - $sth->execute($query_values); |
|
| 48 | - } catch(PDOException $e) { |
|
| 49 | - return "error : ".$e->getMessage(); |
|
| 50 | - } |
|
| 51 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 52 | - return $all; |
|
| 53 | - } |
|
| 41 | + public function getAll() { |
|
| 42 | + $filter_query = $this->getFilter(array()); |
|
| 43 | + $query = "SELECT * FROM atc".$filter_query; |
|
| 44 | + $query_values = array(); |
|
| 45 | + try { |
|
| 46 | + $sth = $this->db->prepare($query); |
|
| 47 | + $sth->execute($query_values); |
|
| 48 | + } catch(PDOException $e) { |
|
| 49 | + return "error : ".$e->getMessage(); |
|
| 50 | + } |
|
| 51 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 52 | + return $all; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 56 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 57 | - $info = str_replace('^','<br />',$info); |
|
| 58 | - $info = str_replace('&sect;','',$info); |
|
| 59 | - $info = str_replace('"','',$info); |
|
| 60 | - if ($type == '') $type = NULL; |
|
| 61 | - $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
|
| 62 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 63 | - try { |
|
| 64 | - $sth = $this->db->prepare($query); |
|
| 65 | - $sth->execute($query_values); |
|
| 66 | - } catch(PDOException $e) { |
|
| 67 | - return "error : ".$e->getMessage(); |
|
| 68 | - } |
|
| 69 | - } |
|
| 55 | + public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 56 | + $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 57 | + $info = str_replace('^','<br />',$info); |
|
| 58 | + $info = str_replace('&sect;','',$info); |
|
| 59 | + $info = str_replace('"','',$info); |
|
| 60 | + if ($type == '') $type = NULL; |
|
| 61 | + $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
|
| 62 | + $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 63 | + try { |
|
| 64 | + $sth = $this->db->prepare($query); |
|
| 65 | + $sth->execute($query_values); |
|
| 66 | + } catch(PDOException $e) { |
|
| 67 | + return "error : ".$e->getMessage(); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function deleteById($id) { |
|
| 72 | - $query = "DELETE FROM atc WHERE atc_id = :id"; |
|
| 73 | - $query_values = array(':id' => $id); |
|
| 74 | - try { |
|
| 75 | - $sth = $this->db->prepare($query); |
|
| 76 | - $sth->execute($query_values); |
|
| 77 | - } catch(PDOException $e) { |
|
| 78 | - return "error : ".$e->getMessage(); |
|
| 79 | - } |
|
| 80 | - } |
|
| 71 | + public function deleteById($id) { |
|
| 72 | + $query = "DELETE FROM atc WHERE atc_id = :id"; |
|
| 73 | + $query_values = array(':id' => $id); |
|
| 74 | + try { |
|
| 75 | + $sth = $this->db->prepare($query); |
|
| 76 | + $sth->execute($query_values); |
|
| 77 | + } catch(PDOException $e) { |
|
| 78 | + return "error : ".$e->getMessage(); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - public function deleteAll() { |
|
| 83 | - $query = "DELETE FROM atc"; |
|
| 84 | - $query_values = array(); |
|
| 85 | - try { |
|
| 86 | - $sth = $this->db->prepare($query); |
|
| 87 | - $sth->execute($query_values); |
|
| 88 | - } catch(PDOException $e) { |
|
| 89 | - return "error : ".$e->getMessage(); |
|
| 90 | - } |
|
| 91 | - } |
|
| 82 | + public function deleteAll() { |
|
| 83 | + $query = "DELETE FROM atc"; |
|
| 84 | + $query_values = array(); |
|
| 85 | + try { |
|
| 86 | + $sth = $this->db->prepare($query); |
|
| 87 | + $sth->execute($query_values); |
|
| 88 | + } catch(PDOException $e) { |
|
| 89 | + return "error : ".$e->getMessage(); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | public function deleteOldATC() { |
| 94 | - global $globalDBdriver; |
|
| 95 | - if ($globalDBdriver == 'mysql') { |
|
| 96 | - $query = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen"; |
|
| 97 | - } else { |
|
| 98 | - $query = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - '1 HOUR'->INTERVAL >= atc.atc_lastseen"; |
|
| 99 | - } |
|
| 100 | - try { |
|
| 101 | - $sth = $this->db->prepare($query); |
|
| 102 | - $sth->execute(); |
|
| 103 | - } catch(PDOException $e) { |
|
| 104 | - return "error"; |
|
| 105 | - } |
|
| 106 | - return "success"; |
|
| 107 | - } |
|
| 94 | + global $globalDBdriver; |
|
| 95 | + if ($globalDBdriver == 'mysql') { |
|
| 96 | + $query = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen"; |
|
| 97 | + } else { |
|
| 98 | + $query = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - '1 HOUR'->INTERVAL >= atc.atc_lastseen"; |
|
| 99 | + } |
|
| 100 | + try { |
|
| 101 | + $sth = $this->db->prepare($query); |
|
| 102 | + $sth->execute(); |
|
| 103 | + } catch(PDOException $e) { |
|
| 104 | + return "error"; |
|
| 105 | + } |
|
| 106 | + return "success"; |
|
| 107 | + } |
|
| 108 | 108 | } |
| 109 | 109 | ?> |
| 110 | 110 | \ No newline at end of file |
@@ -15,22 +15,22 @@ discard block |
||
| 15 | 15 | * @param Array $filter the filter |
| 16 | 16 | * @return Array the SQL part |
| 17 | 17 | */ |
| 18 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 18 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 19 | 19 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 22 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
| 22 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
| 23 | 23 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
| 24 | 24 | } |
| 25 | 25 | } else { |
| 26 | 26 | $filter = $globalStatsFilters[$globalFilterName]; |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 30 | 30 | $filter_query_join = ''; |
| 31 | 31 | $filter_query_where = ''; |
| 32 | 32 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 33 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 33 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 34 | 34 | } |
| 35 | 35 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 36 | 36 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -45,25 +45,25 @@ discard block |
||
| 45 | 45 | try { |
| 46 | 46 | $sth = $this->db->prepare($query); |
| 47 | 47 | $sth->execute($query_values); |
| 48 | - } catch(PDOException $e) { |
|
| 48 | + } catch (PDOException $e) { |
|
| 49 | 49 | return "error : ".$e->getMessage(); |
| 50 | 50 | } |
| 51 | 51 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 52 | 52 | return $all; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 56 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 57 | - $info = str_replace('^','<br />',$info); |
|
| 58 | - $info = str_replace('&sect;','',$info); |
|
| 59 | - $info = str_replace('"','',$info); |
|
| 55 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 56 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 57 | + $info = str_replace('^', '<br />', $info); |
|
| 58 | + $info = str_replace('&sect;', '', $info); |
|
| 59 | + $info = str_replace('"', '', $info); |
|
| 60 | 60 | if ($type == '') $type = NULL; |
| 61 | 61 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
| 62 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 62 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
| 63 | 63 | try { |
| 64 | 64 | $sth = $this->db->prepare($query); |
| 65 | 65 | $sth->execute($query_values); |
| 66 | - } catch(PDOException $e) { |
|
| 66 | + } catch (PDOException $e) { |
|
| 67 | 67 | return "error : ".$e->getMessage(); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | try { |
| 75 | 75 | $sth = $this->db->prepare($query); |
| 76 | 76 | $sth->execute($query_values); |
| 77 | - } catch(PDOException $e) { |
|
| 77 | + } catch (PDOException $e) { |
|
| 78 | 78 | return "error : ".$e->getMessage(); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | try { |
| 86 | 86 | $sth = $this->db->prepare($query); |
| 87 | 87 | $sth->execute($query_values); |
| 88 | - } catch(PDOException $e) { |
|
| 88 | + } catch (PDOException $e) { |
|
| 89 | 89 | return "error : ".$e->getMessage(); |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | try { |
| 101 | 101 | $sth = $this->db->prepare($query); |
| 102 | 102 | $sth->execute(); |
| 103 | - } catch(PDOException $e) { |
|
| 103 | + } catch (PDOException $e) { |
|
| 104 | 104 | return "error"; |
| 105 | 105 | } |
| 106 | 106 | return "success"; |